Spaces:
Build error
Build error
James McCool
commited on
Commit
·
834a92c
1
Parent(s):
5a42d4a
Refactor hitter tab layout and enhance position selection in Streamlit app
Browse files- Reduced the number of columns in the hitter tab layout for improved organization.
- Replaced single select for positions with a multiselect option, allowing users to choose between 'All' or 'Specific' positions.
- Updated logic to handle position selection based on user input, enhancing interactivity.
- Adjusted loading spinner duration for league baselines to improve user experience during data retrieval.
- src/streamlit_app.py +10 -6
src/streamlit_app.py
CHANGED
|
@@ -173,7 +173,7 @@ with pitcher_tab:
|
|
| 173 |
with hitter_tab:
|
| 174 |
with st.container(border = True):
|
| 175 |
st.info('Note: Splits options are available for all baseline tables')
|
| 176 |
-
col1, col2, col3, col4, col5
|
| 177 |
with col1:
|
| 178 |
site_var_hitter = st.selectbox('Site', ['DraftKings', 'FanDuel'], key = 'site_var_hitter')
|
| 179 |
with col2:
|
|
@@ -181,15 +181,19 @@ with hitter_tab:
|
|
| 181 |
with col3:
|
| 182 |
splits_var_hitter = st.selectbox('Splits', ['Overall', 'RHP', 'LHP'], key = 'splits_var_hitter')
|
| 183 |
with col4:
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
with col5:
|
| 186 |
team_type_hitter = st.selectbox('Do you want to view all teams or Specific ones?', ['All', 'Specific'], key = 'team_type_hitter')
|
| 187 |
-
with col6:
|
| 188 |
if team_type_hitter == 'Specific':
|
| 189 |
team_var_hitter = st.multiselect('Select Teams', slate_hitters['Team'].unique(), key = 'team_var_hitter')
|
| 190 |
else:
|
| 191 |
team_var_hitter = None
|
| 192 |
-
st.write('All
|
| 193 |
|
| 194 |
if table_var_hitter == 'Current Slate Overview':
|
| 195 |
disp_raw = slate_hitters
|
|
@@ -246,8 +250,8 @@ with hitter_tab:
|
|
| 246 |
|
| 247 |
with hitter_disp_container:
|
| 248 |
if table_var_hitter in (['League Aggregate Baselines', 'League Short Term Baselines', 'League Long Term Baselines']):
|
| 249 |
-
with st.spinner("Full league baselines can take some time to load"
|
| 250 |
-
time.sleep(
|
| 251 |
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)
|
| 252 |
|
| 253 |
with team_tab:
|
|
|
|
| 173 |
with hitter_tab:
|
| 174 |
with st.container(border = True):
|
| 175 |
st.info('Note: Splits options are available for all baseline tables')
|
| 176 |
+
col1, col2, col3, col4, col5 = st.columns(5)
|
| 177 |
with col1:
|
| 178 |
site_var_hitter = st.selectbox('Site', ['DraftKings', 'FanDuel'], key = 'site_var_hitter')
|
| 179 |
with col2:
|
|
|
|
| 181 |
with col3:
|
| 182 |
splits_var_hitter = st.selectbox('Splits', ['Overall', 'RHP', 'LHP'], key = 'splits_var_hitter')
|
| 183 |
with col4:
|
| 184 |
+
position_type_hitter = st.multiselect('Select Positions', ['All', 'Specific'], key = 'position_var_hitter')
|
| 185 |
+
if position_type_hitter == 'Specific':
|
| 186 |
+
position_var_hitter = st.multiselect('Positions', ['C', '1B', '2B', '3B', 'SS', 'OF'], key = 'position_var_hitter')
|
| 187 |
+
else:
|
| 188 |
+
position_var_hitter = None
|
| 189 |
+
st.write('All Positions selected')
|
| 190 |
with col5:
|
| 191 |
team_type_hitter = st.selectbox('Do you want to view all teams or Specific ones?', ['All', 'Specific'], key = 'team_type_hitter')
|
|
|
|
| 192 |
if team_type_hitter == 'Specific':
|
| 193 |
team_var_hitter = st.multiselect('Select Teams', slate_hitters['Team'].unique(), key = 'team_var_hitter')
|
| 194 |
else:
|
| 195 |
team_var_hitter = None
|
| 196 |
+
st.write('All Teams selected')
|
| 197 |
|
| 198 |
if table_var_hitter == 'Current Slate Overview':
|
| 199 |
disp_raw = slate_hitters
|
|
|
|
| 250 |
|
| 251 |
with hitter_disp_container:
|
| 252 |
if table_var_hitter in (['League Aggregate Baselines', 'League Short Term Baselines', 'League Long Term Baselines']):
|
| 253 |
+
with st.spinner("Full league baselines can take some time to load"):
|
| 254 |
+
time.sleep(7)
|
| 255 |
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)
|
| 256 |
|
| 257 |
with team_tab:
|