James McCool
commited on
Commit
·
59693da
1
Parent(s):
447182c
Refactor contest file handling in app.py
Browse files- Updated variable assignments for contest file loading to improve clarity and maintainability.
- Replaced direct references to session state with a local variable for contest data, enhancing code readability and ensuring accurate data processing during name matching operations.
app.py
CHANGED
@@ -35,12 +35,12 @@ with tab1:
|
|
35 |
del st.session_state['Contest']
|
36 |
|
37 |
if Contest_file:
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
if
|
42 |
st.success('Contest file loaded successfully!')
|
43 |
-
st.dataframe(
|
44 |
|
45 |
with col2:
|
46 |
st.subheader("Projections File")
|
@@ -72,14 +72,14 @@ with tab1:
|
|
72 |
st.dataframe(projections.head(10))
|
73 |
|
74 |
if Contest_file and projections_file:
|
75 |
-
if
|
76 |
st.subheader("Name Matching functions")
|
77 |
# Initialize projections_df in session state if it doesn't exist
|
78 |
if 'projections_df' not in st.session_state:
|
79 |
st.session_state['projections_df'] = projections.copy()
|
80 |
st.session_state['projections_df']['salary'] = (st.session_state['projections_df']['salary'].astype(str).str.replace(',', '').astype(float).astype(int))
|
81 |
# Run name matching only once when first loading the files
|
82 |
-
st.session_state['Contest'], st.session_state['projections_df'], st.session_state['ownership_dict'], st.session_state['actual_dict'] = find_name_mismatches(
|
83 |
|
84 |
with tab2:
|
85 |
if 'Contest' in st.session_state and 'projections_df' in st.session_state:
|
|
|
35 |
del st.session_state['Contest']
|
36 |
|
37 |
if Contest_file:
|
38 |
+
contest_base, ownership_df, fpts_df, st.session_state['entry_list'] = load_contest_file(Contest_file, sport_select)
|
39 |
+
contest_base = contest_base.dropna(how='all')
|
40 |
+
contest_base = contest_base.reset_index(drop=True)
|
41 |
+
if contest_base is not None:
|
42 |
st.success('Contest file loaded successfully!')
|
43 |
+
st.dataframe(contest_base.head(10))
|
44 |
|
45 |
with col2:
|
46 |
st.subheader("Projections File")
|
|
|
72 |
st.dataframe(projections.head(10))
|
73 |
|
74 |
if Contest_file and projections_file:
|
75 |
+
if contest_base is not None and projections is not None:
|
76 |
st.subheader("Name Matching functions")
|
77 |
# Initialize projections_df in session state if it doesn't exist
|
78 |
if 'projections_df' not in st.session_state:
|
79 |
st.session_state['projections_df'] = projections.copy()
|
80 |
st.session_state['projections_df']['salary'] = (st.session_state['projections_df']['salary'].astype(str).str.replace(',', '').astype(float).astype(int))
|
81 |
# Run name matching only once when first loading the files
|
82 |
+
st.session_state['Contest'], st.session_state['projections_df'], st.session_state['ownership_dict'], st.session_state['actual_dict'] = find_name_mismatches(contest_base, st.session_state['projections_df'], ownership_df, fpts_df)
|
83 |
|
84 |
with tab2:
|
85 |
if 'Contest' in st.session_state and 'projections_df' in st.session_state:
|