James McCool
commited on
Commit
·
e04a121
1
Parent(s):
c4c501e
Refactor contest name handling in app.py to combine contest names with their corresponding dates. Removed the contest ID map from the return values of grab_contest_names function to streamline data retrieval, while maintaining the necessary information for subsequent processing.
Browse files
app.py
CHANGED
@@ -27,10 +27,9 @@ def grab_contest_names(db, sport, type):
|
|
27 |
curr_info = pd.DataFrame(list(cursor)).drop('_id', axis=1)
|
28 |
curr_info['Date'] = pd.to_datetime(curr_info['Contest Date'].sort_values(ascending = False))
|
29 |
curr_info['Date'] = curr_info['Date'].dt.strftime('%Y-%m-%d')
|
30 |
-
contest_names = curr_info['Contest Name']
|
31 |
-
contest_id_map = dict(zip(curr_info['Contest Name'], curr_info['Contest ID']))
|
32 |
|
33 |
-
return contest_names,
|
34 |
|
35 |
def grab_contest_player_info(db, sport, type, contest_date, contest_name, contest_id_map):
|
36 |
if type == 'Classic':
|
@@ -86,7 +85,7 @@ with tab1:
|
|
86 |
with sport_options:
|
87 |
sport_select = st.selectbox("Select Sport", ['MLB', 'MMA', 'GOLF'], key='sport_select')
|
88 |
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_var')
|
89 |
-
contest_names,
|
90 |
|
91 |
with date_options:
|
92 |
date_list = curr_info['Date'].sort_values(ascending=False).unique()
|
@@ -95,6 +94,7 @@ with tab1:
|
|
95 |
date_select2 = (pd.to_datetime(date_select) + pd.Timedelta(days=1)).strftime('%Y-%m-%d')
|
96 |
|
97 |
name_parse = curr_info[curr_info['Date'] == date_select]['Contest Name'].reset_index(drop=True)
|
|
|
98 |
date_select = date_select.replace('-', '')
|
99 |
date_select2 = date_select2.replace('-', '')
|
100 |
|
|
|
27 |
curr_info = pd.DataFrame(list(cursor)).drop('_id', axis=1)
|
28 |
curr_info['Date'] = pd.to_datetime(curr_info['Contest Date'].sort_values(ascending = False))
|
29 |
curr_info['Date'] = curr_info['Date'].dt.strftime('%Y-%m-%d')
|
30 |
+
contest_names = curr_info['Contest Name'] + ' - ' + curr_info['Date']
|
|
|
31 |
|
32 |
+
return contest_names, curr_info
|
33 |
|
34 |
def grab_contest_player_info(db, sport, type, contest_date, contest_name, contest_id_map):
|
35 |
if type == 'Classic':
|
|
|
85 |
with sport_options:
|
86 |
sport_select = st.selectbox("Select Sport", ['MLB', 'MMA', 'GOLF'], key='sport_select')
|
87 |
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_var')
|
88 |
+
contest_names, curr_info = grab_contest_names(db, sport_select, type_var)
|
89 |
|
90 |
with date_options:
|
91 |
date_list = curr_info['Date'].sort_values(ascending=False).unique()
|
|
|
94 |
date_select2 = (pd.to_datetime(date_select) + pd.Timedelta(days=1)).strftime('%Y-%m-%d')
|
95 |
|
96 |
name_parse = curr_info[curr_info['Date'] == date_select]['Contest Name'].reset_index(drop=True)
|
97 |
+
contest_id_map = dict(zip(name_parse, curr_info[curr_info['Date'] == date_select]['Contest ID']))
|
98 |
date_select = date_select.replace('-', '')
|
99 |
date_select2 = date_select2.replace('-', '')
|
100 |
|