James McCool commited on
Commit
899c130
·
1 Parent(s): e840845

Update 'Order' column type to integer and add 'Runs/$' calculation in scoring percentages DataFrame in app.py for improved data accuracy and analysis capabilities.

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -82,7 +82,7 @@ def init_baselines():
82
  hold_frame['Hand'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['bats']), '')
83
 
84
  roo_data.insert(3, 'Hand', hold_frame['Hand'])
85
- roo_data.insert(4, 'Order', hold_frame['Order'])
86
 
87
  dk_roo = roo_data[roo_data['Site'] == 'Draftkings']
88
  dk_id_map = dict(zip(dk_roo['Player'], dk_roo['player_ID']))
@@ -101,7 +101,8 @@ def init_baselines():
101
  cursor = collection.find()
102
  team_frame = pd.DataFrame(cursor)
103
  scoring_percentages = team_frame.drop(columns=['_id'])
104
- scoring_percentages = scoring_percentages[['Names', 'Avg_Salary', 'Stack_Prio', 'Opp_SP', 'Avg First Inning', 'First Inning Lead Percentage', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage', 'Avg Score', '8+ runs', 'Win Percentage',
 
105
  'DK Main Slate', 'DK Secondary Slate', 'DK Turbo Slate', 'FD Main Slate', 'FD Secondary Slate', 'FD Turbo Slate', 'DK Main Top Score', 'FD Main Top Score', 'DK Secondary Top Score', 'FD Secondary Top Score',
106
  'DK Turbo Top Score', 'FD Turbo Top Score']]
107
  scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)
 
82
  hold_frame['Hand'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['bats']), '')
83
 
84
  roo_data.insert(3, 'Hand', hold_frame['Hand'])
85
+ roo_data.insert(4, 'Order', hold_frame['Order'].astype(int))
86
 
87
  dk_roo = roo_data[roo_data['Site'] == 'Draftkings']
88
  dk_id_map = dict(zip(dk_roo['Player'], dk_roo['player_ID']))
 
101
  cursor = collection.find()
102
  team_frame = pd.DataFrame(cursor)
103
  scoring_percentages = team_frame.drop(columns=['_id'])
104
+ scoring_percentages['Runs/$'] = scoring_percentages['Avg Score'] / (scoring_percentages['Avg_Salary'] / 1000)
105
+ scoring_percentages = scoring_percentages[['Names', 'Avg_Salary', 'Stack_Prio', 'Opp_SP', 'Avg First Inning', 'First Inning Lead Percentage', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage', 'Avg Score', 'Runs/$', '8+ runs', 'Win Percentage',
106
  'DK Main Slate', 'DK Secondary Slate', 'DK Turbo Slate', 'FD Main Slate', 'FD Secondary Slate', 'FD Turbo Slate', 'DK Main Top Score', 'FD Main Top Score', 'DK Secondary Top Score', 'FD Secondary Top Score',
107
  'DK Turbo Top Score', 'FD Turbo Top Score']]
108
  scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)