Spaces:
Running
Running
James McCool
commited on
Commit
·
44fbcd2
1
Parent(s):
d485820
Enhance team ownership calculations in app.py by filtering for 'main_slate' in DraftKings and FanDuel data, updating ownership metrics, and refining scoring percentages with new calculations for 'DK LevX' and 'FD LevX'.
Browse files
app.py
CHANGED
@@ -90,20 +90,6 @@ def init_baselines():
|
|
90 |
scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)
|
91 |
scoring_percentages['Win Percentage'] = scoring_percentages['Win Percentage'].replace('%', '', regex=True).astype(float)
|
92 |
scoring_percentages['Top Score'] = scoring_percentages['Top Score'].replace('', np.nan).astype(float)
|
93 |
-
dk_hitters_only = dk_roo[dk_roo['pos_group'] != 'Pitchers']
|
94 |
-
dk_hitters_only = dk_hitters_only.replace('CWS', 'CHW')
|
95 |
-
dk_team_ownership = dk_hitters_only.groupby('Team')['Own%'].sum().reset_index()
|
96 |
-
fd_hitters_only = fd_roo[fd_roo['pos_group'] != 'Pitchers']
|
97 |
-
fd_hitters_only = fd_hitters_only.replace('CWS', 'CHW')
|
98 |
-
fd_team_ownership = fd_hitters_only.groupby('Team')['Own%'].sum().reset_index()
|
99 |
-
scoring_percentages = scoring_percentages.merge(dk_team_ownership, left_on='Names', right_on='Team', how='left')
|
100 |
-
scoring_percentages.rename(columns={'Own%': 'DK Own%'}, inplace=True)
|
101 |
-
scoring_percentages.drop('Team', axis=1, inplace=True)
|
102 |
-
scoring_percentages = scoring_percentages.merge(fd_team_ownership, left_on='Names', right_on='Team', how='left')
|
103 |
-
scoring_percentages.rename(columns={'Own%': 'FD Own%'}, inplace=True)
|
104 |
-
scoring_percentages.drop('Team', axis=1, inplace=True)
|
105 |
-
scoring_percentages['DK LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['DK Own%'].rank(pct=True).astype(float)
|
106 |
-
scoring_percentages['FD LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['FD Own%'].rank(pct=True).astype(float)
|
107 |
|
108 |
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map
|
109 |
|
@@ -293,6 +279,23 @@ with tab1:
|
|
293 |
elif slate_var1 != 'Main Slate':
|
294 |
pass
|
295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
scoring_percentages = scoring_percentages.sort_values(by='8+ runs', ascending=False)
|
297 |
scoring_percentages = scoring_percentages.drop('Slate', axis=1)
|
298 |
|
|
|
90 |
scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)
|
91 |
scoring_percentages['Win Percentage'] = scoring_percentages['Win Percentage'].replace('%', '', regex=True).astype(float)
|
92 |
scoring_percentages['Top Score'] = scoring_percentages['Top Score'].replace('', np.nan).astype(float)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map
|
95 |
|
|
|
279 |
elif slate_var1 != 'Main Slate':
|
280 |
pass
|
281 |
|
282 |
+
dk_hitters_only = dk_roo[dk_roo['pos_group'] != 'Pitchers']
|
283 |
+
dk_hitters_only = dk_hitters_only[dk_hitters_only['Slate'] == 'main_slate']
|
284 |
+
dk_hitters_only = dk_hitters_only.replace('CWS', 'CHW')
|
285 |
+
dk_team_ownership = dk_hitters_only.groupby('Team')['Own%'].sum().reset_index()
|
286 |
+
fd_hitters_only = fd_roo[fd_roo['pos_group'] != 'Pitchers']
|
287 |
+
fd_hitters_only = fd_hitters_only[fd_hitters_only['Slate'] == 'main_slate']
|
288 |
+
fd_hitters_only = fd_hitters_only.replace('CWS', 'CHW')
|
289 |
+
fd_team_ownership = fd_hitters_only.groupby('Team')['Own%'].sum().reset_index()
|
290 |
+
scoring_percentages = scoring_percentages.merge(dk_team_ownership, left_on='Names', right_on='Team', how='left')
|
291 |
+
scoring_percentages.rename(columns={'Own%': 'DK Own%'}, inplace=True)
|
292 |
+
scoring_percentages.drop('Team', axis=1, inplace=True)
|
293 |
+
scoring_percentages = scoring_percentages.merge(fd_team_ownership, left_on='Names', right_on='Team', how='left')
|
294 |
+
scoring_percentages.rename(columns={'Own%': 'FD Own%'}, inplace=True)
|
295 |
+
scoring_percentages.drop('Team', axis=1, inplace=True)
|
296 |
+
scoring_percentages['DK LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['DK Own%'].rank(pct=True).astype(float)
|
297 |
+
scoring_percentages['FD LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['FD Own%'].rank(pct=True).astype(float)
|
298 |
+
|
299 |
scoring_percentages = scoring_percentages.sort_values(by='8+ runs', ascending=False)
|
300 |
scoring_percentages = scoring_percentages.drop('Slate', axis=1)
|
301 |
|