James McCool
commited on
Commit
·
911d70e
1
Parent(s):
546a43f
Add size selection functionality in app.py: introduce options to include player sizes in lineups, enhancing user control over player configurations and improving data representation.
Browse files
app.py
CHANGED
|
@@ -272,7 +272,15 @@ with tab1:
|
|
| 272 |
).most_common(1)[0][0] if any(team_dict.get(player, '') for player in row[2:]) else '',
|
| 273 |
axis=1
|
| 274 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
stack_dict = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Stack']))
|
|
|
|
| 276 |
|
| 277 |
working_frame = st.session_state['portfolio'].copy()
|
| 278 |
try:
|
|
@@ -909,6 +917,7 @@ with tab2:
|
|
| 909 |
st.session_state['working_frame']['Own'] = st.session_state['working_frame'].apply(lambda row: sum(st.session_state['map_dict']['own_map'].get(player, 0) for player in row), axis=1)
|
| 910 |
if stack_dict is not None:
|
| 911 |
st.session_state['working_frame']['Stack'] = st.session_state['working_frame'].index.map(stack_dict)
|
|
|
|
| 912 |
elif type_var == 'Showdown':
|
| 913 |
# Calculate salary (CPT uses cpt_salary_map, others use salary_map)
|
| 914 |
st.session_state['working_frame']['salary'] = st.session_state['working_frame'].apply(
|
|
@@ -1004,6 +1013,7 @@ with tab2:
|
|
| 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['projections_df']['team'].unique()))), default=[])
|
| 1006 |
team_remove = st.multiselect("Remove teams?", options=sorted(list(set(st.session_state['projections_df']['team'].unique()))), default=[])
|
|
|
|
| 1007 |
|
| 1008 |
submitted = st.form_submit_button("Submit")
|
| 1009 |
if submitted:
|
|
@@ -1048,6 +1058,9 @@ with tab2:
|
|
| 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()
|
|
|
|
| 272 |
).most_common(1)[0][0] if any(team_dict.get(player, '') for player in row[2:]) else '',
|
| 273 |
axis=1
|
| 274 |
)
|
| 275 |
+
st.session_state['portfolio']['Size'] = st.session_state['portfolio'].apply(
|
| 276 |
+
lambda row: Counter(
|
| 277 |
+
team_dict.get(player, '') for player in row[2:]
|
| 278 |
+
if team_dict.get(player, '') != ''
|
| 279 |
+
).most_common(1)[0][1] if any(team_dict.get(player, '') for player in row[2:]) else 0,
|
| 280 |
+
axis=1
|
| 281 |
+
)
|
| 282 |
stack_dict = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Stack']))
|
| 283 |
+
size_dict = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Size']))
|
| 284 |
|
| 285 |
working_frame = st.session_state['portfolio'].copy()
|
| 286 |
try:
|
|
|
|
| 917 |
st.session_state['working_frame']['Own'] = st.session_state['working_frame'].apply(lambda row: sum(st.session_state['map_dict']['own_map'].get(player, 0) for player in row), axis=1)
|
| 918 |
if stack_dict is not None:
|
| 919 |
st.session_state['working_frame']['Stack'] = st.session_state['working_frame'].index.map(stack_dict)
|
| 920 |
+
st.session_state['working_frame']['Size'] = st.session_state['working_frame'].index.map(size_dict)
|
| 921 |
elif type_var == 'Showdown':
|
| 922 |
# Calculate salary (CPT uses cpt_salary_map, others use salary_map)
|
| 923 |
st.session_state['working_frame']['salary'] = st.session_state['working_frame'].apply(
|
|
|
|
| 1013 |
player_remove = st.multiselect("Remove players?", options=sorted(list(player_names)), default=[])
|
| 1014 |
team_include = st.multiselect("Include teams?", options=sorted(list(set(st.session_state['projections_df']['team'].unique()))), default=[])
|
| 1015 |
team_remove = st.multiselect("Remove teams?", options=sorted(list(set(st.session_state['projections_df']['team'].unique()))), default=[])
|
| 1016 |
+
size_include = st.multiselect("Include sizes?", options=sorted(list(set(st.session_state['working_frame']['Size'].unique()))), default=[])
|
| 1017 |
|
| 1018 |
submitted = st.form_submit_button("Submit")
|
| 1019 |
if submitted:
|
|
|
|
| 1058 |
lambda row: not any(team in list(row) for team in team_remove), axis=1
|
| 1059 |
)
|
| 1060 |
parsed_frame = parsed_frame[remove_mask]
|
| 1061 |
+
|
| 1062 |
+
if size_include:
|
| 1063 |
+
parsed_frame = parsed_frame[parsed_frame['Size'].isin(size_include)]
|
| 1064 |
|
| 1065 |
st.session_state['working_frame'] = parsed_frame.sort_values(by='median', ascending=False)
|
| 1066 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|