Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
33e229f
1
Parent(s):
25ce10e
big update to incorporate pick6 and clean up loop on stat specific sim
Browse files
app.py
CHANGED
|
@@ -87,10 +87,13 @@ non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
|
| 87 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
| 88 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
| 89 |
|
| 90 |
-
prop_table_options = ['
|
|
|
|
| 91 |
prop_format = {'L3 Success': '{:.2%}', 'L6_Success': '{:.2%}', 'L10_success': '{:.2%}', 'Trending Over': '{:.2%}', 'Trending Under': '{:.2%}',
|
| 92 |
'Implied Over': '{:.2%}', 'Implied Under': '{:.2%}', 'Over Edge': '{:.2%}', 'Under Edge': '{:.2%}'}
|
| 93 |
-
all_sim_vars = ['NFL_GAME_PLAYER_PASSING_YARDS', 'NFL_GAME_PLAYER_RUSHING_YARDS', '
|
|
|
|
|
|
|
| 94 |
sim_all_hold = pd.DataFrame(columns=['Player', 'Team', 'Book', 'Prop Type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge'])
|
| 95 |
|
| 96 |
tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(["Game Betting Model", "QB Projections", "RB/WR/TE Projections", "Player Prop Trends", "Player Prop Simulations", "Stat Specific Simulations"])
|
|
@@ -376,6 +379,11 @@ with tab6:
|
|
| 376 |
|
| 377 |
with col1:
|
| 378 |
game_select_var = st.selectbox('Select prop source', options = ['Aggregate', 'Pick6'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
if game_select_var == 'Aggregate':
|
| 380 |
prop_df = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
|
| 381 |
elif game_select_var == 'Pick6':
|
|
@@ -384,18 +392,26 @@ with tab6:
|
|
| 384 |
st.download_button(
|
| 385 |
label="Download Prop Source",
|
| 386 |
data=convert_df_to_csv(prop_df),
|
| 387 |
-
file_name='
|
| 388 |
mime='text/csv',
|
| 389 |
key='prop_source',
|
| 390 |
)
|
| 391 |
-
|
|
|
|
|
|
|
|
|
|
| 392 |
|
| 393 |
if st.button('Simulate Prop Category'):
|
| 394 |
with col2:
|
| 395 |
|
| 396 |
with df_hold_container.container():
|
| 397 |
if prop_type_var == 'All Props':
|
| 398 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 399 |
|
| 400 |
if game_select_var == 'Aggregate':
|
| 401 |
prop_df_raw = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
|
|
@@ -409,44 +425,54 @@ with tab6:
|
|
| 409 |
prop_df = prop_df[~((prop_df['over_prop'] < 15) & (prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS'))]
|
| 410 |
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 411 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
|
|
|
| 412 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 413 |
-
st.table(prop_df)
|
| 414 |
prop_df['Over'] = 1 / prop_df['over_line']
|
| 415 |
prop_df['Under'] = 1 / prop_df['under_line']
|
| 416 |
df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 417 |
-
|
|
|
|
| 418 |
prop_dict = dict(zip(df.Player, df.Prop))
|
| 419 |
book_dict = dict(zip(df.Player, df.book))
|
| 420 |
over_dict = dict(zip(df.Player, df.Over))
|
|
|
|
| 421 |
under_dict = dict(zip(df.Player, df.Under))
|
| 422 |
|
| 423 |
total_sims = 1000
|
| 424 |
|
| 425 |
df.replace("", 0, inplace=True)
|
| 426 |
|
| 427 |
-
if prop == "NFL_GAME_PLAYER_PASSING_YARDS":
|
| 428 |
df['Median'] = df['pass_yards']
|
| 429 |
-
elif prop == "NFL_GAME_PLAYER_RUSHING_YARDS":
|
| 430 |
df['Median'] = df['rush_yards']
|
| 431 |
-
elif prop == "
|
| 432 |
-
df['Median'] = df['rec_yards']
|
| 433 |
-
elif prop == "NFL_GAME_PLAYER_RECEIVING_RECEPTIONS":
|
| 434 |
-
df['Median'] = df['rec']
|
| 435 |
-
elif prop == "NFL_GAME_PLAYER_RUSHING_ATTEMPTS":
|
| 436 |
-
df['Median'] = df['rush_att']
|
| 437 |
-
elif prop == "NFL_GAME_PLAYER_PASSING_ATTEMPTS":
|
| 438 |
df['Median'] = df['pass_att']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
-
flex_file = df
|
| 441 |
flex_file['Floor'] = flex_file['Median'] * .25
|
| 442 |
flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1.75)
|
| 443 |
flex_file['STD'] = flex_file['Median'] / 4
|
| 444 |
flex_file['Prop'] = flex_file['Player'].map(prop_dict)
|
| 445 |
flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 446 |
|
| 447 |
-
hold_file = flex_file
|
| 448 |
-
overall_file = flex_file
|
| 449 |
-
prop_file = flex_file
|
| 450 |
|
| 451 |
overall_players = overall_file[['Player']]
|
| 452 |
|
|
@@ -495,115 +521,105 @@ with tab6:
|
|
| 495 |
sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
|
| 496 |
|
| 497 |
final_outcomes = sim_all_hold
|
|
|
|
| 498 |
|
| 499 |
elif prop_type_var != 'All Props':
|
| 500 |
-
|
| 501 |
-
|
| 502 |
if game_select_var == 'Aggregate':
|
| 503 |
prop_df_raw = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
|
| 504 |
elif game_select_var == 'Pick6':
|
| 505 |
prop_df_raw = pick_frame[['Full_name', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
|
| 506 |
prop_df_raw.rename(columns={"Full_name": "Player"}, inplace = True)
|
| 507 |
|
| 508 |
-
for books in
|
| 509 |
prop_df = prop_df_raw.loc[prop_df_raw['book'] == books]
|
| 510 |
-
|
|
|
|
| 511 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_YARDS']
|
| 512 |
-
|
| 513 |
-
prop_df
|
| 514 |
-
|
| 515 |
-
st.table(prop_df)
|
| 516 |
-
prop_df['Over'] = 1 / prop_df['over_line']
|
| 517 |
-
prop_df['Under'] = 1 / prop_df['under_line']
|
| 518 |
-
df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 519 |
-
elif prop_type_var == "rush_yards":
|
| 520 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS']
|
| 521 |
-
|
| 522 |
-
prop_df = prop_df[['
|
| 523 |
-
|
| 524 |
-
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 525 |
-
st.table(prop_df)
|
| 526 |
-
prop_df['Over'] = 1 / prop_df['over_line']
|
| 527 |
-
prop_df['Under'] = 1 / prop_df['under_line']
|
| 528 |
-
df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 529 |
-
elif prop_type_var == "rec_yards":
|
| 530 |
-
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_YARDS']
|
| 531 |
-
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 532 |
-
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 533 |
-
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 534 |
-
st.table(prop_df)
|
| 535 |
-
prop_df['Over'] = 1 / prop_df['over_line']
|
| 536 |
-
prop_df['Under'] = 1 / prop_df['under_line']
|
| 537 |
-
df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 538 |
-
elif prop_type_var == "receptions":
|
| 539 |
-
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_RECEPTIONS']
|
| 540 |
-
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 541 |
-
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 542 |
-
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 543 |
-
st.table(prop_df)
|
| 544 |
-
prop_df['Over'] = 1 / prop_df['over_line']
|
| 545 |
-
prop_df['Under'] = 1 / prop_df['under_line']
|
| 546 |
-
df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 547 |
-
elif prop_type_var == "rush_attempts":
|
| 548 |
-
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_ATTEMPTS']
|
| 549 |
-
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 550 |
-
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 551 |
-
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 552 |
-
st.table(prop_df)
|
| 553 |
-
prop_df['Over'] = 1 / prop_df['over_line']
|
| 554 |
-
prop_df['Under'] = 1 / prop_df['under_line']
|
| 555 |
-
df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 556 |
-
elif prop_type_var == "pass_attempts":
|
| 557 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_ATTEMPTS']
|
| 558 |
-
|
| 559 |
-
prop_df
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
prop_df['
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
prop_df = prop_df[['
|
| 568 |
-
|
| 569 |
-
prop_df = prop_df.loc[prop_df['
|
| 570 |
-
|
| 571 |
-
prop_df['
|
| 572 |
-
|
| 573 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
|
| 575 |
prop_dict = dict(zip(df.Player, df.Prop))
|
| 576 |
book_dict = dict(zip(df.Player, df.book))
|
| 577 |
over_dict = dict(zip(df.Player, df.Over))
|
|
|
|
| 578 |
under_dict = dict(zip(df.Player, df.Under))
|
| 579 |
|
| 580 |
total_sims = 1000
|
| 581 |
|
| 582 |
df.replace("", 0, inplace=True)
|
| 583 |
|
| 584 |
-
if prop_type_var == "
|
| 585 |
df['Median'] = df['pass_yards']
|
| 586 |
-
elif prop_type_var == "
|
| 587 |
df['Median'] = df['rush_yards']
|
| 588 |
-
elif prop_type_var == "
|
| 589 |
-
df['Median'] = df['rec_yards']
|
| 590 |
-
elif prop_type_var == "receptions":
|
| 591 |
-
df['Median'] = df['rec']
|
| 592 |
-
elif prop_type_var == "rush_attempts":
|
| 593 |
-
df['Median'] = df['rush_att']
|
| 594 |
-
elif prop_type_var == "pass_attempts":
|
| 595 |
df['Median'] = df['pass_att']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
|
| 597 |
-
flex_file = df
|
| 598 |
flex_file['Floor'] = flex_file['Median'] * .25
|
| 599 |
flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1.75)
|
| 600 |
flex_file['STD'] = flex_file['Median'] / 4
|
| 601 |
flex_file['Prop'] = flex_file['Player'].map(prop_dict)
|
| 602 |
flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 603 |
|
| 604 |
-
hold_file = flex_file
|
| 605 |
-
overall_file = flex_file
|
| 606 |
-
prop_file = flex_file
|
| 607 |
|
| 608 |
overall_players = overall_file[['Player']]
|
| 609 |
|
|
@@ -652,8 +668,11 @@ with tab6:
|
|
| 652 |
sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
|
| 653 |
|
| 654 |
final_outcomes = sim_all_hold
|
|
|
|
| 655 |
|
| 656 |
final_outcomes = final_outcomes.dropna()
|
|
|
|
|
|
|
| 657 |
final_outcomes = final_outcomes.sort_values(by='Edge', ascending=False)
|
| 658 |
|
| 659 |
with df_hold_container:
|
|
|
|
| 87 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
| 88 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
| 89 |
|
| 90 |
+
prop_table_options = ['NFL_GAME_PLAYER_PASSING_YARDS', 'NFL_GAME_PLAYER_RUSHING_YARDS', 'NFL_GAME_PLAYER_PASSING_ATTEMPTS', 'NFL_GAME_PLAYER_PASSING_TOUCHDOWNS', 'NFL_GAME_PLAYER_PASSING_COMPLETIONS', 'NFL_GAME_PLAYER_RUSHING_ATTEMPTS',
|
| 91 |
+
'NFL_GAME_PLAYER_RECEIVING_RECEPTIONS', 'NFL_GAME_PLAYER_RECEIVING_YARDS', 'NFL_GAME_PLAYER_RECEIVING_TOUCHDOWNS']
|
| 92 |
prop_format = {'L3 Success': '{:.2%}', 'L6_Success': '{:.2%}', 'L10_success': '{:.2%}', 'Trending Over': '{:.2%}', 'Trending Under': '{:.2%}',
|
| 93 |
'Implied Over': '{:.2%}', 'Implied Under': '{:.2%}', 'Over Edge': '{:.2%}', 'Under Edge': '{:.2%}'}
|
| 94 |
+
all_sim_vars = ['NFL_GAME_PLAYER_PASSING_YARDS', 'NFL_GAME_PLAYER_RUSHING_YARDS', 'NFL_GAME_PLAYER_PASSING_ATTEMPTS', 'NFL_GAME_PLAYER_PASSING_TOUCHDOWNS', 'NFL_GAME_PLAYER_PASSING_COMPLETIONS', 'NFL_GAME_PLAYER_RUSHING_ATTEMPTS',
|
| 95 |
+
'NFL_GAME_PLAYER_RECEIVING_RECEPTIONS', 'NFL_GAME_PLAYER_RECEIVING_YARDS', 'NFL_GAME_PLAYER_RECEIVING_TOUCHDOWNS']
|
| 96 |
+
pick6_sim_vars = ['Rush + Rec Yards', 'Rush + Rec TDs', 'Interceptions Thrown', 'Passing Yards', 'Passing Attempts', 'Passing TDs', 'Completions', 'Rushing Yards', 'Receptions', 'Receiving Yards']
|
| 97 |
sim_all_hold = pd.DataFrame(columns=['Player', 'Team', 'Book', 'Prop Type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge'])
|
| 98 |
|
| 99 |
tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(["Game Betting Model", "QB Projections", "RB/WR/TE Projections", "Player Prop Trends", "Player Prop Simulations", "Stat Specific Simulations"])
|
|
|
|
| 379 |
|
| 380 |
with col1:
|
| 381 |
game_select_var = st.selectbox('Select prop source', options = ['Aggregate', 'Pick6'])
|
| 382 |
+
book_select_var = st.selectbox('Select book', options = ['ALL', 'BET_365', 'DRAFTKINGS', 'FANDUEL', 'MGM', 'UNIBET', 'WILLIAM_HILL'])
|
| 383 |
+
if book_select_var == 'ALL':
|
| 384 |
+
book_selections = ['BET_365', 'DRAFTKINGS', 'FANDUEL', 'MGM', 'UNIBET', 'WILLIAM_HILL']
|
| 385 |
+
else:
|
| 386 |
+
book_selections = [book_select_var]
|
| 387 |
if game_select_var == 'Aggregate':
|
| 388 |
prop_df = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
|
| 389 |
elif game_select_var == 'Pick6':
|
|
|
|
| 392 |
st.download_button(
|
| 393 |
label="Download Prop Source",
|
| 394 |
data=convert_df_to_csv(prop_df),
|
| 395 |
+
file_name='NFL_prop_source.csv',
|
| 396 |
mime='text/csv',
|
| 397 |
key='prop_source',
|
| 398 |
)
|
| 399 |
+
if game_select_var == 'Aggregate':
|
| 400 |
+
prop_type_var = st.selectbox('Select prop category', options = ['All Props', 'NBA_GAME_PLAYER_POINTS', 'NBA_GAME_PLAYER_REBOUNDS', 'NBA_GAME_PLAYER_ASSISTS', 'NBA_GAME_PLAYER_POINTS_REBOUNDS_ASSISTS', 'NBA_GAME_PLAYER_POINTS_REBOUNDS', 'NBA_GAME_PLAYER_POINTS_ASSISTS', 'NBA_GAME_PLAYER_REBOUNDS_ASSISTS'])
|
| 401 |
+
elif game_select_var == 'Pick6':
|
| 402 |
+
prop_type_var = st.selectbox('Select prop category', options = ['All Props', 'Points', 'Rebounds', 'Assists', 'Points + Assists + Rebounds', 'Points + Assists', 'Points + Rebounds', 'Assists + Rebounds'])
|
| 403 |
|
| 404 |
if st.button('Simulate Prop Category'):
|
| 405 |
with col2:
|
| 406 |
|
| 407 |
with df_hold_container.container():
|
| 408 |
if prop_type_var == 'All Props':
|
| 409 |
+
if game_select_var == 'Aggregate':
|
| 410 |
+
sim_vars = ['NFL_GAME_PLAYER_PASSING_YARDS', 'NFL_GAME_PLAYER_RUSHING_YARDS', 'NFL_GAME_PLAYER_PASSING_ATTEMPTS', 'NFL_GAME_PLAYER_PASSING_TOUCHDOWNS', 'NFL_GAME_PLAYER_RUSHING_ATTEMPTS',
|
| 411 |
+
'NFL_GAME_PLAYER_RECEIVING_RECEPTIONS', 'NFL_GAME_PLAYER_RECEIVING_YARDS', 'NFL_GAME_PLAYER_RECEIVING_TOUCHDOWNS']
|
| 412 |
+
elif game_select_var == 'Pick6':
|
| 413 |
+
sim_vars = ['Rush + Rec Yards', 'Rush + Rec TDs', 'Interceptions Thrown', 'Passing Yards', 'Passing Attempts', 'Passing TDs', 'Rushing Attempts', 'Rushing Yards', 'Receptions', 'Receiving Yards', 'Receiving TDs']
|
| 414 |
+
for prop in sim_vars:
|
| 415 |
|
| 416 |
if game_select_var == 'Aggregate':
|
| 417 |
prop_df_raw = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
|
|
|
|
| 425 |
prop_df = prop_df[~((prop_df['over_prop'] < 15) & (prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS'))]
|
| 426 |
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 427 |
prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
|
| 428 |
+
prop_df = prop_df.drop_duplicates(subset=['Player'])
|
| 429 |
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
|
|
|
| 430 |
prop_df['Over'] = 1 / prop_df['over_line']
|
| 431 |
prop_df['Under'] = 1 / prop_df['under_line']
|
| 432 |
df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 433 |
+
df = df.reset_index(drop=True)
|
| 434 |
+
|
| 435 |
prop_dict = dict(zip(df.Player, df.Prop))
|
| 436 |
book_dict = dict(zip(df.Player, df.book))
|
| 437 |
over_dict = dict(zip(df.Player, df.Over))
|
| 438 |
+
team_dict = dict(zip(df.Player, df.Team))
|
| 439 |
under_dict = dict(zip(df.Player, df.Under))
|
| 440 |
|
| 441 |
total_sims = 1000
|
| 442 |
|
| 443 |
df.replace("", 0, inplace=True)
|
| 444 |
|
| 445 |
+
if prop == "NFL_GAME_PLAYER_PASSING_YARDS" or prop == "Passing Yards":
|
| 446 |
df['Median'] = df['pass_yards']
|
| 447 |
+
elif prop == "NFL_GAME_PLAYER_RUSHING_YARDS" or prop == "Rushing Yards":
|
| 448 |
df['Median'] = df['rush_yards']
|
| 449 |
+
elif prop == "NFL_GAME_PLAYER_PASSING_ATTEMPTS" or prop == "Passing Attempts":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
df['Median'] = df['pass_att']
|
| 451 |
+
elif prop == "NFL_GAME_PLAYER_PASSING_TOUCHDOWNS" or prop == "Passing TDs":
|
| 452 |
+
df['Median'] = df['pass_tds']
|
| 453 |
+
elif prop == "NFL_GAME_PLAYER_RUSHING_ATTEMPTS" or prop == "Rushing Attempts":
|
| 454 |
+
df['Median'] = df['rush_att']
|
| 455 |
+
elif prop == "NFL_GAME_PLAYER_RECEIVING_RECEPTIONS" or prop == "Receptions":
|
| 456 |
+
df['Median'] = df['rec']
|
| 457 |
+
elif prop == "NFL_GAME_PLAYER_RECEIVING_YARDS" or prop == "Receiving Yards":
|
| 458 |
+
df['Median'] = df['rec_yards']
|
| 459 |
+
elif prop == "NFL_GAME_PLAYER_RECEIVING_TOUCHDOWNS" or prop == "Receiving TDs":
|
| 460 |
+
df['Median'] = df['rec_tds']
|
| 461 |
+
elif prop == "Rush + Rec Yards":
|
| 462 |
+
df['Median'] = df['rush_yards'] + df['rec_yards']
|
| 463 |
+
elif prop == "Rush + Rec TDs":
|
| 464 |
+
df['Median'] = df['rush_tds'] + df['rec_tds']
|
| 465 |
|
| 466 |
+
flex_file = df.copy()
|
| 467 |
flex_file['Floor'] = flex_file['Median'] * .25
|
| 468 |
flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1.75)
|
| 469 |
flex_file['STD'] = flex_file['Median'] / 4
|
| 470 |
flex_file['Prop'] = flex_file['Player'].map(prop_dict)
|
| 471 |
flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 472 |
|
| 473 |
+
hold_file = flex_file.copy()
|
| 474 |
+
overall_file = flex_file.copy()
|
| 475 |
+
prop_file = flex_file.copy()
|
| 476 |
|
| 477 |
overall_players = overall_file[['Player']]
|
| 478 |
|
|
|
|
| 521 |
sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
|
| 522 |
|
| 523 |
final_outcomes = sim_all_hold
|
| 524 |
+
st.write(f'finished {prop}')
|
| 525 |
|
| 526 |
elif prop_type_var != 'All Props':
|
|
|
|
|
|
|
| 527 |
if game_select_var == 'Aggregate':
|
| 528 |
prop_df_raw = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
|
| 529 |
elif game_select_var == 'Pick6':
|
| 530 |
prop_df_raw = pick_frame[['Full_name', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
|
| 531 |
prop_df_raw.rename(columns={"Full_name": "Player"}, inplace = True)
|
| 532 |
|
| 533 |
+
for books in book_selections:
|
| 534 |
prop_df = prop_df_raw.loc[prop_df_raw['book'] == books]
|
| 535 |
+
|
| 536 |
+
if prop_type_var == "NFL_GAME_PLAYER_PASSING_YARDS":
|
| 537 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_YARDS']
|
| 538 |
+
elif prop_type_var == "Passing Yards":
|
| 539 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Passing Yards']
|
| 540 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RUSHING_YARDS":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS']
|
| 542 |
+
elif prop_type_var == "Rushing Yards":
|
| 543 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Rushing Yards']
|
| 544 |
+
elif prop_type_var == "NFL_GAME_PLAYER_PASSING_ATTEMPTS":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_ATTEMPTS']
|
| 546 |
+
elif prop_type_var == "Passing Attempts":
|
| 547 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Passing Attempts']
|
| 548 |
+
elif prop_type_var == "NFL_GAME_PLAYER_PASSING_TOUCHDOWNS":
|
| 549 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_TOUCHDOWNS']
|
| 550 |
+
elif prop_type_var == "Passing TDs":
|
| 551 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Passing TDs']
|
| 552 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RUSHING_ATTEMPTS":
|
| 553 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_ATTEMPTS']
|
| 554 |
+
elif prop_type_var == "Rushing Attempts":
|
| 555 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Rushing Attempts']
|
| 556 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RECEIVING_RECEPTIONS":
|
| 557 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_RECEPTIONS']
|
| 558 |
+
elif prop_type_var == "Receptions":
|
| 559 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Receptions']
|
| 560 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RECEIVING_YARDS":
|
| 561 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_YARDS']
|
| 562 |
+
elif prop_type_var == "Receiving Yards":
|
| 563 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Receiving Yards']
|
| 564 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RECEIVING_TOUCHDOWNS":
|
| 565 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_TOUCHDOWNS']
|
| 566 |
+
elif prop_type_var == "Receiving TDs":
|
| 567 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Receiving TDs']
|
| 568 |
+
elif prop_type_var == "Rush + Rec Yards":
|
| 569 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Rush + Rec Yards']
|
| 570 |
+
elif prop_type_var == "Rush + Rec TDs":
|
| 571 |
+
prop_df = prop_df.loc[prop_df['prop_type'] == 'Rush + Rec TDs']
|
| 572 |
+
|
| 573 |
+
prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
|
| 574 |
+
prop_df = prop_df.rename(columns={"over_prop": "Prop"})
|
| 575 |
+
prop_df = prop_df.loc[prop_df['Prop'] != 0]
|
| 576 |
+
prop_df = prop_df.drop_duplicates(subset=['Player'])
|
| 577 |
+
prop_df['Over'] = 1 / prop_df['over_line']
|
| 578 |
+
prop_df['Under'] = 1 / prop_df['under_line']
|
| 579 |
+
df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
|
| 580 |
+
df = df.reset_index(drop=True)
|
| 581 |
|
| 582 |
prop_dict = dict(zip(df.Player, df.Prop))
|
| 583 |
book_dict = dict(zip(df.Player, df.book))
|
| 584 |
over_dict = dict(zip(df.Player, df.Over))
|
| 585 |
+
team_dict = dict(zip(df.Player, df.Team))
|
| 586 |
under_dict = dict(zip(df.Player, df.Under))
|
| 587 |
|
| 588 |
total_sims = 1000
|
| 589 |
|
| 590 |
df.replace("", 0, inplace=True)
|
| 591 |
|
| 592 |
+
if prop_type_var == "NFL_GAME_PLAYER_PASSING_YARDS" or prop_type_var == "Passing Yards":
|
| 593 |
df['Median'] = df['pass_yards']
|
| 594 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RUSHING_YARDS" or prop_type_var == "Rushing Yards":
|
| 595 |
df['Median'] = df['rush_yards']
|
| 596 |
+
elif prop_type_var == "NFL_GAME_PLAYER_PASSING_ATTEMPTS" or prop_type_var == "Passing Attempts":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
df['Median'] = df['pass_att']
|
| 598 |
+
elif prop_type_var == "NFL_GAME_PLAYER_PASSING_TOUCHDOWNS" or prop_type_var == "Passing TDs":
|
| 599 |
+
df['Median'] = df['pass_tds']
|
| 600 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RUSHING_ATTEMPTS" or prop_type_var == "Rushing Attempts":
|
| 601 |
+
df['Median'] = df['rush_att']
|
| 602 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RECEIVING_RECEPTIONS" or prop_type_var == "Receptions":
|
| 603 |
+
df['Median'] = df['rec']
|
| 604 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RECEIVING_YARDS" or prop_type_var == "Receiving Yards":
|
| 605 |
+
df['Median'] = df['rec_yards']
|
| 606 |
+
elif prop_type_var == "NFL_GAME_PLAYER_RECEIVING_TOUCHDOWNS" or prop_type_var == "Receiving TDs":
|
| 607 |
+
df['Median'] = df['rec_tds']
|
| 608 |
+
elif prop_type_var == "Rush + Rec Yards":
|
| 609 |
+
df['Median'] = df['rush_yards'] + df['rec_yards']
|
| 610 |
+
elif prop_type_var == "Rush + Rec TDs":
|
| 611 |
+
df['Median'] = df['rush_tds'] + df['rec_tds']
|
| 612 |
|
| 613 |
+
flex_file = df.copy()
|
| 614 |
flex_file['Floor'] = flex_file['Median'] * .25
|
| 615 |
flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1.75)
|
| 616 |
flex_file['STD'] = flex_file['Median'] / 4
|
| 617 |
flex_file['Prop'] = flex_file['Player'].map(prop_dict)
|
| 618 |
flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 619 |
|
| 620 |
+
hold_file = flex_file.copy()
|
| 621 |
+
overall_file = flex_file.copy()
|
| 622 |
+
prop_file = flex_file.copy()
|
| 623 |
|
| 624 |
overall_players = overall_file[['Player']]
|
| 625 |
|
|
|
|
| 668 |
sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
|
| 669 |
|
| 670 |
final_outcomes = sim_all_hold
|
| 671 |
+
st.write(f'finished {prop_type_var}')
|
| 672 |
|
| 673 |
final_outcomes = final_outcomes.dropna()
|
| 674 |
+
if game_select_var == 'Pick6':
|
| 675 |
+
final_outcomes = final_outcomes.drop_duplicates(subset=['Player', 'Prop Type'])
|
| 676 |
final_outcomes = final_outcomes.sort_values(by='Edge', ascending=False)
|
| 677 |
|
| 678 |
with df_hold_container:
|