Multichem commited on
Commit
fe6597f
·
1 Parent(s): 8a5a3f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -58,15 +58,17 @@ def pull_baselines():
58
  raw_display.replace('', np.nan, inplace=True)
59
  prop_trends = raw_display.dropna(subset='Player')
60
 
 
 
61
  worksheet = sh.worksheet('Timestamp')
62
  timestamp = worksheet.acell('A1').value
63
 
64
- return prop_table, prop_trends, timestamp
65
 
66
  def convert_df_to_csv(df):
67
  return df.to_csv().encode('utf-8')
68
 
69
- prop_display, prop_trends, timestamp = pull_baselines()
70
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
71
 
72
  tab1, tab2, tab3 = st.tabs(["Player Stat Table", 'Prop Trend Table', 'Stat Specific Simulations'])
@@ -75,7 +77,7 @@ with tab1:
75
  st.info(t_stamp)
76
  if st.button("Reset Data", key='reset1'):
77
  st.cache_data.clear()
78
- prop_display, prop_trends, timestamp = pull_baselines()
79
  prop_frame = prop_display
80
  st.dataframe(prop_frame.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
81
 
@@ -91,7 +93,7 @@ with tab2:
91
  st.info(t_stamp)
92
  if st.button("Reset Data", key='reset3'):
93
  st.cache_data.clear()
94
- prop_display, prop_trends, timestamp = pull_baselines()
95
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
96
  split_var5 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var5')
97
  if split_var5 == 'Specific Teams':
@@ -116,7 +118,7 @@ with tab3:
116
  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.')
117
  if st.button("Reset Data/Load Data", key='reset5'):
118
  st.cache_data.clear()
119
- prop_display, prop_trends, timestamp = pull_baselines()
120
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
121
  col1, col2 = st.columns([1, 5])
122
 
@@ -215,8 +217,9 @@ with tab3:
215
  players_only['Prop type'] = prop
216
 
217
  players_only['Player'] = hold_file[['Player']]
 
218
 
219
- leg_outcomes = players_only[['Player', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
220
 
221
  sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
222
 
@@ -331,8 +334,9 @@ with tab3:
331
  players_only['Edge'] = players_only['Bet_check']
332
 
333
  players_only['Player'] = hold_file[['Player']]
 
334
 
335
- final_outcomes = players_only[['Player', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
336
 
337
  final_outcomes = final_outcomes[final_outcomes['Prop'] > 0]
338
  final_outcomes = final_outcomes.sort_values(by='Edge', ascending=False)
 
58
  raw_display.replace('', np.nan, inplace=True)
59
  prop_trends = raw_display.dropna(subset='Player')
60
 
61
+ team_dict = dict(zip(prop_table['Player'], prop_table['Team']))
62
+
63
  worksheet = sh.worksheet('Timestamp')
64
  timestamp = worksheet.acell('A1').value
65
 
66
+ return prop_table, prop_trends, timestamp, team_dict
67
 
68
  def convert_df_to_csv(df):
69
  return df.to_csv().encode('utf-8')
70
 
71
+ prop_display, prop_trends, timestamp, team_dict = pull_baselines()
72
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
73
 
74
  tab1, tab2, tab3 = st.tabs(["Player Stat Table", 'Prop Trend Table', 'Stat Specific Simulations'])
 
77
  st.info(t_stamp)
78
  if st.button("Reset Data", key='reset1'):
79
  st.cache_data.clear()
80
+ prop_display, prop_trends, timestamp, team_dict = pull_baselines()
81
  prop_frame = prop_display
82
  st.dataframe(prop_frame.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
83
 
 
93
  st.info(t_stamp)
94
  if st.button("Reset Data", key='reset3'):
95
  st.cache_data.clear()
96
+ prop_display, prop_trends, timestamp, team_dict = pull_baselines()
97
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
98
  split_var5 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var5')
99
  if split_var5 == 'Specific Teams':
 
118
  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.')
119
  if st.button("Reset Data/Load Data", key='reset5'):
120
  st.cache_data.clear()
121
+ prop_display, prop_trends, timestamp, team_dict = pull_baselines()
122
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
123
  col1, col2 = st.columns([1, 5])
124
 
 
217
  players_only['Prop type'] = prop
218
 
219
  players_only['Player'] = hold_file[['Player']]
220
+ players_only['Team'] = players_only['Player'].map(team_dict)
221
 
222
+ leg_outcomes = players_only[['Player', 'Team', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
223
 
224
  sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
225
 
 
334
  players_only['Edge'] = players_only['Bet_check']
335
 
336
  players_only['Player'] = hold_file[['Player']]
337
+ players_only['Team'] = players_only['Player'].map(team_dict)
338
 
339
+ final_outcomes = players_only[['Player', 'Team', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
340
 
341
  final_outcomes = final_outcomes[final_outcomes['Prop'] > 0]
342
  final_outcomes = final_outcomes.sort_values(by='Edge', ascending=False)