James McCool
commited on
Commit
·
8d72ffa
1
Parent(s):
555e449
Refactor helper DataFrame selection in load_contest_file function
Browse files- Simplified the DataFrame selection by retaining only essential columns: 'Player', 'Salary', and 'Team'.
- Removed unnecessary processing steps related to entry names and ownership percentages, streamlining the data loading process.
- Maintained existing functionality while improving code clarity and efficiency.
global_func/load_contest_file.py
CHANGED
@@ -45,19 +45,7 @@ def load_contest_file(upload, helper = None, sport = None):
|
|
45 |
|
46 |
# Select and rename essential columns for the actual upload
|
47 |
if helper is not None:
|
48 |
-
df_helper = helper_df[['
|
49 |
-
df_helper = df_helper.rename(columns={'Roster Position': 'Pos', '%Drafted': 'Own'})
|
50 |
-
|
51 |
-
# Split EntryName into base name and entry count
|
52 |
-
df_helper['BaseName'] = df_helper['EntryName'].str.replace(r'\s*\(\d+/\d+\)$', '', regex=True)
|
53 |
-
df_helper['EntryCount'] = df_helper['EntryName'].str.extract(r'\((\d+/\d+)\)')
|
54 |
-
df_helper['EntryCount'] = df_helper['EntryCount'].fillna('1/1') # Default to 1/1 if no entry count
|
55 |
-
|
56 |
-
# Convert ownership percentage to float
|
57 |
-
try:
|
58 |
-
df_helper['Own'] = df_helper['Own'].str.replace('%', '').astype(float)
|
59 |
-
except:
|
60 |
-
df_helper['Own'] = df_helper['Own'].astype(float)
|
61 |
|
62 |
print('Made it through helper')
|
63 |
|
|
|
45 |
|
46 |
# Select and rename essential columns for the actual upload
|
47 |
if helper is not None:
|
48 |
+
df_helper = helper_df[['Player', 'Salary', 'Team']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
print('Made it through helper')
|
51 |
|