Spaces:
Running
Running
James McCool
commited on
Commit
·
1e6c2b8
1
Parent(s):
1a7cb58
Refactor team ownership calculations in app.py to separate DraftKings and FanDuel data processing, enhancing clarity and accuracy in scoring percentages while removing unnecessary columns.
Browse files
app.py
CHANGED
@@ -87,9 +87,13 @@ def init_baselines():
|
|
87 |
scoring_percentages = scoring_percentages[['Names', 'Avg First Inning', 'First Inning Lead Percentage', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage', 'Avg Score', '8+ runs', 'Win Percentage']]
|
88 |
scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)
|
89 |
scoring_percentages['Win Percentage'] = scoring_percentages['Win Percentage'].replace('%', '', regex=True).astype(float)
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
93 |
scoring_percentages.drop('Team', axis=1, inplace=True)
|
94 |
|
95 |
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo
|
|
|
87 |
scoring_percentages = scoring_percentages[['Names', 'Avg First Inning', 'First Inning Lead Percentage', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage', 'Avg Score', '8+ runs', 'Win Percentage']]
|
88 |
scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)
|
89 |
scoring_percentages['Win Percentage'] = scoring_percentages['Win Percentage'].replace('%', '', regex=True).astype(float)
|
90 |
+
dk_hitters_only = dk_roo[dk_roo['pos_group'] != 'Pitchers']
|
91 |
+
dk_team_ownership = dk_hitters_only.groupby('Team')['DK Own%'].sum().reset_index()
|
92 |
+
fd_hitters_only = fd_roo[fd_roo['pos_group'] != 'Pitchers']
|
93 |
+
fd_team_ownership = fd_hitters_only.groupby('Team')['FD Own%'].sum().reset_index()
|
94 |
+
scoring_percentages = scoring_percentages.merge(dk_team_ownership, left_on='Names', right_on='Team', how='left')
|
95 |
+
scoring_percentages.drop('Team', axis=1, inplace=True)
|
96 |
+
scoring_percentages = scoring_percentages.merge(fd_team_ownership, left_on='Names', right_on='Team', how='left')
|
97 |
scoring_percentages.drop('Team', axis=1, inplace=True)
|
98 |
|
99 |
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo
|