James McCool
commited on
Commit
·
0e549ce
1
Parent(s):
591ec4f
Update stack column handling in app.py
Browse files- Introduced a new list of excluded stack columns to enhance data processing for contest entries.
- Updated the logic for determining the 'stack' and 'stack_size' in the working DataFrame to utilize the new stack columns, improving accuracy in data representation.
app.py
CHANGED
|
@@ -197,8 +197,10 @@ with tab1:
|
|
| 197 |
|
| 198 |
with tab2:
|
| 199 |
excluded_cols = ['BaseName', 'EntryCount']
|
|
|
|
| 200 |
if 'Contest' in st.session_state and 'display_contest_info' not in st.session_state:
|
| 201 |
st.session_state['player_columns'] = [col for col in st.session_state['Contest'].columns if col not in excluded_cols]
|
|
|
|
| 202 |
print(st.session_state['player_columns'])
|
| 203 |
for col in st.session_state['player_columns']:
|
| 204 |
st.session_state['Contest'][col] = st.session_state['Contest'][col].astype(str).str.strip()
|
|
@@ -217,16 +219,16 @@ with tab2:
|
|
| 217 |
if type_var == 'Classic':
|
| 218 |
working_df['stack'] = working_df.apply(
|
| 219 |
lambda row: Counter(
|
| 220 |
-
st.session_state['map_dict']['team_map'].get(player, '') for player in row[st.session_state['
|
| 221 |
if st.session_state['map_dict']['team_map'].get(player, '') != ''
|
| 222 |
-
).most_common(1)[0][0] if any(st.session_state['map_dict']['team_map'].get(player, '') for player in row[st.session_state['
|
| 223 |
axis=1
|
| 224 |
)
|
| 225 |
working_df['stack_size'] = working_df.apply(
|
| 226 |
lambda row: Counter(
|
| 227 |
-
st.session_state['map_dict']['team_map'].get(player, '') for player in row[st.session_state['
|
| 228 |
if st.session_state['map_dict']['team_map'].get(player, '') != ''
|
| 229 |
-
).most_common(1)[0][1] if any(st.session_state['map_dict']['team_map'].get(player, '') for player in row[st.session_state['
|
| 230 |
axis=1
|
| 231 |
)
|
| 232 |
working_df['salary'] = working_df.apply(lambda row: sum(st.session_state['salary_dict'].get(player, 0) for player in row[st.session_state['player_columns']]), axis=1)
|
|
|
|
| 197 |
|
| 198 |
with tab2:
|
| 199 |
excluded_cols = ['BaseName', 'EntryCount']
|
| 200 |
+
exclude_stacks = ['BaseName', 'EntryCount', 'SP', 'SP1', 'SP2']
|
| 201 |
if 'Contest' in st.session_state and 'display_contest_info' not in st.session_state:
|
| 202 |
st.session_state['player_columns'] = [col for col in st.session_state['Contest'].columns if col not in excluded_cols]
|
| 203 |
+
st.session_state['stack_columns'] = [col for col in st.session_state['Contest'].columns if col not in exclude_stacks]
|
| 204 |
print(st.session_state['player_columns'])
|
| 205 |
for col in st.session_state['player_columns']:
|
| 206 |
st.session_state['Contest'][col] = st.session_state['Contest'][col].astype(str).str.strip()
|
|
|
|
| 219 |
if type_var == 'Classic':
|
| 220 |
working_df['stack'] = working_df.apply(
|
| 221 |
lambda row: Counter(
|
| 222 |
+
st.session_state['map_dict']['team_map'].get(player, '') for player in row[st.session_state['stack_columns']]
|
| 223 |
if st.session_state['map_dict']['team_map'].get(player, '') != ''
|
| 224 |
+
).most_common(1)[0][0] if any(st.session_state['map_dict']['team_map'].get(player, '') for player in row[st.session_state['stack_columns']]) else '',
|
| 225 |
axis=1
|
| 226 |
)
|
| 227 |
working_df['stack_size'] = working_df.apply(
|
| 228 |
lambda row: Counter(
|
| 229 |
+
st.session_state['map_dict']['team_map'].get(player, '') for player in row[st.session_state['stack_columns']]
|
| 230 |
if st.session_state['map_dict']['team_map'].get(player, '') != ''
|
| 231 |
+
).most_common(1)[0][1] if any(st.session_state['map_dict']['team_map'].get(player, '') for player in row[st.session_state['stack_columns']]) else '',
|
| 232 |
axis=1
|
| 233 |
)
|
| 234 |
working_df['salary'] = working_df.apply(lambda row: sum(st.session_state['salary_dict'].get(player, 0) for player in row[st.session_state['player_columns']]), axis=1)
|