James McCool
commited on
Commit
·
5b2d759
1
Parent(s):
55a9933
Add WNBA support for contest file loading
Browse files- Implemented specific handling for WNBA lineups in the load_contest_file function, allowing for the correct parsing of player positions and lineup structure.
- Updated the DataFrame processing to accommodate WNBA-specific columns, enhancing the application's functionality for users participating in WNBA contests.
global_func/load_contest_file.py
CHANGED
@@ -113,6 +113,8 @@ def load_contest_file(upload, type, helper = None, sport = None):
|
|
113 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ', ' F ', 'F '], 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 |
print(sport)
|
117 |
check_lineups = cleaned_df.copy()
|
118 |
if sport == 'MLB':
|
@@ -121,6 +123,8 @@ def load_contest_file(upload, type, helper = None, sport = None):
|
|
121 |
cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
|
122 |
elif sport == 'GOLF':
|
123 |
cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
|
|
|
|
|
124 |
cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
|
125 |
entry_counts = cleaned_df['BaseName'].value_counts()
|
126 |
cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
|
@@ -130,6 +134,8 @@ def load_contest_file(upload, type, helper = None, sport = None):
|
|
130 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
|
131 |
elif sport == 'GOLF':
|
132 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
|
|
|
|
|
133 |
elif type == 'Showdown':
|
134 |
if sport == 'NHL':
|
135 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
|
|
|
113 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ', ' F ', 'F '], 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([' F ', ' UTIL ', 'G '], value=',', regex=True)
|
118 |
print(sport)
|
119 |
check_lineups = cleaned_df.copy()
|
120 |
if sport == 'MLB':
|
|
|
123 |
cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
|
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[['Guard1', 'Guard2', 'Forward1', 'Forward2', 'Forward3', '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)
|
|
|
134 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
|
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', 'Guard1', 'Guard2', 'Forward1', 'Forward2', 'Forward3', 'UTIL']]
|
139 |
elif type == 'Showdown':
|
140 |
if sport == 'NHL':
|
141 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
|