James McCool commited on
Commit
2ab6242
·
1 Parent(s): 31e306d

getting NFL ready and set

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. global_func/load_contest_file.py +9 -3
app.py CHANGED
@@ -250,7 +250,7 @@ if selected_tab == 'Data Load':
250
  sport_options, date_options = st.columns(2)
251
  parse_type = 'Manual'
252
  with sport_options:
253
- sport_init = st.selectbox("Select Sport", ['MLB', 'MMA', 'GOLF', 'NBA', 'NHL', 'CFB', 'WNBA', 'NAS'], key='sport_init')
254
  type_init = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_init')
255
  try:
256
  contest_names, curr_info = grab_contest_names(db, sport_init, type_init)
@@ -718,14 +718,14 @@ if selected_tab == 'Contest Analysis':
718
  with col1:
719
  pos_var = st.selectbox("Which position(s) would you like to view?", ['All', 'Specific'], key='pos_var')
720
  with col2:
721
- if st.session_state['sport_select'] == 'MLB':
 
 
722
  pos_select = st.multiselect("Select your position(s)", ['P', 'C', '1B', '2B', '3B', 'SS', 'OF'], key='pos_select')
723
  elif st.session_state['sport_select'] == 'NBA':
724
  pos_select = st.multiselect("Select your position(s)", ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_select')
725
  elif st.session_state['sport_select'] == 'WNBA':
726
  pos_select = st.multiselect("Select your position(s)", ['PG', 'SG', 'SF', 'PF'], key='pos_select')
727
- elif st.session_state['sport_select'] == 'NFL':
728
- pos_select = st.multiselect("Select your position(s)", ['QB', 'RB', 'WR', 'TE', 'DST'], key='pos_select')
729
  elif st.session_state['sport_select'] == 'NHL':
730
  pos_select = st.multiselect("Select your position(s)", ['W', 'C', 'D', 'G'], key='pos_select')
731
  elif st.session_state['sport_select'] == 'MMA':
 
250
  sport_options, date_options = st.columns(2)
251
  parse_type = 'Manual'
252
  with sport_options:
253
+ sport_init = st.selectbox("Select Sport", ['NFL', 'MLB', 'MMA', 'GOLF', 'NBA', 'NHL', 'CFB', 'WNBA', 'NAS'], key='sport_init')
254
  type_init = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_init')
255
  try:
256
  contest_names, curr_info = grab_contest_names(db, sport_init, type_init)
 
718
  with col1:
719
  pos_var = st.selectbox("Which position(s) would you like to view?", ['All', 'Specific'], key='pos_var')
720
  with col2:
721
+ if st.session_state['sport_select'] == 'NFL':
722
+ pos_select = st.multiselect("Select your position(s)", ['QB', 'RB', 'WR', 'TE', 'DST'], key='pos_select')
723
+ elif st.session_state['sport_select'] == 'MLB':
724
  pos_select = st.multiselect("Select your position(s)", ['P', 'C', '1B', '2B', '3B', 'SS', 'OF'], key='pos_select')
725
  elif st.session_state['sport_select'] == 'NBA':
726
  pos_select = st.multiselect("Select your position(s)", ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_select')
727
  elif st.session_state['sport_select'] == 'WNBA':
728
  pos_select = st.multiselect("Select your position(s)", ['PG', 'SG', 'SF', 'PF'], key='pos_select')
 
 
729
  elif st.session_state['sport_select'] == 'NHL':
730
  pos_select = st.multiselect("Select your position(s)", ['W', 'C', 'D', 'G'], key='pos_select')
731
  elif st.session_state['sport_select'] == 'MMA':
global_func/load_contest_file.py CHANGED
@@ -109,7 +109,9 @@ def load_contest_file(upload, type, helper = None, sport = None, portfolio = Non
109
  # Create the cleaned dataframe with just the essential columns
110
  cleaned_df = df[['BaseName', 'Lineup']]
111
  if type == 'Classic':
112
- if sport == 'MLB':
 
 
113
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF '], value=',', regex=True)
114
  elif sport == 'MMA':
115
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ', ' F ', 'F '], value=',', regex=True)
@@ -123,7 +125,9 @@ def load_contest_file(upload, type, helper = None, sport = None, portfolio = Non
123
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' QB ', 'QB ', ' RB ', 'RB ', 'WR ', 'WR ', ' S-FLEX ', 'S-FLEX ', ' FLEX ', 'FLEX '], value=',', regex=True)
124
  print(sport)
125
  check_lineups = cleaned_df.copy()
126
- if sport == 'MLB':
 
 
127
  cleaned_df[['Remove', '1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
128
  elif sport == 'MMA':
129
  cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
@@ -138,7 +142,9 @@ def load_contest_file(upload, type, helper = None, sport = None, portfolio = Non
138
  cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
139
  entry_counts = cleaned_df['BaseName'].value_counts()
140
  cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
141
- if sport == 'MLB':
 
 
142
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
143
  elif sport == 'MMA':
144
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]
 
109
  # Create the cleaned dataframe with just the essential columns
110
  cleaned_df = df[['BaseName', 'Lineup']]
111
  if type == 'Classic':
112
+ if sport == 'NFL':
113
+ cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' QB ', 'QB ', ' RB ', 'RB ', ' WR ', 'WR ', ' TE ', 'TE ', ' DST ', 'DST ', ' FLEX ', 'FLEX '], value=',', regex=True)
114
+ elif sport == 'MLB':
115
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF '], value=',', regex=True)
116
  elif sport == 'MMA':
117
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ', ' F ', 'F '], value=',', regex=True)
 
125
  cleaned_df['Lineup'] = cleaned_df['Lineup'].replace([' QB ', 'QB ', ' RB ', 'RB ', 'WR ', 'WR ', ' S-FLEX ', 'S-FLEX ', ' FLEX ', 'FLEX '], value=',', regex=True)
126
  print(sport)
127
  check_lineups = cleaned_df.copy()
128
+ if sport == 'NFL':
129
+ cleaned_df[['Remove', 'DST', 'FLEX', 'QB', 'RB1', 'RB2', 'TE', 'WR1', 'WR2', 'WR3']] = cleaned_df['Lineup'].str.split(',', expand=True)
130
+ elif sport == 'MLB':
131
  cleaned_df[['Remove', '1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
132
  elif sport == 'MMA':
133
  cleaned_df[['Remove', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']] = cleaned_df['Lineup'].str.split(',', expand=True)
 
142
  cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
143
  entry_counts = cleaned_df['BaseName'].value_counts()
144
  cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
145
+ if sport == 'NFL':
146
+ cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST']]
147
+ elif sport == 'MLB':
148
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
149
  elif sport == 'MMA':
150
  cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'Guy', 'Dude', 'Pooba', 'Bub', 'Chief', 'Buddy']]