James McCool commited on
Commit
cbe1c19
·
1 Parent(s): a8cfbf7

Refactor grab_contest_data function to adjust EntryId generation and DataFrame structure

Browse files

- Modified the 'EntryId' generation to simplify its construction by removing the 'lineupHash' component, enhancing clarity.
- Updated the DataFrame structure to include 'EntryId' in the output, improving the data representation for users.

Files changed (1) hide show
  1. global_func/grab_contest_data.py +2 -2
global_func/grab_contest_data.py CHANGED
@@ -60,13 +60,13 @@ def grab_contest_data(sport, contest_name, contest_id_map, contest_date_map):
60
  lineups_df = lineups_df.reset_index()
61
  lineups_df['index'] = lineups_df.index + 1
62
  lineups_df['TimeRemaining'] = str(0)
63
- lineups_df['EntryId'] = lineups_df['lineupHash'].astype(str) + str(lineups_df['index']) + str(lineups_df['entryNameList'])
64
  lineups_df['lineupHash'] = ':' + lineups_df['lineupHash']
65
  lineups_df = lineups_df.rename(columns={'index': 'Rank', 'points': 'Points', 'entryNameList': 'EntryName', 'lineupHash': 'Lineup'})
66
  lineups_df['EntryName'] = lineups_df['EntryName'] + ' (1/1)'
67
  lineups_df['Lineup'] = lineups_df['Lineup'].apply(lambda x: format_lineup_string(x, position_inserts))
68
  lineups_df['Lineup'] = lineups_df['Lineup'].replace(pid_map, regex=True)
69
- lineups_df = lineups_df[['Rank', 'EntryName', 'TimeRemaining', 'Points', 'Lineup']]
70
 
71
  total_data = lineups_df.merge(players_df, how='left', left_index=True, right_index=True)
72
 
 
60
  lineups_df = lineups_df.reset_index()
61
  lineups_df['index'] = lineups_df.index + 1
62
  lineups_df['TimeRemaining'] = str(0)
63
+ lineups_df['EntryId'] = str(lineups_df['index']) + str(lineups_df['entryNameList'])
64
  lineups_df['lineupHash'] = ':' + lineups_df['lineupHash']
65
  lineups_df = lineups_df.rename(columns={'index': 'Rank', 'points': 'Points', 'entryNameList': 'EntryName', 'lineupHash': 'Lineup'})
66
  lineups_df['EntryName'] = lineups_df['EntryName'] + ' (1/1)'
67
  lineups_df['Lineup'] = lineups_df['Lineup'].apply(lambda x: format_lineup_string(x, position_inserts))
68
  lineups_df['Lineup'] = lineups_df['Lineup'].replace(pid_map, regex=True)
69
+ lineups_df = lineups_df[['Rank', 'EntryId', 'EntryName', 'TimeRemaining', 'Points', 'Lineup']]
70
 
71
  total_data = lineups_df.merge(players_df, how='left', left_index=True, right_index=True)
72