James McCool
commited on
Commit
·
95c7789
1
Parent(s):
4448bfb
Refactor lineup filtering logic in app.py to improve clarity and maintainability. Updated variable names for multiselect options to enhance user understanding when managing player and stack filters, ensuring a more intuitive experience.
Browse files
app.py
CHANGED
|
@@ -1304,14 +1304,10 @@ with tab2:
|
|
| 1304 |
player_names.update(st.session_state['working_frame'][col].unique())
|
| 1305 |
conditional_var_1 = st.selectbox("Remove variable: ", options=['Players', 'Stacks'], key='conditional_var_1')
|
| 1306 |
conditional_var_2 = st.selectbox("Contains variable: ", options=['Players', 'Stacks'], key='conditional_var_2')
|
| 1307 |
-
|
| 1308 |
-
|
| 1309 |
-
|
| 1310 |
-
|
| 1311 |
-
if st.session_state['conditional_var_2'] == 'Players':
|
| 1312 |
-
conditional_include = st.multiselect("If Contains variable is Players, where lineups contain players:", options=sorted(list(player_names)), default=[])
|
| 1313 |
-
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1314 |
-
conditional_include = st.multiselect("If Contains variable is Stacks, where lineups contain stacks:", options=sorted(list(set(st.session_state['stack_dict'].values()))), default=[])
|
| 1315 |
|
| 1316 |
submitted_col, export_col = st.columns(2)
|
| 1317 |
st.info("Portfolio Button applies to your overall Portfolio, Export button applies to your Custom Export")
|
|
@@ -1324,14 +1320,14 @@ with tab2:
|
|
| 1324 |
parsed_frame = st.session_state['working_frame'].copy()
|
| 1325 |
if st.session_state['conditional_var_1'] == 'Players':
|
| 1326 |
if st.session_state['conditional_var_2'] == 'Players':
|
| 1327 |
-
parsed_frame = parsed_frame[~parsed_frame['player_names'].isin(
|
| 1328 |
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1329 |
-
parsed_frame = parsed_frame[~parsed_frame['Stack'].isin(
|
| 1330 |
elif st.session_state['conditional_var_1'] == 'Stacks':
|
| 1331 |
if st.session_state['conditional_var_2'] == 'Players':
|
| 1332 |
-
parsed_frame = parsed_frame[parsed_frame['player_names'].isin(
|
| 1333 |
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1334 |
-
parsed_frame = parsed_frame[parsed_frame['Stack'].isin(
|
| 1335 |
st.session_state['working_frame'] = parsed_frame.sort_values(by='median', ascending=False).reset_index(drop=True)
|
| 1336 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 1337 |
elif exp_submitted:
|
|
@@ -1339,14 +1335,14 @@ with tab2:
|
|
| 1339 |
parsed_frame = st.session_state['export_base'].copy()
|
| 1340 |
if st.session_state['conditional_var_1'] == 'Players':
|
| 1341 |
if st.session_state['conditional_var_2'] == 'Players':
|
| 1342 |
-
parsed_frame = parsed_frame[~parsed_frame['player_names'].isin(
|
| 1343 |
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1344 |
-
parsed_frame = parsed_frame[~parsed_frame['Stack'].isin(
|
| 1345 |
elif st.session_state['conditional_var_1'] == 'Stacks':
|
| 1346 |
if st.session_state['conditional_var_2'] == 'Players':
|
| 1347 |
-
parsed_frame = parsed_frame[parsed_frame['player_names'].isin(
|
| 1348 |
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1349 |
-
parsed_frame = parsed_frame[parsed_frame['Stack'].isin(
|
| 1350 |
st.session_state['export_base'] = parsed_frame.sort_values(by='median', ascending=False).reset_index(drop=True)
|
| 1351 |
st.session_state['export_merge'] = st.session_state['export_base'].copy()
|
| 1352 |
|
|
|
|
| 1304 |
player_names.update(st.session_state['working_frame'][col].unique())
|
| 1305 |
conditional_var_1 = st.selectbox("Remove variable: ", options=['Players', 'Stacks'], key='conditional_var_1')
|
| 1306 |
conditional_var_2 = st.selectbox("Contains variable: ", options=['Players', 'Stacks'], key='conditional_var_2')
|
| 1307 |
+
conditional_remove_players = st.multiselect("If Remove variable is Players, remove lineups containing players:", options=sorted(list(player_names)), default=[])
|
| 1308 |
+
conditional_remove_stacks = st.multiselect("If Remove variable is Stacks, remove lineups containing stacks:", options=sorted(list(set(st.session_state['stack_dict'].values()))), default=[])
|
| 1309 |
+
conditional_include_players = st.multiselect("If Contains variable is Players, where lineups contain players:", options=sorted(list(player_names)), default=[])
|
| 1310 |
+
conditional_include_stacks = st.multiselect("If Contains variable is Stacks, where lineups contain stacks:", options=sorted(list(set(st.session_state['stack_dict'].values()))), default=[])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1311 |
|
| 1312 |
submitted_col, export_col = st.columns(2)
|
| 1313 |
st.info("Portfolio Button applies to your overall Portfolio, Export button applies to your Custom Export")
|
|
|
|
| 1320 |
parsed_frame = st.session_state['working_frame'].copy()
|
| 1321 |
if st.session_state['conditional_var_1'] == 'Players':
|
| 1322 |
if st.session_state['conditional_var_2'] == 'Players':
|
| 1323 |
+
parsed_frame = parsed_frame[~parsed_frame['player_names'].isin(conditional_remove_players)] & parsed_frame[parsed_frame['player_names'].isin(conditional_include_players)]
|
| 1324 |
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1325 |
+
parsed_frame = parsed_frame[~parsed_frame['Stack'].isin(conditional_remove_stacks)] & parsed_frame[parsed_frame['Stack'].isin(conditional_include_stacks)]
|
| 1326 |
elif st.session_state['conditional_var_1'] == 'Stacks':
|
| 1327 |
if st.session_state['conditional_var_2'] == 'Players':
|
| 1328 |
+
parsed_frame = parsed_frame[parsed_frame['player_names'].isin(conditional_include_players)] & parsed_frame[~parsed_frame['player_names'].isin(conditional_remove_players)]
|
| 1329 |
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1330 |
+
parsed_frame = parsed_frame[parsed_frame['Stack'].isin(conditional_include_stacks)] & parsed_frame[~parsed_frame['Stack'].isin(conditional_remove_stacks)]
|
| 1331 |
st.session_state['working_frame'] = parsed_frame.sort_values(by='median', ascending=False).reset_index(drop=True)
|
| 1332 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 1333 |
elif exp_submitted:
|
|
|
|
| 1335 |
parsed_frame = st.session_state['export_base'].copy()
|
| 1336 |
if st.session_state['conditional_var_1'] == 'Players':
|
| 1337 |
if st.session_state['conditional_var_2'] == 'Players':
|
| 1338 |
+
parsed_frame = parsed_frame[~parsed_frame['player_names'].isin(conditional_remove_players)] & parsed_frame[parsed_frame['player_names'].isin(conditional_include_players)]
|
| 1339 |
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1340 |
+
parsed_frame = parsed_frame[~parsed_frame['Stack'].isin(conditional_remove_stacks)] & parsed_frame[parsed_frame['Stack'].isin(conditional_include_stacks)]
|
| 1341 |
elif st.session_state['conditional_var_1'] == 'Stacks':
|
| 1342 |
if st.session_state['conditional_var_2'] == 'Players':
|
| 1343 |
+
parsed_frame = parsed_frame[parsed_frame['player_names'].isin(conditional_include_players)] & parsed_frame[~parsed_frame['player_names'].isin(conditional_remove_players)]
|
| 1344 |
elif st.session_state['conditional_var_2'] == 'Stacks':
|
| 1345 |
+
parsed_frame = parsed_frame[parsed_frame['Stack'].isin(conditional_include_stacks)] & parsed_frame[~parsed_frame['Stack'].isin(conditional_remove_stacks)]
|
| 1346 |
st.session_state['export_base'] = parsed_frame.sort_values(by='median', ascending=False).reset_index(drop=True)
|
| 1347 |
st.session_state['export_merge'] = st.session_state['export_base'].copy()
|
| 1348 |
|