James McCool
commited on
Commit
·
2c1397f
1
Parent(s):
69590e2
Refactor date handling in grab_contest_names function for improved mapping
Browse files- Updated the date processing in the grab_contest_names function to sort dates in descending order before formatting, enhancing the accuracy of contest date mapping.
- Adjusted the contest_date_map to replace hyphens with empty strings, ensuring a consistent format for date representation.
- These changes contribute to ongoing efforts to improve data processing and maintain data integrity within the application.
app.py
CHANGED
@@ -22,13 +22,12 @@ def grab_contest_names(db, sport):
|
|
22 |
cursor = collection.find()
|
23 |
|
24 |
curr_info = pd.DataFrame(list(cursor)).drop('_id', axis=1)
|
25 |
-
curr_info['Date'] = pd.to_datetime(curr_info['Date'])
|
26 |
curr_info['Date'] = curr_info['Date'].dt.strftime('%Y-%m-%d')
|
27 |
contest_names = curr_info['Contest Name']
|
28 |
contest_id_map = dict(zip(curr_info['Contest Name'], curr_info['Contest ID']))
|
29 |
-
contest_date_map = dict(zip(curr_info['Contest Name'], curr_info['Date']))
|
30 |
|
31 |
-
|
32 |
return contest_names, contest_id_map, contest_date_map, curr_info
|
33 |
|
34 |
db = init_conn()
|
|
|
22 |
cursor = collection.find()
|
23 |
|
24 |
curr_info = pd.DataFrame(list(cursor)).drop('_id', axis=1)
|
25 |
+
curr_info['Date'] = pd.to_datetime(curr_info['Date'].sort_values(ascending = False))
|
26 |
curr_info['Date'] = curr_info['Date'].dt.strftime('%Y-%m-%d')
|
27 |
contest_names = curr_info['Contest Name']
|
28 |
contest_id_map = dict(zip(curr_info['Contest Name'], curr_info['Contest ID']))
|
29 |
+
contest_date_map = dict(zip(curr_info['Contest Name'], curr_info['Date'].replace('-', '')))
|
30 |
|
|
|
31 |
return contest_names, contest_id_map, contest_date_map, curr_info
|
32 |
|
33 |
db = init_conn()
|