James McCool commited on
Commit
c256b63
·
1 Parent(s): df23dc3

Enhance dataframe display in Streamlit app for improved readability

Browse files

- Updated the 'Splits' selection order in the pitcher tab for better user experience.
- Changed the dataframe rendering to include background gradients and formatting for enhanced visual appeal across pitcher, hitter, and team tabs.
- Ensured consistent use of styling and container width for all displayed dataframes.

Files changed (1) hide show
  1. src/streamlit_app.py +5 -5
src/streamlit_app.py CHANGED
@@ -105,7 +105,7 @@ with pitcher_tab:
105
  with col2:
106
  table_var_sp = st.selectbox('Table', ['True AVG Splits', 'HWSr Splits', 'Current Slate Overview', 'Active Baselines', 'League Aggregate Baselines', 'League Short Term Baselines', 'League Long Term Baselines'], key = 'table_var_sp')
107
  with col3:
108
- splits_var_sp = st.selectbox('Splits', ['Overall', 'RHH', 'LHH'], key = 'splits_var_sp')
109
 
110
  if table_var_sp == 'True AVG Splits':
111
  disp_raw = true_avg_split
@@ -124,7 +124,7 @@ with pitcher_tab:
124
  else:
125
  disp_raw = disp_raw[disp_raw['Set'] == 'RHH']
126
  disp_raw = disp_raw[['Names', 'DK_Salary', 'FD_Salary', 'Team', 'Opp', 'Opp_TT', 'Hand', 'K%', 'BB%', 'True AVG', 'xSLG', 'xBA', 'Hits', 'xHRs', 'xHR/PA']]
127
- st.session_state['sp_disp_frame'] = pitcher_info
128
  elif table_var_sp == 'League Aggregate Baselines':
129
  disp_raw = pitcher_agg
130
  disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
@@ -145,7 +145,7 @@ with pitcher_tab:
145
  sp_disp_container = sp_disp_container.empty()
146
 
147
  with sp_disp_container:
148
- st.dataframe(st.session_state['sp_disp_frame'], hide_index = True)
149
 
150
  with hitter_tab:
151
  with st.expander('Info and Display Options'):
@@ -173,7 +173,7 @@ with hitter_tab:
173
  hitter_disp_container = hitter_disp_container.empty()
174
 
175
  with hitter_disp_container:
176
- st.dataframe(st.session_state['hitter_disp_frame'])
177
 
178
  with team_tab:
179
  with st.expander('Info and Display Options'):
@@ -192,4 +192,4 @@ with team_tab:
192
  team_disp_container = team_disp_container.empty()
193
 
194
  with team_disp_container:
195
- st.dataframe(st.session_state['team_disp_frame'])
 
105
  with col2:
106
  table_var_sp = st.selectbox('Table', ['True AVG Splits', 'HWSr Splits', 'Current Slate Overview', 'Active Baselines', 'League Aggregate Baselines', 'League Short Term Baselines', 'League Long Term Baselines'], key = 'table_var_sp')
107
  with col3:
108
+ splits_var_sp = st.selectbox('Splits', ['RHH', 'LHH', 'Overall'], key = 'splits_var_sp')
109
 
110
  if table_var_sp == 'True AVG Splits':
111
  disp_raw = true_avg_split
 
124
  else:
125
  disp_raw = disp_raw[disp_raw['Set'] == 'RHH']
126
  disp_raw = disp_raw[['Names', 'DK_Salary', 'FD_Salary', 'Team', 'Opp', 'Opp_TT', 'Hand', 'K%', 'BB%', 'True AVG', 'xSLG', 'xBA', 'Hits', 'xHRs', 'xHR/PA']]
127
+ st.session_state['sp_disp_frame'] = disp_raw
128
  elif table_var_sp == 'League Aggregate Baselines':
129
  disp_raw = pitcher_agg
130
  disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
 
145
  sp_disp_container = sp_disp_container.empty()
146
 
147
  with sp_disp_container:
148
+ st.dataframe(st.session_state['sp_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True, hide_index = True)
149
 
150
  with hitter_tab:
151
  with st.expander('Info and Display Options'):
 
173
  hitter_disp_container = hitter_disp_container.empty()
174
 
175
  with hitter_disp_container:
176
+ 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)
177
 
178
  with team_tab:
179
  with st.expander('Info and Display Options'):
 
192
  team_disp_container = team_disp_container.empty()
193
 
194
  with team_disp_container:
195
+ 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)