Spaces:
Running
Running
James McCool
commited on
Commit
·
9b875c4
1
Parent(s):
89bf41c
Add 'Top Score' to scoring percentages in app.py and calculate DK and FD LevX metrics based on this new column, enhancing player analysis capabilities.
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ def init_conn():
|
|
17 |
|
18 |
db, db2 = init_conn()
|
19 |
|
20 |
-
game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%}',
|
21 |
'Fifth Inning Lead Percentage': '{:.2%}', '8+ runs': '{:.2%}', 'DK LevX': '{:.2%}', 'FD LevX': '{:.2%}'}
|
22 |
|
23 |
player_roo_format = {'Top_finish': '{:.2%}','Top_5_finish': '{:.2%}', 'Top_10_finish': '{:.2%}', '20+%': '{:.2%}', '2x%': '{:.2%}', '3x%': '{:.2%}',
|
@@ -84,7 +84,7 @@ def init_baselines():
|
|
84 |
cursor = collection.find()
|
85 |
team_frame = pd.DataFrame(cursor)
|
86 |
scoring_percentages = team_frame.drop(columns=['_id'])
|
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', 'Slate']]
|
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']
|
@@ -97,6 +97,8 @@ def init_baselines():
|
|
97 |
scoring_percentages = scoring_percentages.merge(fd_team_ownership, left_on='Names', right_on='Team', how='left')
|
98 |
scoring_percentages.rename(columns={'Own%': 'FD Own%'}, inplace=True)
|
99 |
scoring_percentages.drop('Team', axis=1, inplace=True)
|
|
|
|
|
100 |
|
101 |
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo
|
102 |
|
|
|
17 |
|
18 |
db, db2 = init_conn()
|
19 |
|
20 |
+
game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%}', 'Top Score': '{:.2%}',
|
21 |
'Fifth Inning Lead Percentage': '{:.2%}', '8+ runs': '{:.2%}', 'DK LevX': '{:.2%}', 'FD LevX': '{:.2%}'}
|
22 |
|
23 |
player_roo_format = {'Top_finish': '{:.2%}','Top_5_finish': '{:.2%}', 'Top_10_finish': '{:.2%}', '20+%': '{:.2%}', '2x%': '{:.2%}', '3x%': '{:.2%}',
|
|
|
84 |
cursor = collection.find()
|
85 |
team_frame = pd.DataFrame(cursor)
|
86 |
scoring_percentages = team_frame.drop(columns=['_id'])
|
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', 'Slate', 'Top Score']]
|
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']
|
|
|
97 |
scoring_percentages = scoring_percentages.merge(fd_team_ownership, left_on='Names', right_on='Team', how='left')
|
98 |
scoring_percentages.rename(columns={'Own%': 'FD Own%'}, inplace=True)
|
99 |
scoring_percentages.drop('Team', axis=1, inplace=True)
|
100 |
+
scoring_percentages['DK LevX'] = scoring_percentages['Top Score'].rank(pct=True) - scoring_percentages['DK Own%'].rank(pct=True)
|
101 |
+
scoring_percentages['FD LevX'] = scoring_percentages['Top Score'].rank(pct=True) - scoring_percentages['FD Own%'].rank(pct=True)
|
102 |
|
103 |
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo
|
104 |
|