Spaces:
Running
Running
James McCool
commited on
Commit
·
52027e3
1
Parent(s):
e191cdb
added book objects to a bunch of dataframes
Browse files
app.py
CHANGED
|
@@ -191,7 +191,7 @@ with tab3:
|
|
| 191 |
for books in ['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS']:
|
| 192 |
prop_df = prop_df_raw.loc[prop_df_raw['book'] == books]
|
| 193 |
prop_df = prop_df.loc[prop_df['prop_type'] == prop]
|
| 194 |
-
prop_df = prop_df[['Player', 'over_prop', 'over_line', 'under_line']]
|
| 195 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 196 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 197 |
st.table(prop_df)
|
|
@@ -200,6 +200,7 @@ with tab3:
|
|
| 200 |
df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 201 |
|
| 202 |
prop_dict = dict(zip(df.Player, df.Prop))
|
|
|
|
| 203 |
over_dict = dict(zip(df.Player, df.Over))
|
| 204 |
under_dict = dict(zip(df.Player, df.Under))
|
| 205 |
|
|
@@ -221,7 +222,7 @@ with tab3:
|
|
| 221 |
flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1)
|
| 222 |
flex_file['STD'] = (flex_file['Median']/3)
|
| 223 |
flex_file['Prop'] = flex_file['Player'].map(prop_dict)
|
| 224 |
-
flex_file = flex_file[['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 225 |
|
| 226 |
hold_file = flex_file
|
| 227 |
overall_file = flex_file
|
|
@@ -232,12 +233,12 @@ with tab3:
|
|
| 232 |
for x in range(0,total_sims):
|
| 233 |
prop_file[x] = prop_file['Prop']
|
| 234 |
|
| 235 |
-
prop_file = prop_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
|
| 236 |
|
| 237 |
for x in range(0,total_sims):
|
| 238 |
overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
|
| 239 |
|
| 240 |
-
overall_file=overall_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
|
| 241 |
|
| 242 |
players_only = hold_file[['Player']]
|
| 243 |
|
|
@@ -255,6 +256,7 @@ with tab3:
|
|
| 255 |
players_only['Imp Under'] = players_only['Player'].map(under_dict)
|
| 256 |
players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
|
| 257 |
players_only['Prop'] = players_only['Player'].map(prop_dict)
|
|
|
|
| 258 |
players_only['Prop_avg'] = players_only['Prop'].mean() / 100
|
| 259 |
players_only['prop_threshold'] = .10
|
| 260 |
players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
|
|
@@ -269,7 +271,7 @@ with tab3:
|
|
| 269 |
players_only['Player'] = hold_file[['Player']]
|
| 270 |
players_only['Team'] = players_only['Player'].map(team_dict)
|
| 271 |
|
| 272 |
-
leg_outcomes = players_only[['Player', 'Team', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
|
| 273 |
sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
|
| 274 |
|
| 275 |
final_outcomes = sim_all_hold
|
|
@@ -286,7 +288,7 @@ with tab3:
|
|
| 286 |
prop_df = prop_df_raw.loc[prop_df_raw['book'] == books]
|
| 287 |
if prop_type_var == "SOG":
|
| 288 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_SHOTS_ON_GOAL']
|
| 289 |
-
prop_df = prop_df[['Player', 'over_prop', 'over_line', 'under_line']]
|
| 290 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 291 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 292 |
st.table(prop_df)
|
|
@@ -296,7 +298,7 @@ with tab3:
|
|
| 296 |
df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 297 |
elif prop_type_var == "points":
|
| 298 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_POINTS']
|
| 299 |
-
prop_df = prop_df[['Player', 'over_prop', 'over_line', 'under_line']]
|
| 300 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 301 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 302 |
st.table(prop_df)
|
|
@@ -306,7 +308,7 @@ with tab3:
|
|
| 306 |
df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 307 |
elif prop_type_var == "assists":
|
| 308 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_ASSISTS']
|
| 309 |
-
prop_df = prop_df[['Player', 'over_prop', 'over_line', 'under_line']]
|
| 310 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 311 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 312 |
st.table(prop_df)
|
|
@@ -316,7 +318,7 @@ with tab3:
|
|
| 316 |
df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 317 |
elif prop_type_var == "blocked_shots":
|
| 318 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_BLOCKED_SHOTS']
|
| 319 |
-
prop_df = prop_df[['Player', 'over_prop', 'over_line', 'under_line']]
|
| 320 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 321 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 322 |
st.table(prop_df)
|
|
@@ -327,6 +329,7 @@ with tab3:
|
|
| 327 |
|
| 328 |
st.table(df)
|
| 329 |
prop_dict = dict(zip(df.Player, df.Prop))
|
|
|
|
| 330 |
over_dict = dict(zip(df.Player, df.Over))
|
| 331 |
under_dict = dict(zip(df.Player, df.Under))
|
| 332 |
|
|
@@ -348,7 +351,7 @@ with tab3:
|
|
| 348 |
flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1)
|
| 349 |
flex_file['STD'] = (flex_file['Median']/3)
|
| 350 |
flex_file['Prop'] = flex_file['Player'].map(prop_dict)
|
| 351 |
-
flex_file = flex_file[['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 352 |
|
| 353 |
hold_file = flex_file
|
| 354 |
overall_file = flex_file
|
|
@@ -359,12 +362,12 @@ with tab3:
|
|
| 359 |
for x in range(0,total_sims):
|
| 360 |
prop_file[x] = prop_file['Prop']
|
| 361 |
|
| 362 |
-
prop_file = prop_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
|
| 363 |
|
| 364 |
for x in range(0,total_sims):
|
| 365 |
overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
|
| 366 |
|
| 367 |
-
overall_file=overall_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
|
| 368 |
|
| 369 |
players_only = hold_file[['Player']]
|
| 370 |
|
|
@@ -382,6 +385,7 @@ with tab3:
|
|
| 382 |
players_only['Imp Under'] = players_only['Player'].map(under_dict)
|
| 383 |
players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
|
| 384 |
players_only['Prop'] = players_only['Player'].map(prop_dict)
|
|
|
|
| 385 |
players_only['Prop_avg'] = players_only['Prop'].mean() / 100
|
| 386 |
players_only['prop_threshold'] = .10
|
| 387 |
players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
|
|
@@ -395,7 +399,7 @@ with tab3:
|
|
| 395 |
players_only['Player'] = hold_file[['Player']]
|
| 396 |
players_only['Team'] = players_only['Player'].map(team_dict)
|
| 397 |
|
| 398 |
-
leg_outcomes = players_only[['Player', 'Team', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
|
| 399 |
sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
|
| 400 |
|
| 401 |
final_outcomes = sim_all_hold
|
|
|
|
| 191 |
for books in ['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS']:
|
| 192 |
prop_df = prop_df_raw.loc[prop_df_raw['book'] == books]
|
| 193 |
prop_df = prop_df.loc[prop_df['prop_type'] == prop]
|
| 194 |
+
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 195 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 196 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 197 |
st.table(prop_df)
|
|
|
|
| 200 |
df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 201 |
|
| 202 |
prop_dict = dict(zip(df.Player, df.Prop))
|
| 203 |
+
book_dict = dict(zip(df.Player, df.book))
|
| 204 |
over_dict = dict(zip(df.Player, df.Over))
|
| 205 |
under_dict = dict(zip(df.Player, df.Under))
|
| 206 |
|
|
|
|
| 222 |
flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1)
|
| 223 |
flex_file['STD'] = (flex_file['Median']/3)
|
| 224 |
flex_file['Prop'] = flex_file['Player'].map(prop_dict)
|
| 225 |
+
flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 226 |
|
| 227 |
hold_file = flex_file
|
| 228 |
overall_file = flex_file
|
|
|
|
| 233 |
for x in range(0,total_sims):
|
| 234 |
prop_file[x] = prop_file['Prop']
|
| 235 |
|
| 236 |
+
prop_file = prop_file.drop(['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
|
| 237 |
|
| 238 |
for x in range(0,total_sims):
|
| 239 |
overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
|
| 240 |
|
| 241 |
+
overall_file=overall_file.drop(['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
|
| 242 |
|
| 243 |
players_only = hold_file[['Player']]
|
| 244 |
|
|
|
|
| 256 |
players_only['Imp Under'] = players_only['Player'].map(under_dict)
|
| 257 |
players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
|
| 258 |
players_only['Prop'] = players_only['Player'].map(prop_dict)
|
| 259 |
+
players_only['Book'] = players_only['Player'].map(book_dict)
|
| 260 |
players_only['Prop_avg'] = players_only['Prop'].mean() / 100
|
| 261 |
players_only['prop_threshold'] = .10
|
| 262 |
players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
|
|
|
|
| 271 |
players_only['Player'] = hold_file[['Player']]
|
| 272 |
players_only['Team'] = players_only['Player'].map(team_dict)
|
| 273 |
|
| 274 |
+
leg_outcomes = players_only[['Player', 'Team', 'Book', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
|
| 275 |
sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
|
| 276 |
|
| 277 |
final_outcomes = sim_all_hold
|
|
|
|
| 288 |
prop_df = prop_df_raw.loc[prop_df_raw['book'] == books]
|
| 289 |
if prop_type_var == "SOG":
|
| 290 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_SHOTS_ON_GOAL']
|
| 291 |
+
prop_df = prop_df[['Player', 'book', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 292 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 293 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 294 |
st.table(prop_df)
|
|
|
|
| 298 |
df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 299 |
elif prop_type_var == "points":
|
| 300 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_POINTS']
|
| 301 |
+
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 302 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 303 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 304 |
st.table(prop_df)
|
|
|
|
| 308 |
df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 309 |
elif prop_type_var == "assists":
|
| 310 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_ASSISTS']
|
| 311 |
+
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 312 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 313 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 314 |
st.table(prop_df)
|
|
|
|
| 318 |
df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 319 |
elif prop_type_var == "blocked_shots":
|
| 320 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_BLOCKED_SHOTS']
|
| 321 |
+
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 322 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 323 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 324 |
st.table(prop_df)
|
|
|
|
| 329 |
|
| 330 |
st.table(df)
|
| 331 |
prop_dict = dict(zip(df.Player, df.Prop))
|
| 332 |
+
book_dict = dict(zip(df.Player, df.book))
|
| 333 |
over_dict = dict(zip(df.Player, df.Over))
|
| 334 |
under_dict = dict(zip(df.Player, df.Under))
|
| 335 |
|
|
|
|
| 351 |
flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1)
|
| 352 |
flex_file['STD'] = (flex_file['Median']/3)
|
| 353 |
flex_file['Prop'] = flex_file['Player'].map(prop_dict)
|
| 354 |
+
flex_file = flex_file[['Player', 'Prop', 'book', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 355 |
|
| 356 |
hold_file = flex_file
|
| 357 |
overall_file = flex_file
|
|
|
|
| 362 |
for x in range(0,total_sims):
|
| 363 |
prop_file[x] = prop_file['Prop']
|
| 364 |
|
| 365 |
+
prop_file = prop_file.drop(['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
|
| 366 |
|
| 367 |
for x in range(0,total_sims):
|
| 368 |
overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
|
| 369 |
|
| 370 |
+
overall_file=overall_file.drop(['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
|
| 371 |
|
| 372 |
players_only = hold_file[['Player']]
|
| 373 |
|
|
|
|
| 385 |
players_only['Imp Under'] = players_only['Player'].map(under_dict)
|
| 386 |
players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
|
| 387 |
players_only['Prop'] = players_only['Player'].map(prop_dict)
|
| 388 |
+
players_only['Book'] = players_only['Player'].map(book_dict)
|
| 389 |
players_only['Prop_avg'] = players_only['Prop'].mean() / 100
|
| 390 |
players_only['prop_threshold'] = .10
|
| 391 |
players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
|
|
|
|
| 399 |
players_only['Player'] = hold_file[['Player']]
|
| 400 |
players_only['Team'] = players_only['Player'].map(team_dict)
|
| 401 |
|
| 402 |
+
leg_outcomes = players_only[['Player', 'Team', 'Book', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
|
| 403 |
sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
|
| 404 |
|
| 405 |
final_outcomes = sim_all_hold
|