James McCool
commited on
Commit
·
68d3916
1
Parent(s):
6a12985
Refactor app.py and find_name_mismatches.py for improved user feedback and session state management
Browse files- Adjusted app.py to enhance the layout and flow of the name matching process, ensuring better user experience with tabbed navigation.
- Updated find_name_mismatches.py to provide clearer feedback when no changes are applied, improving user awareness of the matching process.
- Streamlined session state checks to ensure consistent execution of name matching functions, enhancing overall functionality.
- app.py +4 -4
- global_func/find_name_mismatches.py +5 -3
app.py
CHANGED
|
@@ -72,9 +72,7 @@ with tab1:
|
|
| 72 |
if st.session_state['projections_df'] is not None:
|
| 73 |
st.success('Projections file loaded successfully!')
|
| 74 |
st.dataframe(st.session_state['projections_df'].head(10))
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
with tab2:
|
| 78 |
if Contest_file and projections_file:
|
| 79 |
st.subheader("Name Matching functions")
|
| 80 |
st.session_state['Contest'], st.session_state['projections_df'], st.session_state['ownership_dict'], st.session_state['actual_dict'], st.session_state['calc_toggle'] = find_name_mismatches(st.session_state['Contest'], st.session_state['projections_df'], st.session_state['ownership_dict'], st.session_state['actual_dict'], st.session_state['calc_toggle'])
|
|
@@ -82,7 +80,9 @@ with tab2:
|
|
| 82 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['ownership_dict']['Player'], st.session_state['ownership_dict']['Own']))
|
| 83 |
st.session_state['actual_dict'] = dict(zip(st.session_state['actual_dict']['Player'], st.session_state['actual_dict']['FPTS']))
|
| 84 |
|
| 85 |
-
|
|
|
|
|
|
|
| 86 |
col1, col2 = st.columns([1, 8])
|
| 87 |
excluded_cols = ['BaseName', 'EntryCount']
|
| 88 |
player_columns = [col for col in st.session_state['Contest'].columns if col not in excluded_cols]
|
|
|
|
| 72 |
if st.session_state['projections_df'] is not None:
|
| 73 |
st.success('Projections file loaded successfully!')
|
| 74 |
st.dataframe(st.session_state['projections_df'].head(10))
|
| 75 |
+
|
|
|
|
|
|
|
| 76 |
if Contest_file and projections_file:
|
| 77 |
st.subheader("Name Matching functions")
|
| 78 |
st.session_state['Contest'], st.session_state['projections_df'], st.session_state['ownership_dict'], st.session_state['actual_dict'], st.session_state['calc_toggle'] = find_name_mismatches(st.session_state['Contest'], st.session_state['projections_df'], st.session_state['ownership_dict'], st.session_state['actual_dict'], st.session_state['calc_toggle'])
|
|
|
|
| 80 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['ownership_dict']['Player'], st.session_state['ownership_dict']['Own']))
|
| 81 |
st.session_state['actual_dict'] = dict(zip(st.session_state['actual_dict']['Player'], st.session_state['actual_dict']['FPTS']))
|
| 82 |
|
| 83 |
+
|
| 84 |
+
with tab2:
|
| 85 |
+
if 'Contest' in st.session_state and 'projections_df' in st.session_state and st.session_state['calc_toggle']:
|
| 86 |
col1, col2 = st.columns([1, 8])
|
| 87 |
excluded_cols = ['BaseName', 'EntryCount']
|
| 88 |
player_columns = [col for col in st.session_state['Contest'].columns if col not in excluded_cols]
|
global_func/find_name_mismatches.py
CHANGED
|
@@ -89,11 +89,13 @@ def find_name_mismatches(contest_df, projections_df, ownership_df, fpts_df, calc
|
|
| 89 |
fpts_df['Player'] = fpts_df['Player'].replace(selected_name, projection_name)
|
| 90 |
st.write(contest_name + ' ' + projection_name)
|
| 91 |
st.success(f"Replaced '{selected_name}' with '{projection_name}'")
|
| 92 |
-
|
| 93 |
calc_toggle = True
|
| 94 |
-
|
| 95 |
st.success("All changes applied successfully!")
|
| 96 |
return contest_df, projections_df, ownership_df, fpts_df, calc_toggle
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
else:
|
| 98 |
st.success("All players have been automatically matched!")
|
| 99 |
# Apply automatic matches
|
|
@@ -103,5 +105,5 @@ def find_name_mismatches(contest_df, projections_df, ownership_df, fpts_df, calc
|
|
| 103 |
ownership_df['Player'] = ownership_df['Player'].replace(contest_name, projection_name)
|
| 104 |
fpts_df['Player'] = fpts_df['Player'].replace(contest_name, projection_name)
|
| 105 |
st.write(contest_name + ' ' + projection_name)
|
| 106 |
-
|
| 107 |
return contest_df, projections_df, ownership_df, fpts_df, calc_toggle
|
|
|
|
| 89 |
fpts_df['Player'] = fpts_df['Player'].replace(selected_name, projection_name)
|
| 90 |
st.write(contest_name + ' ' + projection_name)
|
| 91 |
st.success(f"Replaced '{selected_name}' with '{projection_name}'")
|
|
|
|
| 92 |
calc_toggle = True
|
|
|
|
| 93 |
st.success("All changes applied successfully!")
|
| 94 |
return contest_df, projections_df, ownership_df, fpts_df, calc_toggle
|
| 95 |
+
else:
|
| 96 |
+
calc_toggle = False
|
| 97 |
+
st.success("No changes applied")
|
| 98 |
+
return contest_df, projections_df, ownership_df, fpts_df, calc_toggle
|
| 99 |
else:
|
| 100 |
st.success("All players have been automatically matched!")
|
| 101 |
# Apply automatic matches
|
|
|
|
| 105 |
ownership_df['Player'] = ownership_df['Player'].replace(contest_name, projection_name)
|
| 106 |
fpts_df['Player'] = fpts_df['Player'].replace(contest_name, projection_name)
|
| 107 |
st.write(contest_name + ' ' + projection_name)
|
| 108 |
+
calc_toggle = True
|
| 109 |
return contest_df, projections_df, ownership_df, fpts_df, calc_toggle
|