James McCool commited on
Commit
a96ebae
·
1 Parent(s): f7fac57

Add NBA support for lineup cleaning in load_contest_file.py

Browse files

- Implemented lineup formatting and cleaning logic for NBA, ensuring consistent data handling by replacing player position indicators with commas.
- Updated the DataFrame structure to accommodate NBA player positions, enhancing the overall functionality of the contest file loading process.

Files changed (1) hide show
  1. global_func/load_contest_file.py +8 -0
global_func/load_contest_file.py CHANGED
@@ -115,6 +115,8 @@ def load_contest_file(upload, type, helper = None, sport = None, portfolio = Non
115
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' QB ', 'QB ', ' RB ', 'RB ', ' WR ', 'WR ', ' TE ', 'TE ', ' DST ', 'DST ', ' FLEX ', 'FLEX '], value=',', regex=True)
116
  elif sport == 'NHL':
117
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(['C ', ' C ', 'G ', ' G ', 'W ', ' W ', ' UTIL ', 'UTIL ', 'D ', ' D ',], value=',', regex=True)
 
 
118
  elif sport == 'MLB':
119
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF '], value=',', regex=True)
120
  elif sport == 'MMA':
@@ -133,6 +135,8 @@ def load_contest_file(upload, type, helper = None, sport = None, portfolio = Non
133
  cleaned_df[['Remove', 'DST', 'FLEX', 'QB', 'RB1', 'RB2', 'TE', 'WR1', 'WR2', 'WR3']] = cleaned_df['Lineup'].str.split(',', expand=True)
134
  elif sport == 'NHL':
135
  cleaned_df[['Remove', 'C1', 'C2', 'W1', 'W2', 'W3', 'D1', 'D2', 'G', 'UTIL']] = cleaned_df['Lineup'].str.split(',', expand=True)
 
 
136
  elif sport == 'MLB':
137
  cleaned_df[['Remove', '1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
138
  elif sport == 'MMA':
@@ -152,6 +156,8 @@ def load_contest_file(upload, type, helper = None, sport = None, portfolio = Non
152
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST']]
153
  elif sport == 'NHL':
154
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'C1', 'C2', 'W1', 'W2', 'W3', 'D1', 'D2', 'G', 'UTIL']]
 
 
155
  elif sport == 'MLB':
156
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
157
  elif sport == 'MMA':
@@ -167,6 +173,8 @@ def load_contest_file(upload, type, helper = None, sport = None, portfolio = Non
167
  elif type == 'Showdown':
168
  if sport == 'NHL':
169
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
 
 
170
  if sport == 'NFL':
171
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
172
  if sport == 'GOLF':
 
115
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' QB ', 'QB ', ' RB ', 'RB ', ' WR ', 'WR ', ' TE ', 'TE ', ' DST ', 'DST ', ' FLEX ', 'FLEX '], value=',', regex=True)
116
  elif sport == 'NHL':
117
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(['C ', ' C ', 'G ', ' G ', 'W ', ' W ', ' UTIL ', 'UTIL ', 'D ', ' D ',], value=',', regex=True)
118
+ elif sport == 'NBA':
119
+ cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(['C ', ' C ', 'G ', ' G ', 'F ', ' F ', 'UTIL ', 'UTIL ', 'PG ', ' PG ', 'SG ', ' SG ', 'SF ', ' SF ', 'PF ', ' PF '], value=',', regex=True)
120
  elif sport == 'MLB':
121
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF '], value=',', regex=True)
122
  elif sport == 'MMA':
 
135
  cleaned_df[['Remove', 'DST', 'FLEX', 'QB', 'RB1', 'RB2', 'TE', 'WR1', 'WR2', 'WR3']] = cleaned_df['Lineup'].str.split(',', expand=True)
136
  elif sport == 'NHL':
137
  cleaned_df[['Remove', 'C1', 'C2', 'W1', 'W2', 'W3', 'D1', 'D2', 'G', 'UTIL']] = cleaned_df['Lineup'].str.split(',', expand=True)
138
+ elif sport == 'NBA':
139
+ cleaned_df[['Remove', 'PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'UTIL']] = cleaned_df['Lineup'].str.split(',', expand=True)
140
  elif sport == 'MLB':
141
  cleaned_df[['Remove', '1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
142
  elif sport == 'MMA':
 
156
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST']]
157
  elif sport == 'NHL':
158
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'C1', 'C2', 'W1', 'W2', 'W3', 'D1', 'D2', 'G', 'UTIL']]
159
+ elif sport == 'NBA':
160
+ cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'UTIL']]
161
  elif sport == 'MLB':
162
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
163
  elif sport == 'MMA':
 
173
  elif type == 'Showdown':
174
  if sport == 'NHL':
175
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
176
+ elif sport == 'NBA':
177
+ cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
178
  if sport == 'NFL':
179
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
180
  if sport == 'GOLF':