Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
9f6bb94
1
Parent(s):
34a05eb
Improve player ID handling in app.py: add error handling for player_ID column selection to ensure consistent data frame structure, renaming player_id to player_ID when necessary, enhancing data integrity during processing.
Browse files
app.py
CHANGED
|
@@ -155,8 +155,13 @@ def load_overall_stats(league: str):
|
|
| 155 |
cursor = collection.find()
|
| 156 |
|
| 157 |
raw_display = pd.DataFrame(list(cursor))
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 161 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 162 |
roo_raw = raw_display.sort_values(by='Median', ascending=False)
|
|
|
|
| 155 |
cursor = collection.find()
|
| 156 |
|
| 157 |
raw_display = pd.DataFrame(list(cursor))
|
| 158 |
+
try:
|
| 159 |
+
raw_display = raw_display[['Player', 'Minutes Proj', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '4x%', '5x%', '6x%', 'GPP%',
|
| 160 |
+
'Own', 'Small_Own', 'Large_Own', 'Cash_Own', 'CPT_Own', 'LevX', 'ValX', 'site', 'version', 'slate', 'timestamp', 'player_ID']]
|
| 161 |
+
except:
|
| 162 |
+
raw_display = raw_display[['Player', 'Minutes Proj', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '4x%', '5x%', '6x%', 'GPP%',
|
| 163 |
+
'Own', 'Small_Own', 'Large_Own', 'Cash_Own', 'CPT_Own', 'LevX', 'ValX', 'site', 'version', 'slate', 'timestamp', 'player_id']]
|
| 164 |
+
raw_display = raw_display.rename(columns={"player_id": "player_ID"})
|
| 165 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 166 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 167 |
roo_raw = raw_display.sort_values(by='Median', ascending=False)
|