James McCool commited on
Commit
252a303
·
1 Parent(s): b8e8bdb

Refactor app.py to consistently set index for scoring percentages and player ROO displays, enhancing data presentation and ensuring uniformity across different view types.

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -354,13 +354,13 @@ with tab1:
354
  elif site_var == 'Fanduel':
355
  scoring_percentages = scoring_percentages.rename(columns={'FD LevX': 'LevX', 'FD Own%': 'Own%', 'Avg Score': 'Runs', 'Win Percentage': 'Win%', '8+ runs': '8+ Runs'})
356
  scoring_percentages = scoring_percentages.drop(['DK Own%'], axis=1)
357
- scoring_percentages = scoring_percentages.set_index('Names', drop=True)
358
 
359
  if view_var == "Simple":
360
  scoring_percentages = scoring_percentages[['Names', 'Runs', '8+ Runs', 'Win%', 'LevX', 'Own%']]
361
  scoring_percentages = scoring_percentages.set_index('Names', drop=True)
362
  st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True)
363
  elif view_var == "Advanced":
 
364
  st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True)
365
 
366
  with tab2:
@@ -431,7 +431,6 @@ with tab2:
431
  player_roo_disp = player_roo_disp.drop(columns=['site', 'slate', 'version', 'timestamp'])
432
 
433
  player_roo_disp = player_roo_disp.drop_duplicates(subset=['Player'])
434
- player_roo_disp = player_roo_disp.set_index('Player', drop=True)
435
 
436
  if view_var == "Simple":
437
  try:
@@ -439,11 +438,15 @@ with tab2:
439
  player_roo_disp = player_roo_disp.set_index('Player', drop=True)
440
  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)
441
  except:
 
442
  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)
 
443
  elif view_var == "Advanced":
444
  try:
 
445
  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)
446
  except:
 
447
  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)
448
 
449
  with tab3:
 
354
  elif site_var == 'Fanduel':
355
  scoring_percentages = scoring_percentages.rename(columns={'FD LevX': 'LevX', 'FD Own%': 'Own%', 'Avg Score': 'Runs', 'Win Percentage': 'Win%', '8+ runs': '8+ Runs'})
356
  scoring_percentages = scoring_percentages.drop(['DK Own%'], axis=1)
 
357
 
358
  if view_var == "Simple":
359
  scoring_percentages = scoring_percentages[['Names', 'Runs', '8+ Runs', 'Win%', 'LevX', 'Own%']]
360
  scoring_percentages = scoring_percentages.set_index('Names', drop=True)
361
  st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True)
362
  elif view_var == "Advanced":
363
+ scoring_percentages = scoring_percentages.set_index('Names', drop=True)
364
  st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=750, use_container_width = True)
365
 
366
  with tab2:
 
431
  player_roo_disp = player_roo_disp.drop(columns=['site', 'slate', 'version', 'timestamp'])
432
 
433
  player_roo_disp = player_roo_disp.drop_duplicates(subset=['Player'])
 
434
 
435
  if view_var == "Simple":
436
  try:
 
438
  player_roo_disp = player_roo_disp.set_index('Player', drop=True)
439
  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)
440
  except:
441
+ player_roo_disp = player_roo_disp.set_index('Player', drop=True)
442
  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)
443
+
444
  elif view_var == "Advanced":
445
  try:
446
+ player_roo_disp = player_roo_disp.set_index('Player', drop=True)
447
  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)
448
  except:
449
+ player_roo_disp = player_roo_disp.set_index('Player', drop=True)
450
  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)
451
 
452
  with tab3: