James McCool
commited on
Commit
·
bbf6bb9
1
Parent(s):
f099cf5
Enhance debugging feedback in load_contest_file function
Browse files- Added print statements throughout the load_contest_file function to provide step-by-step feedback during the data loading and processing stages.
- Improved visibility into the function's execution flow, aiding in debugging and ensuring that each critical step is completed successfully.
global_func/load_contest_file.py
CHANGED
|
@@ -18,6 +18,8 @@ def load_contest_file(upload, helper = None, sport = None):
|
|
| 18 |
raw_df = upload
|
| 19 |
if helper is not None:
|
| 20 |
helper_df = helper
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Select and rename essential columns for the actual upload
|
| 23 |
if helper is None:
|
|
@@ -25,6 +27,8 @@ def load_contest_file(upload, helper = None, sport = None):
|
|
| 25 |
else:
|
| 26 |
df = raw_df[['EntryId', 'EntryName', 'TimeRemaining', 'Points', 'Lineup', 'Player', 'Roster Position', '%Drafted', 'FPTS']]
|
| 27 |
df = df.rename(columns={'Roster Position': 'Pos', '%Drafted': 'Own'})
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Split EntryName into base name and entry count
|
| 30 |
df['BaseName'] = df['EntryName'].str.replace(r'\s*\(\d+/\d+\)$', '', regex=True)
|
|
@@ -36,6 +40,8 @@ def load_contest_file(upload, helper = None, sport = None):
|
|
| 36 |
df['Own'] = df['Own'].str.replace('%', '').astype(float)
|
| 37 |
except:
|
| 38 |
df['Own'] = df['Own'].astype(float)
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# Select and rename essential columns for the actual upload
|
| 41 |
if helper is not None:
|
|
@@ -53,6 +59,8 @@ def load_contest_file(upload, helper = None, sport = None):
|
|
| 53 |
except:
|
| 54 |
df_helper['Own'] = df_helper['Own'].astype(float)
|
| 55 |
|
|
|
|
|
|
|
| 56 |
# Create separate dataframes for different player attributes
|
| 57 |
if helper is not None:
|
| 58 |
ownership_df = df[['Player', 'Own']]
|
|
@@ -66,6 +74,8 @@ def load_contest_file(upload, helper = None, sport = None):
|
|
| 66 |
salary_df = df[['Player', 'Salary']]
|
| 67 |
team_df = df[['Player', 'Team']]
|
| 68 |
pos_df = df[['Player', 'Pos']]
|
|
|
|
|
|
|
| 69 |
|
| 70 |
# Create the cleaned dataframe with just the essential columns
|
| 71 |
cleaned_df = df[['BaseName', 'Lineup']]
|
|
@@ -76,6 +86,8 @@ def load_contest_file(upload, helper = None, sport = None):
|
|
| 76 |
entry_counts = cleaned_df['BaseName'].value_counts()
|
| 77 |
cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
|
| 78 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
|
|
|
|
|
|
|
| 79 |
|
| 80 |
# Get unique entry names
|
| 81 |
entry_list = list(set(df['BaseName']))
|
|
|
|
| 18 |
raw_df = upload
|
| 19 |
if helper is not None:
|
| 20 |
helper_df = helper
|
| 21 |
+
|
| 22 |
+
print('Made it through initial upload')
|
| 23 |
|
| 24 |
# Select and rename essential columns for the actual upload
|
| 25 |
if helper is None:
|
|
|
|
| 27 |
else:
|
| 28 |
df = raw_df[['EntryId', 'EntryName', 'TimeRemaining', 'Points', 'Lineup', 'Player', 'Roster Position', '%Drafted', 'FPTS']]
|
| 29 |
df = df.rename(columns={'Roster Position': 'Pos', '%Drafted': 'Own'})
|
| 30 |
+
|
| 31 |
+
print('Made it through rename')
|
| 32 |
|
| 33 |
# Split EntryName into base name and entry count
|
| 34 |
df['BaseName'] = df['EntryName'].str.replace(r'\s*\(\d+/\d+\)$', '', regex=True)
|
|
|
|
| 40 |
df['Own'] = df['Own'].str.replace('%', '').astype(float)
|
| 41 |
except:
|
| 42 |
df['Own'] = df['Own'].astype(float)
|
| 43 |
+
|
| 44 |
+
print('Made it through ownership conversion')
|
| 45 |
|
| 46 |
# Select and rename essential columns for the actual upload
|
| 47 |
if helper is not None:
|
|
|
|
| 59 |
except:
|
| 60 |
df_helper['Own'] = df_helper['Own'].astype(float)
|
| 61 |
|
| 62 |
+
print('Made it through helper')
|
| 63 |
+
|
| 64 |
# Create separate dataframes for different player attributes
|
| 65 |
if helper is not None:
|
| 66 |
ownership_df = df[['Player', 'Own']]
|
|
|
|
| 74 |
salary_df = df[['Player', 'Salary']]
|
| 75 |
team_df = df[['Player', 'Team']]
|
| 76 |
pos_df = df[['Player', 'Pos']]
|
| 77 |
+
|
| 78 |
+
print('Made it through dictionaries')
|
| 79 |
|
| 80 |
# Create the cleaned dataframe with just the essential columns
|
| 81 |
cleaned_df = df[['BaseName', 'Lineup']]
|
|
|
|
| 86 |
entry_counts = cleaned_df['BaseName'].value_counts()
|
| 87 |
cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
|
| 88 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
|
| 89 |
+
|
| 90 |
+
print('Made it through check_lineups')
|
| 91 |
|
| 92 |
# Get unique entry names
|
| 93 |
entry_list = list(set(df['BaseName']))
|