James McCool commited on
Commit
245a9b5
·
1 Parent(s): 19654d9

Enhance lineup splitting logic in load_contest_file function

Browse files

- Added logic to split the cleaned lineup into individual player positions, improving the organization of player data.
- This change continues the effort to refine data handling and enhance user experience within the application.

Files changed (1) hide show
  1. global_func/load_contest_file.py +2 -1
global_func/load_contest_file.py CHANGED
@@ -3,7 +3,7 @@ import pandas as pd
3
 
4
  def load_contest_file(upload, sport):
5
  if sport == 'MLB':
6
- pos_list = [' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS', ' OF ']
7
  if upload is not None:
8
  try:
9
  try:
@@ -42,6 +42,7 @@ def load_contest_file(upload, sport):
42
  # Create the cleaned dataframe with just the essential columns
43
  cleaned_df = df[['BaseName', 'EntryCount', 'Lineup']]
44
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(pos_list, value=',', regex=True)
 
45
 
46
  # Get unique entry names
47
  entry_list = list(set(df['BaseName']))
 
3
 
4
  def load_contest_file(upload, sport):
5
  if sport == 'MLB':
6
+ pos_list = [' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ']
7
  if upload is not None:
8
  try:
9
  try:
 
42
  # Create the cleaned dataframe with just the essential columns
43
  cleaned_df = df[['BaseName', 'EntryCount', 'Lineup']]
44
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(pos_list, value=',', regex=True)
45
+ cleaned_df[['1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
46
 
47
  # Get unique entry names
48
  entry_list = list(set(df['BaseName']))