James McCool
commited on
Commit
·
d92d150
1
Parent(s):
448fa4e
Add new stack exclusions and implement vectorized team calculation in app.py
Browse files- Expanded the list of excluded stacks to include 'P1' and 'P2' for improved data handling.
- Introduced a vectorized function to calculate the most common team from player data, enhancing performance and efficiency in team analysis.
app.py
CHANGED
@@ -199,7 +199,7 @@ with tab1:
|
|
199 |
|
200 |
with tab2:
|
201 |
excluded_cols = ['BaseName', 'EntryCount']
|
202 |
-
exclude_stacks = ['BaseName', 'EntryCount', 'SP', 'SP1', 'SP2']
|
203 |
if 'Contest' in st.session_state and 'display_contest_info' not in st.session_state:
|
204 |
st.session_state['player_columns'] = [col for col in st.session_state['Contest'].columns if col not in excluded_cols]
|
205 |
st.session_state['stack_columns'] = [col for col in st.session_state['Contest'].columns if col not in exclude_stacks]
|
@@ -292,6 +292,16 @@ with tab2:
|
|
292 |
player_teams = working_df.iloc[:, 2:].apply(
|
293 |
lambda x: x.map(team_map).fillna('')
|
294 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
stack_results = player_teams.apply(get_most_common_team, axis=1)
|
297 |
working_df['stack'] = [result[0] for result in stack_results]
|
|
|
199 |
|
200 |
with tab2:
|
201 |
excluded_cols = ['BaseName', 'EntryCount']
|
202 |
+
exclude_stacks = ['BaseName', 'EntryCount', 'SP', 'SP1', 'SP2', 'P1', 'P2']
|
203 |
if 'Contest' in st.session_state and 'display_contest_info' not in st.session_state:
|
204 |
st.session_state['player_columns'] = [col for col in st.session_state['Contest'].columns if col not in excluded_cols]
|
205 |
st.session_state['stack_columns'] = [col for col in st.session_state['Contest'].columns if col not in exclude_stacks]
|
|
|
292 |
player_teams = working_df.iloc[:, 2:].apply(
|
293 |
lambda x: x.map(team_map).fillna('')
|
294 |
)
|
295 |
+
|
296 |
+
# Vectorized stack and stack_size calculation
|
297 |
+
def get_most_common_team(teams):
|
298 |
+
if teams.empty or teams.isna().all():
|
299 |
+
return '', 0
|
300 |
+
non_empty_teams = teams[teams != '']
|
301 |
+
if len(non_empty_teams) == 0:
|
302 |
+
return '', 0
|
303 |
+
team_counts = non_empty_teams.value_counts()
|
304 |
+
return team_counts.index[0], team_counts.iloc[0]
|
305 |
|
306 |
stack_results = player_teams.apply(get_most_common_team, axis=1)
|
307 |
working_df['stack'] = [result[0] for result in stack_results]
|