James McCool commited on
Commit
472d4c4
·
1 Parent(s): 31c912d

Enhance lineup processing in load_contest_file.py

Browse files

- Added error handling for lineup replacement logic to ensure robustness when processing different lineup formats, improving the reliability of data cleaning for Showdown contests.

Files changed (1) hide show
  1. global_func/load_contest_file.py +4 -1
global_func/load_contest_file.py CHANGED
@@ -131,7 +131,10 @@ def load_contest_file(upload, type, helper = None, sport = None):
131
  elif sport == 'GOLF':
132
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
133
  elif type == 'Showdown':
134
- cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' UTIL ', 'CPT '], value=',', regex=True)
 
 
 
135
  print(type)
136
  check_lineups = cleaned_df.copy()
137
  cleaned_df[['Remove', 'CPT', 'UTIL1', 'UTIL2', 'UTIL3', 'UTIL4', 'UTIL5']] = cleaned_df['Lineup'].str.split(',', expand=True)
 
131
  elif sport == 'GOLF':
132
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
133
  elif type == 'Showdown':
134
+ try:
135
+ cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' UTIL ', 'CPT '], value=',', regex=True)
136
+ except:
137
+ cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
138
  print(type)
139
  check_lineups = cleaned_df.copy()
140
  cleaned_df[['Remove', 'CPT', 'UTIL1', 'UTIL2', 'UTIL3', 'UTIL4', 'UTIL5']] = cleaned_df['Lineup'].str.split(',', expand=True)