Spaces:
Running
Running
James McCool
commited on
Commit
·
6f594e5
1
Parent(s):
9c7ad76
Refactor scoring percentage calculations in app.py to differentiate between DraftKings and FanDuel slate types, updating column names and improving data filtering logic for enhanced accuracy and user experience.
Browse files
app.py
CHANGED
@@ -276,12 +276,20 @@ with tab1:
|
|
276 |
slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate', 'Turbo Slate'), key='slate_var1')
|
277 |
own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
|
278 |
|
279 |
-
if
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
dk_hitters_only = dk_roo[dk_roo['pos_group'] != 'Pitchers']
|
287 |
if slate_var1 == 'Main Slate':
|
@@ -311,10 +319,16 @@ with tab1:
|
|
311 |
scoring_percentages['FD LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['FD Own%'].rank(pct=True).astype(float)
|
312 |
|
313 |
scoring_percentages = scoring_percentages.sort_values(by='8+ runs', ascending=False)
|
314 |
-
scoring_percentages = scoring_percentages.drop(['Main Slate', 'Secondary Slate', 'Turbo Slate'], axis=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
|
316 |
if view_var == "Simple":
|
317 |
-
scoring_percentages = scoring_percentages[['Names', '
|
318 |
st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True, hide_index=True)
|
319 |
elif view_var == "Advanced":
|
320 |
st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True, hide_index=True)
|
@@ -390,7 +404,7 @@ with tab2:
|
|
390 |
|
391 |
if view_var == "Simple":
|
392 |
try:
|
393 |
-
player_roo_disp = player_roo_disp[['Player', 'Position', 'Salary', 'Median', 'Ceiling', 'Own%']]
|
394 |
st.dataframe(player_roo_disp.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), height=750, use_container_width = True, hide_index=True)
|
395 |
except:
|
396 |
st.dataframe(player_roo_disp.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), height=750, use_container_width = True, hide_index=True)
|
|
|
276 |
slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate', 'Turbo Slate'), key='slate_var1')
|
277 |
own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
|
278 |
|
279 |
+
if site_var == 'Draftkings':
|
280 |
+
if slate_var1 == 'Main Slate':
|
281 |
+
scoring_percentages = scoring_percentages[scoring_percentages['DK Main Slate'] == 1]
|
282 |
+
elif slate_var1 == 'Secondary Slate':
|
283 |
+
scoring_percentages = scoring_percentages[scoring_percentages['DK Secondary Slate'] == 1]
|
284 |
+
elif slate_var1 == 'Turbo Slate':
|
285 |
+
scoring_percentages = scoring_percentages[scoring_percentages['DK Turbo Slate'] == 1]
|
286 |
+
elif site_var == 'Fanduel':
|
287 |
+
if slate_var1 == 'Main Slate':
|
288 |
+
scoring_percentages = scoring_percentages[scoring_percentages['FD Main Slate'] == 1]
|
289 |
+
elif slate_var1 == 'Secondary Slate':
|
290 |
+
scoring_percentages = scoring_percentages[scoring_percentages['FD Secondary Slate'] == 1]
|
291 |
+
elif slate_var1 == 'Turbo Slate':
|
292 |
+
scoring_percentages = scoring_percentages[scoring_percentages['FD Turbo Slate'] == 1]
|
293 |
|
294 |
dk_hitters_only = dk_roo[dk_roo['pos_group'] != 'Pitchers']
|
295 |
if slate_var1 == 'Main Slate':
|
|
|
319 |
scoring_percentages['FD LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['FD Own%'].rank(pct=True).astype(float)
|
320 |
|
321 |
scoring_percentages = scoring_percentages.sort_values(by='8+ runs', ascending=False)
|
322 |
+
scoring_percentages = scoring_percentages.drop(['DK Main Slate', 'DK Secondary Slate', 'DK Turbo Slate', 'FD Main Slate', 'FD Secondary Slate', 'FD Turbo Slate'], axis=1)
|
323 |
+
if site_var == 'Draftkings':
|
324 |
+
scoring_percentages = scoring_percentages.drop(['FD LevX', 'FD Own%'], axis=1)
|
325 |
+
scoring_percentages = scoring_percentages.rename(columns={'DK LevX': 'LevX', 'DK Own%': 'Own%', 'Avg Score': 'Runs', 'Win Percentage': 'Win%', '8+ runs': '8+ Runs'})
|
326 |
+
elif site_var == 'Fanduel':
|
327 |
+
scoring_percentages = scoring_percentages.drop(['DK LevX', 'DK Own%'], axis=1)
|
328 |
+
scoring_percentages = scoring_percentages.rename(columns={'FD LevX': 'LevX', 'FD Own%': 'Own%', 'Avg Score': 'Runs', 'Win Percentage': 'Win%', '8+ runs': '8+ Runs'})
|
329 |
|
330 |
if view_var == "Simple":
|
331 |
+
scoring_percentages = scoring_percentages[['Names', 'Runs', '8+ Runs', 'Win%', 'LevX', 'Own%']]
|
332 |
st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True, hide_index=True)
|
333 |
elif view_var == "Advanced":
|
334 |
st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True, hide_index=True)
|
|
|
404 |
|
405 |
if view_var == "Simple":
|
406 |
try:
|
407 |
+
player_roo_disp = player_roo_disp[['Player', 'Position', 'Team', 'Salary', 'Median', 'Ceiling', 'Own%']]
|
408 |
st.dataframe(player_roo_disp.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), height=750, use_container_width = True, hide_index=True)
|
409 |
except:
|
410 |
st.dataframe(player_roo_disp.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), height=750, use_container_width = True, hide_index=True)
|