James McCool commited on
Commit
93913de
·
1 Parent(s): 9ca66f9

Update dataframe display settings in Streamlit app for enhanced usability

Browse files

- Set default values for team selection variables in pitcher and hitter tabs to None when 'All teams' is selected, improving clarity for users.
- Adjusted dataframe rendering height for pitcher, hitter, and team tabs to 750 pixels, enhancing visibility and user experience.

Files changed (1) hide show
  1. src/streamlit_app.py +7 -5
src/streamlit_app.py CHANGED
@@ -112,6 +112,7 @@ with pitcher_tab:
112
  if team_type_sp == 'Specific':
113
  team_var_sp = st.multiselect('Select Teams', starting_pitchers['Team'].unique(), key = 'team_var_sp')
114
  else:
 
115
  st.write('All teams selected')
116
 
117
  if table_var_sp == 'True AVG Splits':
@@ -142,18 +143,18 @@ with pitcher_tab:
142
  disp_raw = pitcher_short
143
  disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
144
  disp_raw = disp_raw[['Player', 'PA', 'Hits', 'Singles', 'Doubles', 'Homeruns', 'Strikeoutper', 'Strikeouts', 'Walkper', 'Walks', 'xBA', 'xSLG', 'xwOBA', 'BABIP', 'AVG', 'FB%', 'True_AVG', 'xHits', 'xHRs', 'xHR/PA', 'HWSr']]
145
- st.session_state['sp_disp_frame'] = pitcher_short
146
  elif table_var_sp == 'League Long Term Baselines':
147
  disp_raw = pitcher_long
148
  disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
149
  disp_raw = disp_raw[['Player', 'PA', 'Hits', 'Singles', 'Doubles', 'Homeruns', 'Strikeoutper', 'Strikeouts', 'Walkper', 'Walks', 'xBA', 'xSLG', 'xwOBA', 'BABIP', 'AVG', 'FB%', 'True_AVG', 'xHits', 'xHRs', 'xHR/PA', 'HWSr']]
150
- st.session_state['sp_disp_frame'] = pitcher_long
151
 
152
  sp_disp_container = st.container(border = True)
153
  sp_disp_container = sp_disp_container.empty()
154
 
155
  with sp_disp_container:
156
- st.dataframe(st.session_state['sp_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn_r').format(precision=2), use_container_width = True, hide_index = True)
157
 
158
  with hitter_tab:
159
  with st.container(border = True):
@@ -171,6 +172,7 @@ with hitter_tab:
171
  if team_type_hitter == 'Specific':
172
  team_var_hitter = st.multiselect('Select Teams', slate_hitters['Team'].unique(), key = 'team_var_hitter')
173
  else:
 
174
  st.write('All teams selected')
175
 
176
  if table_var_hitter == 'Current Slate Overview':
@@ -188,7 +190,7 @@ with hitter_tab:
188
  hitter_disp_container = hitter_disp_container.empty()
189
 
190
  with hitter_disp_container:
191
- st.dataframe(st.session_state['hitter_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True, hide_index = True)
192
 
193
  with team_tab:
194
  with st.container(border = True):
@@ -207,4 +209,4 @@ with team_tab:
207
  team_disp_container = team_disp_container.empty()
208
 
209
  with team_disp_container:
210
- st.dataframe(st.session_state['team_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True, hide_index = True)
 
112
  if team_type_sp == 'Specific':
113
  team_var_sp = st.multiselect('Select Teams', starting_pitchers['Team'].unique(), key = 'team_var_sp')
114
  else:
115
+ team_var_sp = None
116
  st.write('All teams selected')
117
 
118
  if table_var_sp == 'True AVG Splits':
 
143
  disp_raw = pitcher_short
144
  disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
145
  disp_raw = disp_raw[['Player', 'PA', 'Hits', 'Singles', 'Doubles', 'Homeruns', 'Strikeoutper', 'Strikeouts', 'Walkper', 'Walks', 'xBA', 'xSLG', 'xwOBA', 'BABIP', 'AVG', 'FB%', 'True_AVG', 'xHits', 'xHRs', 'xHR/PA', 'HWSr']]
146
+ st.session_state['sp_disp_frame'] = disp_raw
147
  elif table_var_sp == 'League Long Term Baselines':
148
  disp_raw = pitcher_long
149
  disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
150
  disp_raw = disp_raw[['Player', 'PA', 'Hits', 'Singles', 'Doubles', 'Homeruns', 'Strikeoutper', 'Strikeouts', 'Walkper', 'Walks', 'xBA', 'xSLG', 'xwOBA', 'BABIP', 'AVG', 'FB%', 'True_AVG', 'xHits', 'xHRs', 'xHR/PA', 'HWSr']]
151
+ st.session_state['sp_disp_frame'] = disp_raw
152
 
153
  sp_disp_container = st.container(border = True)
154
  sp_disp_container = sp_disp_container.empty()
155
 
156
  with sp_disp_container:
157
+ st.dataframe(st.session_state['sp_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn_r').format(precision=2), height = 750, use_container_width = True, hide_index = True)
158
 
159
  with hitter_tab:
160
  with st.container(border = True):
 
172
  if team_type_hitter == 'Specific':
173
  team_var_hitter = st.multiselect('Select Teams', slate_hitters['Team'].unique(), key = 'team_var_hitter')
174
  else:
175
+ team_var_hitter = None
176
  st.write('All teams selected')
177
 
178
  if table_var_hitter == 'Current Slate Overview':
 
190
  hitter_disp_container = hitter_disp_container.empty()
191
 
192
  with hitter_disp_container:
193
+ st.dataframe(st.session_state['hitter_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height = 750, use_container_width = True, hide_index = True)
194
 
195
  with team_tab:
196
  with st.container(border = True):
 
209
  team_disp_container = team_disp_container.empty()
210
 
211
  with team_disp_container:
212
+ st.dataframe(st.session_state['team_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height = 750, use_container_width = True, hide_index = True)