James McCool
commited on
Commit
·
fc490c5
1
Parent(s):
40fb788
Implement conditional team stacking logic in app.py: add a check to ensure 'Stack' column is created only if it doesn't exist, enhancing the portfolio's team analysis functionality and preventing redundant calculations.
Browse files
app.py
CHANGED
@@ -231,14 +231,16 @@ with tab1:
|
|
231 |
projections['player_names'] = projections['player_names'].map(lambda x: projections_match_dict.get(x, x))
|
232 |
st.session_state['projections_df'] = projections
|
233 |
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
|
|
|
|
242 |
|
243 |
working_frame = st.session_state['portfolio'].copy()
|
244 |
try:
|
|
|
231 |
projections['player_names'] = projections['player_names'].map(lambda x: projections_match_dict.get(x, x))
|
232 |
st.session_state['projections_df'] = projections
|
233 |
|
234 |
+
if 'Stack' not in st.session_state['portfolio'].columns:
|
235 |
+
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
236 |
+
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
237 |
+
lambda row: Counter(
|
238 |
+
team_dict.get(player, '') for player in row[2:]
|
239 |
+
if team_dict.get(player, '') != ''
|
240 |
+
).most_common(1)[0][0] if any(team_dict.get(player, '') for player in row[2:]) else '',
|
241 |
+
axis=1
|
242 |
+
)
|
243 |
+
stack_dict = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Stack']))
|
244 |
|
245 |
working_frame = st.session_state['portfolio'].copy()
|
246 |
try:
|