Spaces:
Build error
Build error
James McCool
commited on
Commit
·
2a7c2bb
1
Parent(s):
2f31f7d
Enhance pitcher data display logic in Streamlit app
Browse files- Updated dataframe filtering for 'Active Baselines', 'League Aggregate Baselines', 'League Short Term Baselines', and 'League Long Term Baselines' to include splits based on user selection.
- Improved clarity by explicitly defining columns to display for each baseline type.
- Ensured consistent dataframe rendering with index hidden for better presentation.
- src/streamlit_app.py +17 -2
src/streamlit_app.py
CHANGED
|
@@ -118,19 +118,34 @@ with pitcher_tab:
|
|
| 118 |
elif table_var_sp == 'Current Slate Overview':
|
| 119 |
st.session_state['sp_disp_frame'] = starting_pitchers
|
| 120 |
elif table_var_sp == 'Active Baselines':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
st.session_state['sp_disp_frame'] = pitcher_info
|
| 122 |
elif table_var_sp == 'League Aggregate Baselines':
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
| 124 |
elif table_var_sp == 'League Short Term Baselines':
|
|
|
|
|
|
|
|
|
|
| 125 |
st.session_state['sp_disp_frame'] = pitcher_short
|
| 126 |
elif table_var_sp == 'League Long Term Baselines':
|
|
|
|
|
|
|
|
|
|
| 127 |
st.session_state['sp_disp_frame'] = pitcher_long
|
| 128 |
|
| 129 |
sp_disp_container = st.container(border = True)
|
| 130 |
sp_disp_container = sp_disp_container.empty()
|
| 131 |
|
| 132 |
with sp_disp_container:
|
| 133 |
-
st.dataframe(st.session_state['sp_disp_frame'])
|
| 134 |
|
| 135 |
with hitter_tab:
|
| 136 |
with st.expander('Info and Display Options'):
|
|
|
|
| 118 |
elif table_var_sp == 'Current Slate Overview':
|
| 119 |
st.session_state['sp_disp_frame'] = starting_pitchers
|
| 120 |
elif table_var_sp == 'Active Baselines':
|
| 121 |
+
disp_raw = pitcher_info
|
| 122 |
+
if splits_var_sp != 'Overall':
|
| 123 |
+
disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
|
| 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', 'xHits', '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]
|
| 131 |
+
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']]
|
| 132 |
+
st.session_state['sp_disp_frame'] = disp_raw
|
| 133 |
elif table_var_sp == 'League Short Term Baselines':
|
| 134 |
+
disp_raw = pitcher_short
|
| 135 |
+
disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
|
| 136 |
+
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']]
|
| 137 |
st.session_state['sp_disp_frame'] = pitcher_short
|
| 138 |
elif table_var_sp == 'League Long Term Baselines':
|
| 139 |
+
disp_raw = pitcher_long
|
| 140 |
+
disp_raw = disp_raw[disp_raw['Set'] == splits_var_sp]
|
| 141 |
+
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']]
|
| 142 |
st.session_state['sp_disp_frame'] = pitcher_long
|
| 143 |
|
| 144 |
sp_disp_container = st.container(border = True)
|
| 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'):
|