James McCool
commited on
Commit
·
5b9c82c
1
Parent(s):
f9e16b0
Refactor player information handling in app.py by removing redundant error handling for contest ID filtering. Streamlined session state management for salary, team, and position dictionaries to enhance code clarity and maintain functionality.
Browse files
app.py
CHANGED
@@ -42,10 +42,6 @@ def grab_contest_player_info(db, sport, type, contest_date, contest_name, contes
|
|
42 |
|
43 |
player_info = pd.DataFrame(list(cursor)).drop('_id', axis=1)
|
44 |
player_info = player_info[player_info['Contest Date'] == contest_date]
|
45 |
-
try:
|
46 |
-
player_info = player_info[player_info['Contest ID'] == contest_id_map[contest_name]]
|
47 |
-
except:
|
48 |
-
pass
|
49 |
player_info = player_info.rename(columns={'Display Name': 'Player'})
|
50 |
player_info = player_info.sort_values(by='Salary', ascending=True).drop_duplicates(subset='Player', keep='first')
|
51 |
|
@@ -142,14 +138,9 @@ with tab1:
|
|
142 |
if 'Contest_file' in st.session_state:
|
143 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['ownership_df']['Player'], st.session_state['ownership_df']['Own']))
|
144 |
st.session_state['actual_dict'] = dict(zip(st.session_state['actual_df']['Player'], st.session_state['actual_df']['FPTS']))
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
st.session_state['pos_dict'] = st.session_state['info_maps']['position_dict']
|
149 |
-
else:
|
150 |
-
st.session_state['salary_dict'] = dict(zip(st.session_state['salary_df']['Player'], st.session_state['salary_df']['Salary']))
|
151 |
-
st.session_state['team_dict'] = dict(zip(st.session_state['team_df']['Player'], st.session_state['team_df']['Team']))
|
152 |
-
st.session_state['pos_dict'] = dict(zip(st.session_state['pos_df']['Player'], st.session_state['pos_df']['Pos']))
|
153 |
|
154 |
with tab2:
|
155 |
excluded_cols = ['BaseName', 'EntryCount']
|
|
|
42 |
|
43 |
player_info = pd.DataFrame(list(cursor)).drop('_id', axis=1)
|
44 |
player_info = player_info[player_info['Contest Date'] == contest_date]
|
|
|
|
|
|
|
|
|
45 |
player_info = player_info.rename(columns={'Display Name': 'Player'})
|
46 |
player_info = player_info.sort_values(by='Salary', ascending=True).drop_duplicates(subset='Player', keep='first')
|
47 |
|
|
|
138 |
if 'Contest_file' in st.session_state:
|
139 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['ownership_df']['Player'], st.session_state['ownership_df']['Own']))
|
140 |
st.session_state['actual_dict'] = dict(zip(st.session_state['actual_df']['Player'], st.session_state['actual_df']['FPTS']))
|
141 |
+
st.session_state['salary_dict'] = st.session_state['info_maps']['salary_dict']
|
142 |
+
st.session_state['team_dict'] = st.session_state['info_maps']['team_dict']
|
143 |
+
st.session_state['pos_dict'] = st.session_state['info_maps']['position_dict']
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
with tab2:
|
146 |
excluded_cols = ['BaseName', 'EntryCount']
|