James McCool
commited on
Commit
·
e31f6cd
1
Parent(s):
6e8cffc
Implement error handling for name matching in app.py
Browse files- Added a try-except block around the name matching function to handle potential errors gracefully.
- Display a warning message to the user if name matching cannot be completed, improving user experience and guiding next steps.
- Ensured that session state variables for adjusted dataframes are only set when name matching is successful, maintaining data integrity.
app.py
CHANGED
@@ -75,7 +75,10 @@ with tab1:
|
|
75 |
if Contest_file and projections_file:
|
76 |
st.subheader("Name Matching functions")
|
77 |
if 'Adj_Contest' not in st.session_state:
|
78 |
-
|
|
|
|
|
|
|
79 |
st.session_state['Adj_projections_df']['salary'] = (st.session_state['Adj_projections_df']['salary'].astype(str).str.replace(',', '').astype(float).astype(int))
|
80 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['Adj_ownership_df']['Player'], st.session_state['Adj_ownership_df']['Own']))
|
81 |
st.session_state['actual_dict'] = dict(zip(st.session_state['Adj_actual_df']['Player'], st.session_state['Adj_actual_df']['FPTS']))
|
|
|
75 |
if Contest_file and projections_file:
|
76 |
st.subheader("Name Matching functions")
|
77 |
if 'Adj_Contest' not in st.session_state:
|
78 |
+
try:
|
79 |
+
st.session_state['Adj_Contest'], st.session_state['Adj_projections_df'], st.session_state['Adj_ownership_df'], st.session_state['Adj_actual_df'] = find_name_mismatches(st.session_state['Contest'], st.session_state['projections_df'], st.session_state['ownership_df'], st.session_state['actual_df'])
|
80 |
+
except:
|
81 |
+
st.warning('Please manage name matching to move forward')
|
82 |
st.session_state['Adj_projections_df']['salary'] = (st.session_state['Adj_projections_df']['salary'].astype(str).str.replace(',', '').astype(float).astype(int))
|
83 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['Adj_ownership_df']['Player'], st.session_state['Adj_ownership_df']['Own']))
|
84 |
st.session_state['actual_dict'] = dict(zip(st.session_state['Adj_actual_df']['Player'], st.session_state['Adj_actual_df']['FPTS']))
|