James McCool
commited on
Commit
·
d7f7a9c
1
Parent(s):
ef95156
Refactor name matching logic in app.py to improve conditional checks
Browse files- Updated the condition for loading contest and projection files to ensure both must be present for name matching functions to execute.
- Enhanced clarity and maintainability of the name matching process, ensuring proper data handling and user feedback when managing contest data.
app.py
CHANGED
@@ -114,17 +114,16 @@ with tab1:
|
|
114 |
st.success('Projections file loaded successfully!')
|
115 |
st.dataframe(st.session_state['projections_df'].head(10))
|
116 |
|
117 |
-
if Contest_file
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
st.session_state['actual_dict'] = dict(zip(st.session_state['Adj_actual_df']['Player'], st.session_state['Adj_actual_df']['FPTS']))
|
128 |
|
129 |
|
130 |
with tab2:
|
|
|
114 |
st.success('Projections file loaded successfully!')
|
115 |
st.dataframe(st.session_state['projections_df'].head(10))
|
116 |
|
117 |
+
if Contest_file and projections_file:
|
118 |
+
st.subheader("Name Matching functions")
|
119 |
+
if 'Adj_Contest' not in st.session_state:
|
120 |
+
try:
|
121 |
+
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'])
|
122 |
+
except:
|
123 |
+
st.warning('Please manage name matching to move forward')
|
124 |
+
st.session_state['Adj_projections_df']['salary'] = (st.session_state['Adj_projections_df']['salary'].astype(str).str.replace(',', '').astype(float).astype(int))
|
125 |
+
st.session_state['ownership_dict'] = dict(zip(st.session_state['Adj_ownership_df']['Player'], st.session_state['Adj_ownership_df']['Own']))
|
126 |
+
st.session_state['actual_dict'] = dict(zip(st.session_state['Adj_actual_df']['Player'], st.session_state['Adj_actual_df']['FPTS']))
|
|
|
127 |
|
128 |
|
129 |
with tab2:
|