James McCool
commited on
Commit
·
dee19f8
1
Parent(s):
0b7d1f5
Enhance player selection functionality in app.py for improved filtering
Browse files- Updated player selection logic to utilize unique player names, ensuring that NaN values are excluded from the options presented to users.
- Implemented a new filtering mechanism for player selection, allowing users to filter lineups based on specific players, enhancing the overall user experience.
app.py
CHANGED
@@ -247,24 +247,26 @@ with tab2:
|
|
247 |
stack_size_parse_var = st.selectbox("Do you want to view a specific stack size(s)?", ['All', 'Specific'], key = 'stack_size_parse_var')
|
248 |
stack_size_names = st.multiselect("Select stack sizes", options=working_df['stack_size'].unique(), default=[], key = 'stack_size_names')
|
249 |
with player_var:
|
|
|
|
|
250 |
player_parse_var = st.selectbox("Do you want to view lineups with specific player(s)?", ['All', 'Specific'], key = 'player_parse_var')
|
251 |
-
player_names = st.multiselect("Select players", options=
|
252 |
submitted = st.form_submit_button("Submit")
|
253 |
if submitted:
|
254 |
if 'player_frame' in st.session_state:
|
255 |
del st.session_state['player_frame']
|
256 |
if 'stack_frame' in st.session_state:
|
257 |
del st.session_state['stack_frame']
|
258 |
-
|
259 |
if entry_parse_var == 'Specific' and entry_names:
|
260 |
working_df = working_df[working_df['BaseName'].isin(entry_names)]
|
261 |
if stack_parse_var == 'Specific' and stack_names:
|
262 |
working_df = working_df[working_df['stack'].isin(stack_names)]
|
263 |
if stack_size_parse_var == 'Specific' and stack_size_names:
|
264 |
working_df = working_df[working_df['stack_size'].isin(stack_size_names)]
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
if low_entries_var and high_entries_var:
|
269 |
working_df = working_df[working_df['EntryCount'].between(low_entries_var, high_entries_var)]
|
270 |
|
|
|
247 |
stack_size_parse_var = st.selectbox("Do you want to view a specific stack size(s)?", ['All', 'Specific'], key = 'stack_size_parse_var')
|
248 |
stack_size_names = st.multiselect("Select stack sizes", options=working_df['stack_size'].unique(), default=[], key = 'stack_size_names')
|
249 |
with player_var:
|
250 |
+
unique_players = pd.unique(working_df[player_columns].values.ravel('K'))
|
251 |
+
unique_players = [p for p in unique_players if p != 'nan'] # Remove any NaN values
|
252 |
player_parse_var = st.selectbox("Do you want to view lineups with specific player(s)?", ['All', 'Specific'], key = 'player_parse_var')
|
253 |
+
player_names = st.multiselect("Select players", options=unique_players, default=[], key = 'player_names')
|
254 |
submitted = st.form_submit_button("Submit")
|
255 |
if submitted:
|
256 |
if 'player_frame' in st.session_state:
|
257 |
del st.session_state['player_frame']
|
258 |
if 'stack_frame' in st.session_state:
|
259 |
del st.session_state['stack_frame']
|
260 |
+
|
261 |
if entry_parse_var == 'Specific' and entry_names:
|
262 |
working_df = working_df[working_df['BaseName'].isin(entry_names)]
|
263 |
if stack_parse_var == 'Specific' and stack_names:
|
264 |
working_df = working_df[working_df['stack'].isin(stack_names)]
|
265 |
if stack_size_parse_var == 'Specific' and stack_size_names:
|
266 |
working_df = working_df[working_df['stack_size'].isin(stack_size_names)]
|
267 |
+
if player_parse_var == 'Specific' and player_names:
|
268 |
+
mask = working_df[player_columns].apply(lambda row: any(player in row.values for player in player_names), axis=1)
|
269 |
+
working_df = working_df[mask]
|
270 |
if low_entries_var and high_entries_var:
|
271 |
working_df = working_df[working_df['EntryCount'].between(low_entries_var, high_entries_var)]
|
272 |
|