James McCool commited on
Commit
89bf41c
·
1 Parent(s): 2565d6d

Update scoring percentages in app.py to include 'Slate' column for filtering data based on selected slate type, enhancing user experience and data relevance in the display.

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -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']]
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']
@@ -278,8 +278,14 @@ with tab1:
278
  st.header("Scoring Percentages")
279
  with st.expander("Info and Filters"):
280
  with st.container():
281
- slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate', 'All Games'), key='slate_var1')
282
  own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
 
 
 
 
 
 
283
  if view_var == "Simple":
284
  scoring_percentages = scoring_percentages[['Names', 'Avg Score', '8+ runs', 'Win Percentage']]
285
  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)
 
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']
 
278
  st.header("Scoring Percentages")
279
  with st.expander("Info and Filters"):
280
  with st.container():
281
+ slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'All Games'), key='slate_var1')
282
  own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
283
+
284
+ if slate_var1 == 'Main Slate':
285
+ scoring_percentages = scoring_percentages[scoring_percentages['Slate'] == 'Main']
286
+ elif slate_var1 != 'Main Slate':
287
+ pass
288
+
289
  if view_var == "Simple":
290
  scoring_percentages = scoring_percentages[['Names', 'Avg Score', '8+ runs', 'Win Percentage']]
291
  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)