James McCool commited on
Commit
ae5c57d
·
1 Parent(s): 1e3bf64

Update scoring percentages to include 'Avg_Salary' and 'Stack_Prio' columns. Introduce Stack Priority filtering in the UI for enhanced data analysis. Adjust dataframe styling for improved visual representation of ownership metrics.

Browse files
Files changed (1) hide show
  1. app.py +20 -6
app.py CHANGED
@@ -53,7 +53,7 @@ def init_baselines():
53
  cursor = collection.find()
54
  team_frame = pd.DataFrame(cursor)
55
  scoring_percentages = team_frame.drop(columns=['_id'])
56
- 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',
57
  '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',
58
  'DK Turbo Top Score', 'FD Turbo Top Score']]
59
  scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)
@@ -246,7 +246,12 @@ with tab1:
246
  with st.expander("Info and Filters"):
247
  with st.container():
248
  slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate', 'Turbo Slate'), key='slate_var1')
249
- own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
 
 
 
 
 
250
 
251
  if site_var == 'Draftkings':
252
  if slate_var1 == 'Main Slate':
@@ -324,10 +329,12 @@ with tab1:
324
  if view_var == "Simple":
325
  scoring_percentages = scoring_percentages[['Names', 'Runs', '8+ Runs', 'Win%', 'LevX', 'Own%']]
326
  scoring_percentages = scoring_percentages.set_index('Names', drop=True)
327
- st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True)
328
  elif view_var == "Advanced":
 
 
329
  scoring_percentages = scoring_percentages.set_index('Names', drop=True)
330
- st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True)
331
 
332
  with tab2:
333
  st.header("Player ROO")
@@ -379,9 +386,16 @@ with tab2:
379
  elif slate_type_var2 == 'Showdown':
380
  player_roo_raw = sd_roo_data.copy()
381
  if site_var == 'Draftkings':
382
- player_roo_raw['Site'] = 'Draftkings'
383
  elif site_var == 'Fanduel':
384
- player_roo_raw['Site'] = 'Fanduel'
 
 
 
 
 
 
 
385
 
386
  if team_select2:
387
  player_roo_raw = player_roo_raw[player_roo_raw['Team'].isin(team_select2)]
 
53
  cursor = collection.find()
54
  team_frame = pd.DataFrame(cursor)
55
  scoring_percentages = team_frame.drop(columns=['_id'])
56
+ scoring_percentages = scoring_percentages[['Names', 'Avg_Salary', 'Stack_Prio', 'Avg First Inning', 'First Inning Lead Percentage', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage', 'Avg Score', '8+ runs', 'Win Percentage',
57
  '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',
58
  'DK Turbo Top Score', 'FD Turbo Top Score']]
59
  scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)
 
246
  with st.expander("Info and Filters"):
247
  with st.container():
248
  slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate', 'Turbo Slate'), key='slate_var1')
249
+ prio_split = st.radio("Do you want to isolate a specific Stack Priority?", ('No', 'Yes'), key='prio_split')
250
+ if prio_split == 'Yes':
251
+ prio_var = st.radio("Which Stack Priority are you looking for?", ['OF_Prio', 'IF_Prio'], key='prio_var')
252
+ else:
253
+ prio_var = None
254
+
255
 
256
  if site_var == 'Draftkings':
257
  if slate_var1 == 'Main Slate':
 
329
  if view_var == "Simple":
330
  scoring_percentages = scoring_percentages[['Names', 'Runs', '8+ Runs', 'Win%', 'LevX', 'Own%']]
331
  scoring_percentages = scoring_percentages.set_index('Names', drop=True)
332
+ st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').background_gradient(cmap='RdYlGn_r', subset=['Own%']).format(game_format, precision=2), height=750, use_container_width = True)
333
  elif view_var == "Advanced":
334
+ if prio_var is not None:
335
+ scoring_percentages = scoring_percentages[scoring_percentages['Stack_Prio'] == prio_var]
336
  scoring_percentages = scoring_percentages.set_index('Names', drop=True)
337
+ st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').background_gradient(cmap='RdYlGn_r', subset=['Avg_Salary', 'Own%']).format(game_format, precision=2), height=750, use_container_width = True)
338
 
339
  with tab2:
340
  st.header("Player ROO")
 
386
  elif slate_type_var2 == 'Showdown':
387
  player_roo_raw = sd_roo_data.copy()
388
  if site_var == 'Draftkings':
389
+ player_roo_raw['site'] = 'Draftkings'
390
  elif site_var == 'Fanduel':
391
+ player_roo_raw['site'] = 'Fanduel'
392
+
393
+ if slate_var2 == 'Main':
394
+ player_roo_raw = player_roo_raw[player_roo_raw['slate'] == 'DK SD1']
395
+ elif slate_var2 == 'Secondary':
396
+ player_roo_raw = player_roo_raw[player_roo_raw['slate'] == 'DK SD2']
397
+ elif slate_var2 == 'Auxiliary':
398
+ player_roo_raw = player_roo_raw[player_roo_raw['slate'] == 'DK SD3']
399
 
400
  if team_select2:
401
  player_roo_raw = player_roo_raw[player_roo_raw['Team'].isin(team_select2)]