Spaces:
Running
Running
James McCool
commited on
Commit
·
1042879
1
Parent(s):
e27c5f8
Add filtering options for team macro display based on selected matchups, enhancing user experience and data clarity
Browse files- src/streamlit_app.py +11 -0
src/streamlit_app.py
CHANGED
|
@@ -242,25 +242,36 @@ if selected_tab == 'Team Macro Tables':
|
|
| 242 |
if st.button("Reset Data", key='reset2'):
|
| 243 |
st.cache_data.clear()
|
| 244 |
team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame = init_macro_tables()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
table_var2 = st.selectbox("Select Table", options=['Team Offense', 'Team Defense', 'Team Combo', 'Team Matchups'], key='table_var2')
|
| 246 |
display_type2 = st.selectbox("Select Display Type", options=['Minutes', 'Total'], key='display_type2')
|
| 247 |
with col2:
|
| 248 |
if table_var2 == 'Team Offense':
|
| 249 |
if display_type2 == 'Minutes':
|
| 250 |
team_macro_display = team_off_frame.loc[:, team_off_frame.columns.isin(macro_minutes_cols)]
|
|
|
|
| 251 |
team_macro_display = team_macro_display[['Team', 'Games', 'MIN', 'FGA/m', 'FG3A/m', 'FTA/m', 'PTS/m', 'REB/m', 'AST/m', 'STL/m', 'BLK/m', 'Fantasy/m', 'FD_Fantasy/m']]
|
| 252 |
elif display_type2 == 'Total':
|
| 253 |
team_macro_display = team_off_frame.loc[:, ~team_off_frame.columns.isin(remove_minutes_cols)]
|
|
|
|
| 254 |
elif table_var2 == 'Team Defense':
|
| 255 |
if display_type2 == 'Minutes':
|
| 256 |
team_macro_display = team_def_frame.loc[:, team_def_frame.columns.isin(macro_minutes_cols)]
|
|
|
|
| 257 |
team_macro_display = team_macro_display[['Team', 'Games', 'MIN', 'FGA/m', 'FG3A/m', 'FTA/m', 'PTS/m', 'REB/m', 'AST/m', 'STL/m', 'BLK/m', 'Fantasy/m', 'FD_Fantasy/m']]
|
| 258 |
elif display_type2 == 'Total':
|
| 259 |
team_macro_display = team_def_frame.loc[:, ~team_def_frame.columns.isin(remove_minutes_cols)]
|
|
|
|
| 260 |
elif table_var2 == 'Team Combo':
|
| 261 |
team_macro_display = team_combo_frame
|
|
|
|
| 262 |
elif table_var2 == 'Team Matchups':
|
| 263 |
team_macro_display = team_matchup_frame
|
|
|
|
| 264 |
st.dataframe(team_macro_display.set_index('Team').style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(team_macro_format, precision=2), use_container_width = True)
|
| 265 |
st.download_button(
|
| 266 |
label="Export Table Data",
|
|
|
|
| 242 |
if st.button("Reset Data", key='reset2'):
|
| 243 |
st.cache_data.clear()
|
| 244 |
team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame = init_macro_tables()
|
| 245 |
+
macro_split_var = st.radio("View all teams or just this main slate's matchups?", ('Slate Matchups', 'All'), key='macro_split_var')
|
| 246 |
+
if macro_split_var == 'Slate Matchups':
|
| 247 |
+
macro_view_var = matchups.Opp.values.tolist()
|
| 248 |
+
if macro_split_var == 'All':
|
| 249 |
+
macro_view_var = team_off_frame.Team.values.tolist()
|
| 250 |
table_var2 = st.selectbox("Select Table", options=['Team Offense', 'Team Defense', 'Team Combo', 'Team Matchups'], key='table_var2')
|
| 251 |
display_type2 = st.selectbox("Select Display Type", options=['Minutes', 'Total'], key='display_type2')
|
| 252 |
with col2:
|
| 253 |
if table_var2 == 'Team Offense':
|
| 254 |
if display_type2 == 'Minutes':
|
| 255 |
team_macro_display = team_off_frame.loc[:, team_off_frame.columns.isin(macro_minutes_cols)]
|
| 256 |
+
team_macro_display = team_macro_display[team_macro_display['Team'].isin(macro_view_var)]
|
| 257 |
team_macro_display = team_macro_display[['Team', 'Games', 'MIN', 'FGA/m', 'FG3A/m', 'FTA/m', 'PTS/m', 'REB/m', 'AST/m', 'STL/m', 'BLK/m', 'Fantasy/m', 'FD_Fantasy/m']]
|
| 258 |
elif display_type2 == 'Total':
|
| 259 |
team_macro_display = team_off_frame.loc[:, ~team_off_frame.columns.isin(remove_minutes_cols)]
|
| 260 |
+
team_macro_display = team_macro_display[team_macro_display['Team'].isin(macro_view_var)]
|
| 261 |
elif table_var2 == 'Team Defense':
|
| 262 |
if display_type2 == 'Minutes':
|
| 263 |
team_macro_display = team_def_frame.loc[:, team_def_frame.columns.isin(macro_minutes_cols)]
|
| 264 |
+
team_macro_display = team_macro_display[team_macro_display['Team'].isin(macro_view_var)]
|
| 265 |
team_macro_display = team_macro_display[['Team', 'Games', 'MIN', 'FGA/m', 'FG3A/m', 'FTA/m', 'PTS/m', 'REB/m', 'AST/m', 'STL/m', 'BLK/m', 'Fantasy/m', 'FD_Fantasy/m']]
|
| 266 |
elif display_type2 == 'Total':
|
| 267 |
team_macro_display = team_def_frame.loc[:, ~team_def_frame.columns.isin(remove_minutes_cols)]
|
| 268 |
+
team_macro_display = team_macro_display[team_macro_display['Team'].isin(macro_view_var)]
|
| 269 |
elif table_var2 == 'Team Combo':
|
| 270 |
team_macro_display = team_combo_frame
|
| 271 |
+
team_macro_display = team_macro_display[team_macro_display['Team'].isin(macro_view_var)]
|
| 272 |
elif table_var2 == 'Team Matchups':
|
| 273 |
team_macro_display = team_matchup_frame
|
| 274 |
+
team_macro_display = team_macro_display[team_macro_display['Team'].isin(macro_view_var)]
|
| 275 |
st.dataframe(team_macro_display.set_index('Team').style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(team_macro_format, precision=2), use_container_width = True)
|
| 276 |
st.download_button(
|
| 277 |
label="Export Table Data",
|