James McCool commited on
Commit
3b2f6ef
·
1 Parent(s): 8a1f473

Enhance sport selection and contest file loading logic

Browse files

- Updated the sport selection options in app.py to include 'MMA' and 'GOLF', improving user choice for contest types.
- Modified the load_contest_file function to handle new sports, defining position lists and DataFrame structures accordingly.
- Maintained existing functionality while expanding the application's capabilities for diverse sports contests.

Files changed (2) hide show
  1. app.py +1 -1
  2. global_func/load_contest_file.py +16 -2
app.py CHANGED
@@ -57,7 +57,7 @@ with tab1:
57
  with search_options:
58
  parse_type = st.selectbox("Manual upload or DB search?", ['DB Search', 'Manual'], key='parse_type')
59
  with sport_options:
60
- sport_select = st.selectbox("Select Sport", ['MLB', 'NBA', 'NFL'], key='sport_select')
61
  contest_names, contest_id_map, curr_info = grab_contest_names(db, sport_select)
62
 
63
  with date_options:
 
57
  with search_options:
58
  parse_type = st.selectbox("Manual upload or DB search?", ['DB Search', 'Manual'], key='parse_type')
59
  with sport_options:
60
+ sport_select = st.selectbox("Select Sport", ['MLB', 'MMA', 'GOLF'], key='sport_select')
61
  contest_names, contest_id_map, curr_info = grab_contest_names(db, sport_select)
62
 
63
  with date_options:
global_func/load_contest_file.py CHANGED
@@ -4,6 +4,10 @@ import pandas as pd
4
  def load_contest_file(upload, helper = None, sport = None):
5
  if sport == 'MLB':
6
  pos_list = [' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ']
 
 
 
 
7
  if upload is not None:
8
  try:
9
  try:
@@ -69,11 +73,21 @@ def load_contest_file(upload, helper = None, sport = None):
69
  cleaned_df = df[['BaseName', 'Lineup']]
70
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(pos_list, value=',', regex=True)
71
  check_lineups = cleaned_df.copy()
72
- cleaned_df[['Remove', '1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
 
 
 
 
 
73
  cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
74
  entry_counts = cleaned_df['BaseName'].value_counts()
75
  cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
76
- cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
 
 
 
 
 
77
 
78
  print('Made it through check_lineups')
79
 
 
4
  def load_contest_file(upload, helper = None, sport = None):
5
  if sport == 'MLB':
6
  pos_list = [' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ']
7
+ elif sport == 'MMA':
8
+ pos_list = ['Guy', 'Dude', 'Pooba', 'Bub', 'Chief']
9
+ elif sport == 'GOLF':
10
+ pos_list = ['Guy', 'Dude', 'Pooba', 'Bub', 'Chief']
11
  if upload is not None:
12
  try:
13
  try:
 
73
  cleaned_df = df[['BaseName', 'Lineup']]
74
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(pos_list, value=',', regex=True)
75
  check_lineups = cleaned_df.copy()
76
+ if sport == 'MLB':
77
+ cleaned_df[['Remove', '1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
78
+ elif sport == 'MMA':
79
+ cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief']] = cleaned_df['Lineup'].str.split(',', expand=True)
80
+ elif sport == 'GOLF':
81
+ cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief']] = cleaned_df['Lineup'].str.split(',', expand=True)
82
  cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
83
  entry_counts = cleaned_df['BaseName'].value_counts()
84
  cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
85
+ if sport == 'MLB':
86
+ cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
87
+ elif sport == 'MMA':
88
+ cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief']]
89
+ elif sport == 'GOLF':
90
+ cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief']]
91
 
92
  print('Made it through check_lineups')
93