James McCool
commited on
Commit
·
646dbbe
1
Parent(s):
13857b8
Add team selection functionality in app.py: introduce options to include and remove teams from lineups for enhanced user control over player configurations.
Browse files
app.py
CHANGED
|
@@ -1002,6 +1002,8 @@ with tab2:
|
|
| 1002 |
player_names.update(st.session_state['working_frame'][col].unique())
|
| 1003 |
player_lock = st.multiselect("Lock players?", options=sorted(list(player_names)), default=[])
|
| 1004 |
player_remove = st.multiselect("Remove players?", options=sorted(list(player_names)), default=[])
|
|
|
|
|
|
|
| 1005 |
|
| 1006 |
submitted = st.form_submit_button("Submit")
|
| 1007 |
if submitted:
|
|
@@ -1022,6 +1024,31 @@ with tab2:
|
|
| 1022 |
lambda row: all(player in list(row) for player in player_lock), axis=1
|
| 1023 |
)
|
| 1024 |
parsed_frame = parsed_frame[lock_mask]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1025 |
st.session_state['working_frame'] = parsed_frame.sort_values(by='median', ascending=False)
|
| 1026 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 1027 |
|
|
|
|
| 1002 |
player_names.update(st.session_state['working_frame'][col].unique())
|
| 1003 |
player_lock = st.multiselect("Lock players?", options=sorted(list(player_names)), default=[])
|
| 1004 |
player_remove = st.multiselect("Remove players?", options=sorted(list(player_names)), default=[])
|
| 1005 |
+
team_include = st.multiselect("Include teams?", options=sorted(list(set(st.session_state['working_frame']['team'].unique()))), default=[])
|
| 1006 |
+
team_remove = st.multiselect("Remove teams?", options=sorted(list(set(st.session_state['working_frame']['team'].unique()))), default=[])
|
| 1007 |
|
| 1008 |
submitted = st.form_submit_button("Submit")
|
| 1009 |
if submitted:
|
|
|
|
| 1024 |
lambda row: all(player in list(row) for player in player_lock), axis=1
|
| 1025 |
)
|
| 1026 |
parsed_frame = parsed_frame[lock_mask]
|
| 1027 |
+
|
| 1028 |
+
if team_include:
|
| 1029 |
+
# Create a copy of the frame with player names replaced by teams, excluding SP1 and SP2
|
| 1030 |
+
filtered_player_columns = [col for col in player_columns if col not in ['SP1', 'SP2']]
|
| 1031 |
+
team_frame = parsed_frame[filtered_player_columns].apply(
|
| 1032 |
+
lambda x: x.map(st.session_state['map_dict']['team_map'])
|
| 1033 |
+
)
|
| 1034 |
+
# Create mask for lineups that contain any of the included teams
|
| 1035 |
+
include_mask = team_frame.apply(
|
| 1036 |
+
lambda row: any(team in list(row) for team in team_include), axis=1
|
| 1037 |
+
)
|
| 1038 |
+
parsed_frame = parsed_frame[include_mask]
|
| 1039 |
+
|
| 1040 |
+
if team_remove:
|
| 1041 |
+
# Create a copy of the frame with player names replaced by teams, excluding SP1 and SP2
|
| 1042 |
+
filtered_player_columns = [col for col in player_columns if col not in ['SP1', 'SP2']]
|
| 1043 |
+
team_frame = parsed_frame[filtered_player_columns].apply(
|
| 1044 |
+
lambda x: x.map(st.session_state['map_dict']['team_map'])
|
| 1045 |
+
)
|
| 1046 |
+
# Create mask for lineups that don't contain any of the removed teams
|
| 1047 |
+
remove_mask = team_frame.apply(
|
| 1048 |
+
lambda row: not any(team in list(row) for team in team_remove), axis=1
|
| 1049 |
+
)
|
| 1050 |
+
parsed_frame = parsed_frame[remove_mask]
|
| 1051 |
+
|
| 1052 |
st.session_state['working_frame'] = parsed_frame.sort_values(by='median', ascending=False)
|
| 1053 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 1054 |
|