James McCool
commited on
Commit
·
9c09ce3
1
Parent(s):
6e4997c
Refactor WNBA lineup column names in load_contest_file.py
Browse files- Updated the column names for WNBA lineups to use shorter identifiers ('G1', 'G2', 'F1', 'F2', 'F3') instead of longer names, improving readability and consistency in the DataFrame.
- Adjusted the regex replacement logic to ensure accurate parsing of player positions, contributing to better data integrity during lineup processing.
global_func/load_contest_file.py
CHANGED
@@ -114,7 +114,7 @@ def load_contest_file(upload, type, helper = None, sport = None):
|
|
114 |
elif sport == 'GOLF':
|
115 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ', ' G ', 'G '], value=',', regex=True)
|
116 |
elif sport == 'WNBA':
|
117 |
-
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(['
|
118 |
print(sport)
|
119 |
check_lineups = cleaned_df.copy()
|
120 |
if sport == 'MLB':
|
@@ -124,7 +124,7 @@ def load_contest_file(upload, type, helper = None, sport = None):
|
|
124 |
elif sport == 'GOLF':
|
125 |
cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
|
126 |
elif sport == 'WNBA':
|
127 |
-
cleaned_df[['Remove', '
|
128 |
cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
|
129 |
entry_counts = cleaned_df['BaseName'].value_counts()
|
130 |
cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
|
@@ -135,7 +135,7 @@ def load_contest_file(upload, type, helper = None, sport = None):
|
|
135 |
elif sport == 'GOLF':
|
136 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
|
137 |
elif sport == 'WNBA':
|
138 |
-
cleaned_df = cleaned_df[['BaseName', 'EntryCount', '
|
139 |
elif type == 'Showdown':
|
140 |
if sport == 'NHL':
|
141 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
|
|
|
114 |
elif sport == 'GOLF':
|
115 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ', ' G ', 'G '], value=',', regex=True)
|
116 |
elif sport == 'WNBA':
|
117 |
+
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' G ', 'F ', ' F ', ' UTIL '], value=',', regex=True)
|
118 |
print(sport)
|
119 |
check_lineups = cleaned_df.copy()
|
120 |
if sport == 'MLB':
|
|
|
124 |
elif sport == 'GOLF':
|
125 |
cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
|
126 |
elif sport == 'WNBA':
|
127 |
+
cleaned_df[['Remove', 'G1', 'G2', 'F1', 'F2', 'F3', 'UTIL']] = cleaned_df['Lineup'].str.split(',', expand=True)
|
128 |
cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
|
129 |
entry_counts = cleaned_df['BaseName'].value_counts()
|
130 |
cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
|
|
|
135 |
elif sport == 'GOLF':
|
136 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
|
137 |
elif sport == 'WNBA':
|
138 |
+
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'G1', 'G2', 'F1', 'F2', 'F3', 'UTIL']]
|
139 |
elif type == 'Showdown':
|
140 |
if sport == 'NHL':
|
141 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
|