Spaces:
Running
Running
James McCool
commited on
Commit
·
d0d2f37
1
Parent(s):
d40862e
Update Streamlit app to filter home run data based on selected teams and positions, enhancing data relevance and user interaction by displaying only the relevant metrics.
Browse files- src/streamlit_app.py +6 -2
src/streamlit_app.py
CHANGED
@@ -38,8 +38,12 @@ with st.container():
|
|
38 |
with col3:
|
39 |
pos_options = st.multiselect("Parse Positions:", options = ['C', '1B', '2B', '3B', 'SS', 'OF'], key = 'pos_options')
|
40 |
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
|
44 |
if disp_options == 'Basics':
|
45 |
st.session_state['disp_frame'] = hr_frame[['Player', 'xHR/PA', 'Opp_xHR/PA', 'BP_Binom_xHR', 'Binom_xHR']]
|
|
|
38 |
with col3:
|
39 |
pos_options = st.multiselect("Parse Positions:", options = ['C', '1B', '2B', '3B', 'SS', 'OF'], key = 'pos_options')
|
40 |
|
41 |
+
if len(team_options) > 0:
|
42 |
+
hr_frame = hr_frame[hr_frame['Team'].isin(team_options)]
|
43 |
+
|
44 |
+
if len(pos_options) > 0:
|
45 |
+
position_mask = hr_frame['Position'].apply(lambda x: any(pos in x for pos in pos_options))
|
46 |
+
hr_frame = hr_frame[position_mask]
|
47 |
|
48 |
if disp_options == 'Basics':
|
49 |
st.session_state['disp_frame'] = hr_frame[['Player', 'xHR/PA', 'Opp_xHR/PA', 'BP_Binom_xHR', 'Binom_xHR']]
|