Multichem commited on
Commit
f794315
·
verified ·
1 Parent(s): c1ffc3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -63,9 +63,14 @@ def init_baselines():
63
  raw_display.replace('', np.nan, inplace=True)
64
  prop_frame = raw_display.dropna(subset='Team')
65
 
66
- return pitcher_stats, hitter_stats, team_frame, prop_frame, t_stamp
 
 
 
 
 
67
 
68
- pitcher_stats, hitter_stats, team_frame, prop_frame, t_stamp = init_baselines()
69
 
70
  tab1, tab2, tab3, tab4, tab5 = st.tabs(["Game Betting Model", "Pitcher Prop Projections", "Hitter Prop Projections", "Player Prop Simulations", "Stat Specific Simulations"])
71
 
@@ -76,7 +81,7 @@ with tab1:
76
  st.info(t_stamp)
77
  if st.button("Reset Data", key='reset1'):
78
  st.cache_data.clear()
79
- pitcher_stats, hitter_stats, team_frame, prop_frame, t_stamp = init_baselines()
80
  line_var1 = st.radio('How would you like to display odds?', options = ['Percentage', 'American'], key='line_var1')
81
  if line_var1 == 'Percentage':
82
  team_frame = team_frame[['Names', 'Game', 'Win Percentage', 'Spread', 'Cover Spread Percentage', 'Avg Score', 'Game Total', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage']]
@@ -100,7 +105,7 @@ with tab2:
100
  st.info(t_stamp)
101
  if st.button("Reset Data", key='reset2'):
102
  st.cache_data.clear()
103
- pitcher_stats, hitter_stats, team_frame, prop_frame, t_stamp = init_baselines()
104
  split_var1 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var1')
105
  if split_var1 == 'Specific Teams':
106
  team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = pitcher_stats['Team'].unique(), key='team_var1')
@@ -122,7 +127,7 @@ with tab3:
122
  st.info(t_stamp)
123
  if st.button("Reset Data", key='reset3'):
124
  st.cache_data.clear()
125
- pitcher_stats, hitter_stats, team_frame, prop_frame, t_stamp = init_baselines()
126
  split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
127
  if split_var2 == 'Specific Teams':
128
  team_var2 = st.multiselect('Which teams would you like to include in the tables?', options = hitter_stats['Team'].unique(), key='team_var2')
@@ -144,7 +149,7 @@ with tab4:
144
  st.info(t_stamp)
145
  if st.button("Reset Data", key='reset4'):
146
  st.cache_data.clear()
147
- pitcher_stats, hitter_stats, team_frame, prop_frame, t_stamp = init_baselines()
148
  col1, col2 = st.columns([1, 5])
149
 
150
  with col2:
@@ -311,7 +316,7 @@ with tab5:
311
  # Clear values from *all* all in-memory and on-disk data caches:
312
  # i.e. clear values from both square and cube
313
  st.cache_data.clear()
314
- pitcher_stats, hitter_stats, team_frame, prop_frame, t_stamp = init_baselines()
315
  col1, col2 = st.columns([1, 5])
316
 
317
  with col2:
@@ -321,6 +326,18 @@ with tab5:
321
  export_container = st.empty()
322
 
323
  with col1:
 
 
 
 
 
 
 
 
 
 
 
 
324
  prop_type_var = st.selectbox('Select prop category', options = ['Strikeouts (Pitchers)', 'Total Outs (Pitchers)'])
325
 
326
  if st.button('Simulate Prop Category'):
 
63
  raw_display.replace('', np.nan, inplace=True)
64
  prop_frame = raw_display.dropna(subset='Team')
65
 
66
+ worksheet = sh.worksheet('Pick6_ingest')
67
+ raw_display = pd.DataFrame(worksheet.get_all_records())
68
+ raw_display.replace('', np.nan, inplace=True)
69
+ pick_frame = raw_display.dropna(subset='Player')
70
+
71
+ return pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp
72
 
73
+ pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
74
 
75
  tab1, tab2, tab3, tab4, tab5 = st.tabs(["Game Betting Model", "Pitcher Prop Projections", "Hitter Prop Projections", "Player Prop Simulations", "Stat Specific Simulations"])
76
 
 
81
  st.info(t_stamp)
82
  if st.button("Reset Data", key='reset1'):
83
  st.cache_data.clear()
84
+ pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
85
  line_var1 = st.radio('How would you like to display odds?', options = ['Percentage', 'American'], key='line_var1')
86
  if line_var1 == 'Percentage':
87
  team_frame = team_frame[['Names', 'Game', 'Win Percentage', 'Spread', 'Cover Spread Percentage', 'Avg Score', 'Game Total', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage']]
 
105
  st.info(t_stamp)
106
  if st.button("Reset Data", key='reset2'):
107
  st.cache_data.clear()
108
+ pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
109
  split_var1 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var1')
110
  if split_var1 == 'Specific Teams':
111
  team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = pitcher_stats['Team'].unique(), key='team_var1')
 
127
  st.info(t_stamp)
128
  if st.button("Reset Data", key='reset3'):
129
  st.cache_data.clear()
130
+ pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
131
  split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
132
  if split_var2 == 'Specific Teams':
133
  team_var2 = st.multiselect('Which teams would you like to include in the tables?', options = hitter_stats['Team'].unique(), key='team_var2')
 
149
  st.info(t_stamp)
150
  if st.button("Reset Data", key='reset4'):
151
  st.cache_data.clear()
152
+ pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
153
  col1, col2 = st.columns([1, 5])
154
 
155
  with col2:
 
316
  # Clear values from *all* all in-memory and on-disk data caches:
317
  # i.e. clear values from both square and cube
318
  st.cache_data.clear()
319
+ pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
320
  col1, col2 = st.columns([1, 5])
321
 
322
  with col2:
 
326
  export_container = st.empty()
327
 
328
  with col1:
329
+ game_select_var = st.selectbox('Select prop source', options = ['Draftkings', 'Pick6'])
330
+ if game_select_var == 'Draftkings':
331
+ prop_df = prop_frame[['Player', 'over_prop', 'over_line', 'under_line', 'prop_type']]
332
+ elif game_select_var == 'Pick6':
333
+ prop_df = pick_frame[['Player', 'over_prop', 'over_line', 'under_line', 'prop_type']]
334
+ st.download_button(
335
+ label="Download Prop Source",
336
+ data=convert_df_to_csv(prop_df),
337
+ file_name='MLB_prop_source.csv',
338
+ mime='text/csv',
339
+ key='prop_source',
340
+ )
341
  prop_type_var = st.selectbox('Select prop category', options = ['Strikeouts (Pitchers)', 'Total Outs (Pitchers)'])
342
 
343
  if st.button('Simulate Prop Category'):