James McCool commited on
Commit
68b8a20
·
1 Parent(s): 071f3d9

Enhance scoring percentages dataframe in app.py by converting percentage strings to float for '8+ runs' and 'Win Percentage', improving data accuracy and usability.

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -81,6 +81,8 @@ def init_baselines():
81
  team_frame = pd.DataFrame(cursor)
82
  scoring_percentages = team_frame.drop(columns=['_id'])
83
  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']]
 
 
84
 
85
  return roo_data, sd_roo_data, scoring_percentages
86
 
@@ -138,7 +140,7 @@ with tab1:
138
  with col4:
139
  own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
140
  st.title("Scoring Percentages")
141
- st.dataframe(scoring_percentages.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=750, use_container_width = True, hide_index=True)
142
 
143
  with tab2:
144
  st.title("Player ROO")
@@ -150,6 +152,8 @@ with tab2:
150
  elif site_var == "Fanduel":
151
  display_data = sd_roo_data[sd_roo_data['site'] == 'Fanduel']
152
  display_data = display_data[display_data['slate'] == 'FD SD1']
 
 
153
  st.dataframe(display_data.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), height=750, use_container_width = True, hide_index=True)
154
 
155
  with tab3:
 
81
  team_frame = pd.DataFrame(cursor)
82
  scoring_percentages = team_frame.drop(columns=['_id'])
83
  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']]
84
+ scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float)
85
+ scoring_percentages['Win Percentage'] = scoring_percentages['Win Percentage'].replace('%', '', regex=True).astype(float)
86
 
87
  return roo_data, sd_roo_data, scoring_percentages
88
 
 
140
  with col4:
141
  own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
142
  st.title("Scoring Percentages")
143
+ 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)
144
 
145
  with tab2:
146
  st.title("Player ROO")
 
152
  elif site_var == "Fanduel":
153
  display_data = sd_roo_data[sd_roo_data['site'] == 'Fanduel']
154
  display_data = display_data[display_data['slate'] == 'FD SD1']
155
+
156
+ display_data = display_data.drop(columns=['site', 'slate', 'version', 'timestamp'])
157
  st.dataframe(display_data.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), height=750, use_container_width = True, hide_index=True)
158
 
159
  with tab3: