James McCool
commited on
Commit
·
1599cba
1
Parent(s):
fd1c071
Enhance player selection and removal functionality in app.py
Browse files- Added a new option to remove specific players from the contest information, improving user control over displayed data.
- Updated the filtering form to include a new column for player removal, enhancing the user interface and experience.
- Ensured that the application correctly updates the displayed contest information based on user selections for both viewing and removing players.
app.py
CHANGED
@@ -260,6 +260,8 @@ with tab2:
|
|
260 |
st.session_state['field_player_frame'] = create_player_exposures(working_df, st.session_state['player_columns'])
|
261 |
st.session_state['field_stack_frame'] = create_stack_exposures(working_df)
|
262 |
st.session_state['display_contest_info'] = working_df.copy()
|
|
|
|
|
263 |
|
264 |
if 'display_contest_info' in st.session_state:
|
265 |
with st.expander("Info and filters"):
|
@@ -268,7 +270,7 @@ with tab2:
|
|
268 |
st.session_state.clear()
|
269 |
|
270 |
with st.form(key='filter_form'):
|
271 |
-
users_var, entries_var, stack_var, stack_size_var, player_var = st.columns(
|
272 |
with users_var:
|
273 |
st.session_state['entry_parse_var'] = st.selectbox("Do you want to view a specific user(s)?", ['All', 'Specific'])
|
274 |
st.session_state['entry_names'] = st.multiselect("Select players", options=st.session_state['entry_list'], default=[])
|
@@ -282,10 +284,11 @@ with tab2:
|
|
282 |
st.session_state['stack_size_parse_var'] = st.selectbox("Do you want to view a specific stack size(s)?", ['All', 'Specific'])
|
283 |
st.session_state['stack_size_names'] = st.multiselect("Select stack sizes", options=st.session_state['display_contest_info']['stack_size'].unique(), default=[])
|
284 |
with player_var:
|
285 |
-
st.session_state['unique_players'] = pd.unique(st.session_state['display_contest_info'][st.session_state['player_columns']].values.ravel('K'))
|
286 |
-
st.session_state['unique_players'] = [p for p in st.session_state['unique_players'] if p != 'nan'] # Remove any NaN values
|
287 |
st.session_state['player_parse_var'] = st.selectbox("Do you want to view lineups with specific player(s)?", ['All', 'Specific'])
|
288 |
st.session_state['player_names'] = st.multiselect("Select players", options=st.session_state['unique_players'], default=[])
|
|
|
|
|
|
|
289 |
submitted = st.form_submit_button("Submit")
|
290 |
if submitted:
|
291 |
if 'player_frame' in st.session_state:
|
@@ -302,6 +305,8 @@ with tab2:
|
|
302 |
if st.session_state['player_parse_var'] == 'Specific' and st.session_state['player_names']:
|
303 |
mask = st.session_state['display_contest_info'][st.session_state['player_columns']].apply(lambda row: all(player in row.values for player in st.session_state['player_names']), axis=1)
|
304 |
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][mask]
|
|
|
|
|
305 |
if st.session_state['low_entries_var'] and st.session_state['high_entries_var']:
|
306 |
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][st.session_state['display_contest_info']['EntryCount'].between(st.session_state['low_entries_var'], st.session_state['high_entries_var'])]
|
307 |
|
|
|
260 |
st.session_state['field_player_frame'] = create_player_exposures(working_df, st.session_state['player_columns'])
|
261 |
st.session_state['field_stack_frame'] = create_stack_exposures(working_df)
|
262 |
st.session_state['display_contest_info'] = working_df.copy()
|
263 |
+
st.session_state['unique_players'] = pd.unique(st.session_state['display_contest_info'][st.session_state['player_columns']].values.ravel('K'))
|
264 |
+
st.session_state['unique_players'] = [p for p in st.session_state['unique_players'] if p != 'nan'] # Remove any NaN values
|
265 |
|
266 |
if 'display_contest_info' in st.session_state:
|
267 |
with st.expander("Info and filters"):
|
|
|
270 |
st.session_state.clear()
|
271 |
|
272 |
with st.form(key='filter_form'):
|
273 |
+
users_var, entries_var, stack_var, stack_size_var, player_var, remove_var = st.columns(6)
|
274 |
with users_var:
|
275 |
st.session_state['entry_parse_var'] = st.selectbox("Do you want to view a specific user(s)?", ['All', 'Specific'])
|
276 |
st.session_state['entry_names'] = st.multiselect("Select players", options=st.session_state['entry_list'], default=[])
|
|
|
284 |
st.session_state['stack_size_parse_var'] = st.selectbox("Do you want to view a specific stack size(s)?", ['All', 'Specific'])
|
285 |
st.session_state['stack_size_names'] = st.multiselect("Select stack sizes", options=st.session_state['display_contest_info']['stack_size'].unique(), default=[])
|
286 |
with player_var:
|
|
|
|
|
287 |
st.session_state['player_parse_var'] = st.selectbox("Do you want to view lineups with specific player(s)?", ['All', 'Specific'])
|
288 |
st.session_state['player_names'] = st.multiselect("Select players", options=st.session_state['unique_players'], default=[])
|
289 |
+
with remove_var:
|
290 |
+
st.session_state['remove_var'] = st.selectbox("Do you want to remove a specific player(s)?", ['No', 'Yes'])
|
291 |
+
st.session_state['remove_names'] = st.multiselect("Select players", options=st.session_state['unique_players'], default=[])
|
292 |
submitted = st.form_submit_button("Submit")
|
293 |
if submitted:
|
294 |
if 'player_frame' in st.session_state:
|
|
|
305 |
if st.session_state['player_parse_var'] == 'Specific' and st.session_state['player_names']:
|
306 |
mask = st.session_state['display_contest_info'][st.session_state['player_columns']].apply(lambda row: all(player in row.values for player in st.session_state['player_names']), axis=1)
|
307 |
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][mask]
|
308 |
+
if st.session_state['remove_var'] == 'Yes' and st.session_state['remove_names']:
|
309 |
+
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][~st.session_state['display_contest_info']['BaseName'].isin(st.session_state['remove_names'])]
|
310 |
if st.session_state['low_entries_var'] and st.session_state['high_entries_var']:
|
311 |
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][st.session_state['display_contest_info']['EntryCount'].between(st.session_state['low_entries_var'], st.session_state['high_entries_var'])]
|
312 |
|