James McCool commited on
Commit
7ca4aa0
·
1 Parent(s): 181beb3

Add NAS support in load_contest_file.py for lineup processing

Browse files

- Implemented logic to handle 'NAS' sport in the lineup processing, including adjustments for lineup replacement and splitting into respective columns. This enhances the functionality of the application by accommodating the new sport option in contest file loading.

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):
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':
@@ -125,6 +127,8 @@ def load_contest_file(upload, type, helper = None, sport = None):
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)
@@ -136,11 +140,15 @@ def load_contest_file(upload, type, helper = None, sport = None):
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)
142
  if sport == 'GOLF':
143
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' G ', 'G '], value=',', regex=True)
 
 
144
  else:
145
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' UTIL ', 'CPT '], value=',', regex=True)
146
  print(type)
 
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
+ elif sport == 'NAS':
119
+ cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' D ', 'D '], value=',', regex=True)
120
  print(sport)
121
  check_lineups = cleaned_df.copy()
122
  if sport == 'MLB':
 
127
  cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
128
  elif sport == 'WNBA':
129
  cleaned_df[['Remove', 'G1', 'G2', 'F1', 'F2', 'F3', 'UTIL']] = cleaned_df['Lineup'].str.split(',', expand=True)
130
+ elif sport == 'NAS':
131
+ cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
132
  cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
133
  entry_counts = cleaned_df['BaseName'].value_counts()
134
  cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
 
140
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
141
  elif sport == 'WNBA':
142
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'G1', 'G2', 'F1', 'F2', 'F3', 'UTIL']]
143
+ elif sport == 'NAS':
144
+ cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
145
  elif type == 'Showdown':
146
  if sport == 'NHL':
147
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' FLEX ', 'CPT '], value=',', regex=True)
148
  if sport == 'GOLF':
149
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' G ', 'G '], value=',', regex=True)
150
+ elif sport == 'NAS':
151
+ cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' D ', 'D '], value=',', regex=True)
152
  else:
153
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' UTIL ', 'CPT '], value=',', regex=True)
154
  print(type)