Multichem commited on
Commit
22439ab
1 Parent(s): 5f6acf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -9
app.py CHANGED
@@ -72,16 +72,22 @@ def init_baselines():
72
  raw_display = pd.DataFrame(worksheet.get_all_records())
73
  raw_display.replace('', np.nan, inplace=True)
74
  prop_frame = raw_display.dropna(subset='Player')
 
 
 
 
 
75
 
76
  prop_frame['Player'].replace(['Jaren Jackson', 'Nic Claxton', 'Jabari Smith', 'Lu Dort', 'Moe Wagner', 'Kyle Kuzma', 'Trey Murphy'],
77
  ['Jaren Jackson Jr.', 'Nicolas Claxton', 'Jabari Smith Jr.', 'Luguentz Dort', 'Moritz Wagner', 'Kyle Kuzma Jr.', 'Trey Murphy III'], inplace=True)
78
-
79
- return game_model, player_stats, prop_frame, timestamp
 
80
 
81
  def convert_df_to_csv(df):
82
  return df.to_csv().encode('utf-8')
83
 
84
- game_model, player_stats, prop_frame, timestamp = init_baselines()
85
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
86
 
87
  tab1, tab2, tab3, tab4, tab5 = st.tabs(["Game Betting Model", "Player Projections", "Prop Trend Table", "Player Prop Simulations", "Stat Specific Simulations"])
@@ -90,7 +96,7 @@ with tab1:
90
  st.info(t_stamp)
91
  if st.button("Reset Data", key='reset1'):
92
  st.cache_data.clear()
93
- game_model, player_stats, prop_frame, timestamp = init_baselines()
94
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
95
  line_var1 = st.radio('How would you like to display odds?', options = ['Percentage', 'American'], key='line_var1')
96
  team_frame = game_model
@@ -115,7 +121,7 @@ with tab2:
115
  st.info(t_stamp)
116
  if st.button("Reset Data", key='reset2'):
117
  st.cache_data.clear()
118
- game_model, player_stats, prop_frame, timestamp = init_baselines()
119
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
120
  split_var1 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var1')
121
  if split_var1 == 'Specific Teams':
@@ -137,7 +143,7 @@ with tab3:
137
  st.info(t_stamp)
138
  if st.button("Reset Data", key='reset3'):
139
  st.cache_data.clear()
140
- game_model, player_stats, prop_frame, timestamp = init_baselines()
141
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
142
  split_var5 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var5')
143
  if split_var5 == 'Specific Teams':
@@ -161,7 +167,7 @@ with tab4:
161
  st.info(t_stamp)
162
  if st.button("Reset Data", key='reset4'):
163
  st.cache_data.clear()
164
- game_model, player_stats, prop_frame, timestamp = init_baselines()
165
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
166
  col1, col2 = st.columns([1, 5])
167
 
@@ -306,7 +312,7 @@ with tab5:
306
  st.info('The Over and Under percentages are a composite percentage based on simulations, historical performance, and implied probabilities, and may be different than you would expect based purely on the median projection. Likewise, the Edge of a bet is not the only indicator of if you should make the bet or not as the suggestion is using a base acceptable threshold to determine how much edge you should have for each stat category.')
307
  if st.button("Reset Data/Load Data", key='reset5'):
308
  st.cache_data.clear()
309
- game_model, player_stats, prop_frame, timestamp = init_baselines()
310
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
311
  col1, col2 = st.columns([1, 5])
312
 
@@ -317,6 +323,7 @@ with tab5:
317
  export_container = st.empty()
318
 
319
  with col1:
 
320
  prop_type_var = st.selectbox('Select prop category', options = ['All Props', 'points', 'rebounds', 'assists', 'threes', 'PRA', 'points+rebounds',
321
  'points+assists', 'rebounds+assists'])
322
  if prop_type_var == 'All Props':
@@ -328,7 +335,10 @@ with tab5:
328
  if prop_type_var == 'All Props':
329
  for prop in all_sim_vars:
330
 
331
- prop_df = prop_frame[['Player', 'over_prop', 'over_line', 'under_line', 'prop_type']]
 
 
 
332
  prop_df = prop_df.loc[prop_df['prop_type'] == prop]
333
  prop_df = prop_df[['Player', 'over_prop', 'over_line', 'under_line']]
334
  prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
 
72
  raw_display = pd.DataFrame(worksheet.get_all_records())
73
  raw_display.replace('', np.nan, inplace=True)
74
  prop_frame = raw_display.dropna(subset='Player')
75
+
76
+ worksheet = sh.worksheet('Pick6_ingest')
77
+ raw_display = pd.DataFrame(worksheet.get_all_records())
78
+ raw_display.replace('', np.nan, inplace=True)
79
+ pick_frame = raw_display.dropna(subset='Player')
80
 
81
  prop_frame['Player'].replace(['Jaren Jackson', 'Nic Claxton', 'Jabari Smith', 'Lu Dort', 'Moe Wagner', 'Kyle Kuzma', 'Trey Murphy'],
82
  ['Jaren Jackson Jr.', 'Nicolas Claxton', 'Jabari Smith Jr.', 'Luguentz Dort', 'Moritz Wagner', 'Kyle Kuzma Jr.', 'Trey Murphy III'], inplace=True)
83
+ pick_frame['Player'].replace(['Jaren Jackson', 'Nic Claxton', 'Jabari Smith', 'Lu Dort', 'Moe Wagner', 'Kyle Kuzma', 'Trey Murphy'],
84
+ ['Jaren Jackson Jr.', 'Nicolas Claxton', 'Jabari Smith Jr.', 'Luguentz Dort', 'Moritz Wagner', 'Kyle Kuzma Jr.', 'Trey Murphy III'], inplace=True)
85
+ return game_model, player_stats, prop_frame, pick_frame, timestamp
86
 
87
  def convert_df_to_csv(df):
88
  return df.to_csv().encode('utf-8')
89
 
90
+ game_model, player_stats, prop_frame, pick_frame, timestamp = init_baselines()
91
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
92
 
93
  tab1, tab2, tab3, tab4, tab5 = st.tabs(["Game Betting Model", "Player Projections", "Prop Trend Table", "Player Prop Simulations", "Stat Specific Simulations"])
 
96
  st.info(t_stamp)
97
  if st.button("Reset Data", key='reset1'):
98
  st.cache_data.clear()
99
+ game_model, player_stats, prop_frame, pick_frame, timestamp = init_baselines()
100
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
101
  line_var1 = st.radio('How would you like to display odds?', options = ['Percentage', 'American'], key='line_var1')
102
  team_frame = game_model
 
121
  st.info(t_stamp)
122
  if st.button("Reset Data", key='reset2'):
123
  st.cache_data.clear()
124
+ game_model, player_stats, prop_frame, pick_frame, timestamp = init_baselines()
125
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
126
  split_var1 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var1')
127
  if split_var1 == 'Specific Teams':
 
143
  st.info(t_stamp)
144
  if st.button("Reset Data", key='reset3'):
145
  st.cache_data.clear()
146
+ game_model, player_stats, prop_frame, pick_frame, timestamp = init_baselines()
147
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
148
  split_var5 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var5')
149
  if split_var5 == 'Specific Teams':
 
167
  st.info(t_stamp)
168
  if st.button("Reset Data", key='reset4'):
169
  st.cache_data.clear()
170
+ game_model, player_stats, prop_frame, pick_frame, timestamp = init_baselines()
171
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
172
  col1, col2 = st.columns([1, 5])
173
 
 
312
  st.info('The Over and Under percentages are a composite percentage based on simulations, historical performance, and implied probabilities, and may be different than you would expect based purely on the median projection. Likewise, the Edge of a bet is not the only indicator of if you should make the bet or not as the suggestion is using a base acceptable threshold to determine how much edge you should have for each stat category.')
313
  if st.button("Reset Data/Load Data", key='reset5'):
314
  st.cache_data.clear()
315
+ game_model, player_stats, prop_frame, pick_frame, timestamp = init_baselines()
316
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
317
  col1, col2 = st.columns([1, 5])
318
 
 
323
  export_container = st.empty()
324
 
325
  with col1:
326
+ game_select_var = st.selectbox('Select prop source', options = ['Props', 'Pick6'])
327
  prop_type_var = st.selectbox('Select prop category', options = ['All Props', 'points', 'rebounds', 'assists', 'threes', 'PRA', 'points+rebounds',
328
  'points+assists', 'rebounds+assists'])
329
  if prop_type_var == 'All Props':
 
335
  if prop_type_var == 'All Props':
336
  for prop in all_sim_vars:
337
 
338
+ if game_select_var == 'Props':
339
+ prop_df = prop_frame[['Player', 'over_prop', 'over_line', 'under_line', 'prop_type']]
340
+ if game_select_var == 'Pick6':
341
+ prop_df = pick_frame[['Player', 'over_prop', 'over_line', 'under_line', 'prop_type']]
342
  prop_df = prop_df.loc[prop_df['prop_type'] == prop]
343
  prop_df = prop_df[['Player', 'over_prop', 'over_line', 'under_line']]
344
  prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)