James McCool
commited on
Commit
·
7557e1a
1
Parent(s):
0d1ebff
Refactor player and stack column handling in app.py to accommodate combined dataframe
Browse files- Updated logic to determine player and stack columns based on the presence of 'portfolio_df' in session state, enhancing data processing flexibility.
- Ensured vectorized string operations are applied to the correct dataframe, improving data integrity and user experience.
app.py
CHANGED
|
@@ -230,13 +230,20 @@ with tab2:
|
|
| 230 |
excluded_cols = ['BaseName', 'EntryCount']
|
| 231 |
exclude_stacks = ['BaseName', 'EntryCount', 'SP', 'SP1', 'SP2', 'P1', 'P2']
|
| 232 |
if 'Contest' in st.session_state and 'display_contest_info' not in st.session_state:
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
print(st.session_state['player_columns'])
|
| 236 |
|
| 237 |
# Vectorized string operations
|
| 238 |
for col in st.session_state['player_columns']:
|
| 239 |
-
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
# Create mapping dictionaries
|
| 242 |
st.session_state['map_dict'] = {
|
|
|
|
| 230 |
excluded_cols = ['BaseName', 'EntryCount']
|
| 231 |
exclude_stacks = ['BaseName', 'EntryCount', 'SP', 'SP1', 'SP2', 'P1', 'P2']
|
| 232 |
if 'Contest' in st.session_state and 'display_contest_info' not in st.session_state:
|
| 233 |
+
if 'portfolio_df' in st.session_state:
|
| 234 |
+
st.session_state['player_columns'] = [col for col in st.session_state['combined_df'].columns if col not in excluded_cols]
|
| 235 |
+
st.session_state['stack_columns'] = [col for col in st.session_state['combined_df'].columns if col not in exclude_stacks]
|
| 236 |
+
else:
|
| 237 |
+
st.session_state['player_columns'] = [col for col in st.session_state['Contest'].columns if col not in excluded_cols]
|
| 238 |
+
st.session_state['stack_columns'] = [col for col in st.session_state['Contest'].columns if col not in exclude_stacks]
|
| 239 |
print(st.session_state['player_columns'])
|
| 240 |
|
| 241 |
# Vectorized string operations
|
| 242 |
for col in st.session_state['player_columns']:
|
| 243 |
+
if 'portfolio_df' in st.session_state:
|
| 244 |
+
st.session_state['combined_df'][col] = st.session_state['combined_df'][col].astype(str).str.strip()
|
| 245 |
+
else:
|
| 246 |
+
st.session_state['Contest'][col] = st.session_state['Contest'][col].astype(str).str.strip()
|
| 247 |
|
| 248 |
# Create mapping dictionaries
|
| 249 |
st.session_state['map_dict'] = {
|