James McCool
commited on
Commit
·
2e01205
1
Parent(s):
54d06a1
Update app.py to handle portfolio dataframe more effectively and streamline data display
Browse files- Modified error handling to set 'portfolio_df' to None when an exception occurs, improving data integrity.
- Removed unnecessary display of 'check_working_df' to enhance user interface clarity.
- These changes aim to improve data management and user experience by ensuring only relevant information is presented.
app.py
CHANGED
|
@@ -186,7 +186,7 @@ with tab1:
|
|
| 186 |
|
| 187 |
st.session_state['portfolio_df'] = st.session_state['portfolio_df'][['BaseName', 'EntryCount'] + original_columns]
|
| 188 |
except:
|
| 189 |
-
|
| 190 |
|
| 191 |
|
| 192 |
if 'Contest_file' in st.session_state:
|
|
@@ -212,7 +212,6 @@ with tab1:
|
|
| 212 |
if 'portfolio_df' in st.session_state:
|
| 213 |
st.write('Portfolio data:')
|
| 214 |
st.dataframe(st.session_state['portfolio_df'].head(25))
|
| 215 |
-
st.table(st.session_state['Contest'])
|
| 216 |
else:
|
| 217 |
pass
|
| 218 |
|
|
@@ -312,7 +311,6 @@ with tab2:
|
|
| 312 |
working_df['percentile_finish'] = working_df['index'].rank(pct=True)
|
| 313 |
working_df['finish'] = working_df['index']
|
| 314 |
working_df = working_df.drop(['sorted', 'index'], axis=1)
|
| 315 |
-
st.session_state['check_working_df'] = working_df
|
| 316 |
|
| 317 |
elif type_var == 'Showdown':
|
| 318 |
# Vectorized stack calculation for Showdown
|
|
@@ -386,7 +384,6 @@ with tab2:
|
|
| 386 |
working_df['percentile_finish'] = working_df['index'].rank(pct=True)
|
| 387 |
working_df['finish'] = working_df['index']
|
| 388 |
working_df = working_df.drop(['sorted', 'index'], axis=1)
|
| 389 |
-
st.session_state['check_working_df'] = working_df
|
| 390 |
|
| 391 |
# Store results
|
| 392 |
st.session_state['field_player_frame'] = create_player_exposures(working_df, st.session_state['player_columns'])
|
|
@@ -462,7 +459,7 @@ with tab2:
|
|
| 462 |
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][~mask]
|
| 463 |
if st.session_state['low_entries_var'] and st.session_state['high_entries_var']:
|
| 464 |
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][st.session_state['display_contest_info']['EntryCount'].between(st.session_state['low_entries_var'], st.session_state['high_entries_var'])]
|
| 465 |
-
|
| 466 |
if 'display_contest_info' in st.session_state:
|
| 467 |
# Initialize pagination in session state if not exists
|
| 468 |
if 'current_page' not in st.session_state:
|
|
|
|
| 186 |
|
| 187 |
st.session_state['portfolio_df'] = st.session_state['portfolio_df'][['BaseName', 'EntryCount'] + original_columns]
|
| 188 |
except:
|
| 189 |
+
st.session_state['portfolio_df'] = None
|
| 190 |
|
| 191 |
|
| 192 |
if 'Contest_file' in st.session_state:
|
|
|
|
| 212 |
if 'portfolio_df' in st.session_state:
|
| 213 |
st.write('Portfolio data:')
|
| 214 |
st.dataframe(st.session_state['portfolio_df'].head(25))
|
|
|
|
| 215 |
else:
|
| 216 |
pass
|
| 217 |
|
|
|
|
| 311 |
working_df['percentile_finish'] = working_df['index'].rank(pct=True)
|
| 312 |
working_df['finish'] = working_df['index']
|
| 313 |
working_df = working_df.drop(['sorted', 'index'], axis=1)
|
|
|
|
| 314 |
|
| 315 |
elif type_var == 'Showdown':
|
| 316 |
# Vectorized stack calculation for Showdown
|
|
|
|
| 384 |
working_df['percentile_finish'] = working_df['index'].rank(pct=True)
|
| 385 |
working_df['finish'] = working_df['index']
|
| 386 |
working_df = working_df.drop(['sorted', 'index'], axis=1)
|
|
|
|
| 387 |
|
| 388 |
# Store results
|
| 389 |
st.session_state['field_player_frame'] = create_player_exposures(working_df, st.session_state['player_columns'])
|
|
|
|
| 459 |
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][~mask]
|
| 460 |
if st.session_state['low_entries_var'] and st.session_state['high_entries_var']:
|
| 461 |
st.session_state['display_contest_info'] = st.session_state['display_contest_info'][st.session_state['display_contest_info']['EntryCount'].between(st.session_state['low_entries_var'], st.session_state['high_entries_var'])]
|
| 462 |
+
|
| 463 |
if 'display_contest_info' in st.session_state:
|
| 464 |
# Initialize pagination in session state if not exists
|
| 465 |
if 'current_page' not in st.session_state:
|