James McCool commited on
Commit
de2ad46
·
1 Parent(s): 795a6d7

Add MLB position handling in load_contest_file function

Browse files

- Introduced a position list for MLB, enhancing lineup processing by allowing for specific position replacements in the cleaned dataframe.
- Updated the logic to replace position indicators in the lineup, improving data accuracy and organization.
- These changes contribute to ongoing efforts to refine player data handling and enhance user experience within the application.

Files changed (1) hide show
  1. global_func/load_contest_file.py +3 -0
global_func/load_contest_file.py CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
2
  import pandas as pd
3
 
4
  def load_contest_file(upload, sport):
 
 
5
  if upload is not None:
6
  try:
7
  try:
@@ -39,6 +41,7 @@ def load_contest_file(upload, sport):
39
 
40
  # Create the cleaned dataframe with just the essential columns
41
  cleaned_df = df[['BaseName', 'EntryCount', 'Lineup']]
 
42
 
43
  # Get unique entry names
44
  entry_list = list(set(df['BaseName']))
 
2
  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:
 
41
 
42
  # Create the cleaned dataframe with just the essential columns
43
  cleaned_df = df[['BaseName', 'EntryCount', 'Lineup']]
44
+ cleaned_df['Lineup'] = cleaned_df['Lineup'].str.replace(pos_list, ',')
45
 
46
  # Get unique entry names
47
  entry_list = list(set(df['BaseName']))