Multichem commited on
Commit
662b921
·
verified ·
1 Parent(s): 080c27a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +187 -180
app.py CHANGED
@@ -385,16 +385,179 @@ with tab6:
385
  elif game_select_var == 'Pick6':
386
  prop_df = pick_frame[['Full_name', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
387
  prop_df.rename(columns={"Full_name": "Player"}, inplace = True)
388
- prop_df = prop_df.loc[prop_df['prop_type'] == prop]
389
- prop_df = prop_df[~((prop_df['over_prop'] < 10) & (prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS'))]
390
- prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
391
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
392
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
393
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
394
- st.table(prop_df)
395
- prop_df['Over'] = 1 / prop_df['over_line']
396
- prop_df['Under'] = 1 / prop_df['under_line']
397
- df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
 
399
  prop_dict = dict(zip(df.Player, df.Prop))
400
  book_dict = dict(zip(df.Player, df.book))
@@ -404,17 +567,17 @@ with tab6:
404
  total_sims = 5000
405
 
406
  df.replace("", 0, inplace=True)
407
-
408
- if prop == "pass_yards":
409
- df['Median'] = df['NFL_GAME_PLAYER_PASSING_YARDS']
410
- elif prop == "rush_yards":
411
- df['Median'] = df['NFL_GAME_PLAYER_RUSHING_YARDS']
412
- elif prop == "rec_yards":
413
- df['Median'] = df['NFL_GAME_PLAYER_RECEIVING_YARDS']
414
- elif prop == "receptions":
415
- df['Median'] = df['NFL_GAME_PLAYER_RECEIVING_RECEPTIONS']
416
- elif prop == "rush_attempts":
417
- df['Median'] = df['NFL_GAME_PLAYER_RUSHING_ATTEMPTS']
418
 
419
  flex_file = df
420
  flex_file['Floor'] = flex_file['Median'] * .25
@@ -437,7 +600,7 @@ with tab6:
437
  for x in range(0,total_sims):
438
  overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
439
 
440
- overall_file=overall_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
441
 
442
  players_only = hold_file[['Player']]
443
 
@@ -454,8 +617,8 @@ with tab6:
454
  players_only['Under'] = prop_check[prop_check < 0].count(axis=1)/float(total_sims)
455
  players_only['Imp Under'] = players_only['Player'].map(under_dict)
456
  players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
457
- players_only['Prop'] = players_only['Player'].map(prop_dict)
458
  players_only['Book'] = players_only['Player'].map(book_dict)
 
459
  players_only['Prop_avg'] = players_only['Prop'].mean() / 100
460
  players_only['prop_threshold'] = .10
461
  players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
@@ -465,170 +628,14 @@ with tab6:
465
  players_only['Bet_suggest'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], "Over" , "Under")
466
  players_only['Bet?'] = np.where(players_only['Bet_check'] >= players_only['prop_threshold'], players_only['Bet_suggest'], "No Bet")
467
  players_only['Edge'] = players_only['Bet_check']
468
- players_only['Prop type'] = prop
469
 
470
  players_only['Player'] = hold_file[['Player']]
471
  players_only['Team'] = players_only['Player'].map(team_dict)
472
 
473
- leg_outcomes = players_only[['Player', 'Team', 'Book', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
474
  sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
475
 
476
  final_outcomes = sim_all_hold
477
-
478
- elif prop_type_var != 'All Props':
479
-
480
- if game_select_var == 'Aggregate':
481
- prop_df = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
482
- elif game_select_var == 'Pick6':
483
- prop_df = pick_frame[['Full_name', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
484
- prop_df.rename(columns={"Full_name": "Player"}, inplace = True)
485
-
486
- if prop_type_var == "pass_yards":
487
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_YARDS']
488
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
489
- prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
490
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
491
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
492
- st.table(prop_df)
493
- prop_df['Over'] = 1 / prop_df['over_line']
494
- prop_df['Under'] = 1 / prop_df['under_line']
495
- df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
496
- elif prop_type_var == "rush_yards":
497
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS']
498
- prop_df = prop_df[~((prop_df['over_prop'] < 10) & (prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS'))]
499
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
500
- prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
501
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
502
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
503
- st.table(prop_df)
504
- prop_df['Over'] = 1 / prop_df['over_line']
505
- prop_df['Under'] = 1 / prop_df['under_line']
506
- df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
507
- elif prop_type_var == "rec_yards":
508
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_YARDS']
509
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
510
- prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
511
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
512
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
513
- st.table(prop_df)
514
- prop_df['Over'] = 1 / prop_df['over_line']
515
- prop_df['Under'] = 1 / prop_df['under_line']
516
- df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
517
- elif prop_type_var == "receptions":
518
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_RECEPTIONS']
519
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
520
- prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
521
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
522
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
523
- st.table(prop_df)
524
- prop_df['Over'] = 1 / prop_df['over_line']
525
- prop_df['Under'] = 1 / prop_df['under_line']
526
- df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
527
- elif prop_type_var == "rush_attempts":
528
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_ATTEMPTS']
529
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
530
- prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
531
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
532
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
533
- st.table(prop_df)
534
- prop_df['Over'] = 1 / prop_df['over_line']
535
- prop_df['Under'] = 1 / prop_df['under_line']
536
- df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
537
- elif prop_type_var == "pass_attempts":
538
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_ATTEMPTS']
539
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
540
- prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
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 == "pass_completions":
548
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_COMPLETIONS']
549
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
550
- prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
551
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
552
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
553
- st.table(prop_df)
554
- prop_df['Over'] = 1 / prop_df['over_line']
555
- prop_df['Under'] = 1 / prop_df['under_line']
556
- df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
557
-
558
- prop_dict = dict(zip(df.Player, df.Prop))
559
- book_dict = dict(zip(df.Player, df.book))
560
- over_dict = dict(zip(df.Player, df.Over))
561
- under_dict = dict(zip(df.Player, df.Under))
562
-
563
- total_sims = 5000
564
-
565
- df.replace("", 0, inplace=True)
566
-
567
- if prop_type_var == "pass_yards":
568
- df['Median'] = df['pass_yards']
569
- elif prop_type_var == "rush_yards":
570
- df['Median'] = df['rush_yards']
571
- elif prop_type_var == "rec_yards":
572
- df['Median'] = df['rec_yards']
573
- elif prop_type_var == "receptions":
574
- df['Median'] = df['rec']
575
- elif prop_type_var == "rush_attempts":
576
- df['Median'] = df['rush_att']
577
-
578
- flex_file = df
579
- flex_file['Floor'] = flex_file['Median'] * .25
580
- flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1.75)
581
- flex_file['STD'] = flex_file['Median'] / 4
582
- flex_file['Prop'] = flex_file['Player'].map(prop_dict)
583
- flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
584
-
585
- hold_file = flex_file
586
- overall_file = flex_file
587
- prop_file = flex_file
588
-
589
- overall_players = overall_file[['Player']]
590
-
591
- for x in range(0,total_sims):
592
- prop_file[x] = prop_file['Prop']
593
-
594
- prop_file = prop_file.drop(['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
595
-
596
- for x in range(0,total_sims):
597
- overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
598
-
599
- overall_file=overall_file.drop(['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
600
-
601
- players_only = hold_file[['Player']]
602
-
603
- player_outcomes = pd.merge(players_only, overall_file, left_index=True, right_index=True)
604
-
605
- prop_check = (overall_file - prop_file)
606
-
607
- players_only['Mean_Outcome'] = overall_file.mean(axis=1)
608
- players_only['10%'] = overall_file.quantile(0.1, axis=1)
609
- players_only['90%'] = overall_file.quantile(0.9, axis=1)
610
- players_only['Over'] = prop_check[prop_check > 0].count(axis=1)/float(total_sims)
611
- players_only['Imp Over'] = players_only['Player'].map(over_dict)
612
- players_only['Over%'] = players_only[["Over", "Imp Over"]].mean(axis=1)
613
- players_only['Under'] = prop_check[prop_check < 0].count(axis=1)/float(total_sims)
614
- players_only['Imp Under'] = players_only['Player'].map(under_dict)
615
- players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
616
- players_only['Book'] = players_only['Player'].map(book_dict)
617
- players_only['Prop'] = players_only['Player'].map(prop_dict)
618
- players_only['Prop_avg'] = players_only['Prop'].mean() / 100
619
- players_only['prop_threshold'] = .10
620
- players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
621
- players_only['Over_diff'] = players_only['Over%'] - players_only['Imp Over']
622
- players_only['Under_diff'] = players_only['Under%'] - players_only['Imp Under']
623
- players_only['Bet_check'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], players_only['Over_diff'] , players_only['Under_diff'])
624
- players_only['Bet_suggest'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], "Over" , "Under")
625
- players_only['Bet?'] = np.where(players_only['Bet_check'] >= players_only['prop_threshold'], players_only['Bet_suggest'], "No Bet")
626
- players_only['Edge'] = players_only['Bet_check']
627
-
628
- players_only['Player'] = hold_file[['Player']]
629
- players_only['Team'] = players_only['Player'].map(team_dict)
630
-
631
- final_outcomes = players_only[['Player', 'Team', 'Book', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
632
 
633
  final_outcomes = final_outcomes.dropna()
634
  final_outcomes = final_outcomes.sort_values(by='Edge', ascending=False)
 
385
  elif game_select_var == 'Pick6':
386
  prop_df = pick_frame[['Full_name', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
387
  prop_df.rename(columns={"Full_name": "Player"}, inplace = True)
388
+
389
+ for books in ['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS']:
390
+ prop_df = prop_df.loc[prop_df['prop_type'] == prop]
391
+ prop_df = prop_df[~((prop_df['over_prop'] < 10) & (prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS'))]
392
+ prop_df = prop_df[prop_df['book'].isin(['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS'])]
393
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
394
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
395
+ prop_df = prop_df.loc[prop_df['Prop'] != 0]
396
+ st.table(prop_df)
397
+ prop_df['Over'] = 1 / prop_df['over_line']
398
+ prop_df['Under'] = 1 / prop_df['under_line']
399
+ df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
400
+
401
+ prop_dict = dict(zip(df.Player, df.Prop))
402
+ book_dict = dict(zip(df.Player, df.book))
403
+ over_dict = dict(zip(df.Player, df.Over))
404
+ under_dict = dict(zip(df.Player, df.Under))
405
+
406
+ total_sims = 5000
407
+
408
+ df.replace("", 0, inplace=True)
409
+
410
+ if prop == "pass_yards":
411
+ df['Median'] = df['NFL_GAME_PLAYER_PASSING_YARDS']
412
+ elif prop == "rush_yards":
413
+ df['Median'] = df['NFL_GAME_PLAYER_RUSHING_YARDS']
414
+ elif prop == "rec_yards":
415
+ df['Median'] = df['NFL_GAME_PLAYER_RECEIVING_YARDS']
416
+ elif prop == "receptions":
417
+ df['Median'] = df['NFL_GAME_PLAYER_RECEIVING_RECEPTIONS']
418
+ elif prop == "rush_attempts":
419
+ df['Median'] = df['NFL_GAME_PLAYER_RUSHING_ATTEMPTS']
420
+
421
+ flex_file = df
422
+ flex_file['Floor'] = flex_file['Median'] * .25
423
+ flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1.75)
424
+ flex_file['STD'] = flex_file['Median'] / 4
425
+ flex_file['Prop'] = flex_file['Player'].map(prop_dict)
426
+ flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
427
+
428
+ hold_file = flex_file
429
+ overall_file = flex_file
430
+ prop_file = flex_file
431
+
432
+ overall_players = overall_file[['Player']]
433
+
434
+ for x in range(0,total_sims):
435
+ prop_file[x] = prop_file['Prop']
436
+
437
+ prop_file = prop_file.drop(['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
438
+
439
+ for x in range(0,total_sims):
440
+ overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
441
+
442
+ overall_file=overall_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
443
+
444
+ players_only = hold_file[['Player']]
445
+
446
+ player_outcomes = pd.merge(players_only, overall_file, left_index=True, right_index=True)
447
+
448
+ prop_check = (overall_file - prop_file)
449
+
450
+ players_only['Mean_Outcome'] = overall_file.mean(axis=1)
451
+ players_only['10%'] = overall_file.quantile(0.1, axis=1)
452
+ players_only['90%'] = overall_file.quantile(0.9, axis=1)
453
+ players_only['Over'] = prop_check[prop_check > 0].count(axis=1)/float(total_sims)
454
+ players_only['Imp Over'] = players_only['Player'].map(over_dict)
455
+ players_only['Over%'] = players_only[["Over", "Imp Over"]].mean(axis=1)
456
+ players_only['Under'] = prop_check[prop_check < 0].count(axis=1)/float(total_sims)
457
+ players_only['Imp Under'] = players_only['Player'].map(under_dict)
458
+ players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
459
+ players_only['Prop'] = players_only['Player'].map(prop_dict)
460
+ players_only['Book'] = players_only['Player'].map(book_dict)
461
+ players_only['Prop_avg'] = players_only['Prop'].mean() / 100
462
+ players_only['prop_threshold'] = .10
463
+ players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
464
+ players_only['Over_diff'] = players_only['Over%'] - players_only['Imp Over']
465
+ players_only['Under_diff'] = players_only['Under%'] - players_only['Imp Under']
466
+ players_only['Bet_check'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], players_only['Over_diff'] , players_only['Under_diff'])
467
+ players_only['Bet_suggest'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], "Over" , "Under")
468
+ players_only['Bet?'] = np.where(players_only['Bet_check'] >= players_only['prop_threshold'], players_only['Bet_suggest'], "No Bet")
469
+ players_only['Edge'] = players_only['Bet_check']
470
+ players_only['Prop type'] = prop
471
+
472
+ players_only['Player'] = hold_file[['Player']]
473
+ players_only['Team'] = players_only['Player'].map(team_dict)
474
+
475
+ leg_outcomes = players_only[['Player', 'Team', 'Book', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
476
+ sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
477
+
478
+ final_outcomes = sim_all_hold
479
+
480
+ elif prop_type_var != 'All Props':
481
+
482
+
483
+ if game_select_var == 'Aggregate':
484
+ prop_df = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
485
+ elif game_select_var == 'Pick6':
486
+ prop_df = pick_frame[['Full_name', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
487
+ prop_df.rename(columns={"Full_name": "Player"}, inplace = True)
488
+
489
+ for books in ['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS']:
490
+ if prop_type_var == "pass_yards":
491
+ prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_YARDS']
492
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
493
+ prop_df = prop_df['book'] == books
494
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
495
+ prop_df = prop_df.loc[prop_df['Prop'] != 0]
496
+ st.table(prop_df)
497
+ prop_df['Over'] = 1 / prop_df['over_line']
498
+ prop_df['Under'] = 1 / prop_df['under_line']
499
+ df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
500
+ elif prop_type_var == "rush_yards":
501
+ prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS']
502
+ prop_df = prop_df[~((prop_df['over_prop'] < 10) & (prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_YARDS'))]
503
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
504
+ prop_df = prop_df['book'] == books
505
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
506
+ prop_df = prop_df.loc[prop_df['Prop'] != 0]
507
+ st.table(prop_df)
508
+ prop_df['Over'] = 1 / prop_df['over_line']
509
+ prop_df['Under'] = 1 / prop_df['under_line']
510
+ df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
511
+ elif prop_type_var == "rec_yards":
512
+ prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_YARDS']
513
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
514
+ prop_df = prop_df['book'] == books
515
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
516
+ prop_df = prop_df.loc[prop_df['Prop'] != 0]
517
+ st.table(prop_df)
518
+ prop_df['Over'] = 1 / prop_df['over_line']
519
+ prop_df['Under'] = 1 / prop_df['under_line']
520
+ df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
521
+ elif prop_type_var == "receptions":
522
+ prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RECEIVING_RECEPTIONS']
523
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
524
+ prop_df = prop_df['book'] == books
525
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
526
+ prop_df = prop_df.loc[prop_df['Prop'] != 0]
527
+ st.table(prop_df)
528
+ prop_df['Over'] = 1 / prop_df['over_line']
529
+ prop_df['Under'] = 1 / prop_df['under_line']
530
+ df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
531
+ elif prop_type_var == "rush_attempts":
532
+ prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_RUSHING_ATTEMPTS']
533
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
534
+ prop_df = prop_df['book'] == books
535
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
536
+ prop_df = prop_df.loc[prop_df['Prop'] != 0]
537
+ st.table(prop_df)
538
+ prop_df['Over'] = 1 / prop_df['over_line']
539
+ prop_df['Under'] = 1 / prop_df['under_line']
540
+ df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
541
+ elif prop_type_var == "pass_attempts":
542
+ prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_ATTEMPTS']
543
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
544
+ prop_df = prop_df['book'] == books
545
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
546
+ prop_df = prop_df.loc[prop_df['Prop'] != 0]
547
+ st.table(prop_df)
548
+ prop_df['Over'] = 1 / prop_df['over_line']
549
+ prop_df['Under'] = 1 / prop_df['under_line']
550
+ df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
551
+ elif prop_type_var == "pass_completions":
552
+ prop_df = prop_df.loc[prop_df['prop_type'] == 'NFL_GAME_PLAYER_PASSING_COMPLETIONS']
553
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
554
+ prop_df = prop_df['book'] == books
555
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
556
+ prop_df = prop_df.loc[prop_df['Prop'] != 0]
557
+ st.table(prop_df)
558
+ prop_df['Over'] = 1 / prop_df['over_line']
559
+ prop_df['Under'] = 1 / prop_df['under_line']
560
+ df = pd.merge(overall_stats, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
561
 
562
  prop_dict = dict(zip(df.Player, df.Prop))
563
  book_dict = dict(zip(df.Player, df.book))
 
567
  total_sims = 5000
568
 
569
  df.replace("", 0, inplace=True)
570
+
571
+ if prop_type_var == "pass_yards":
572
+ df['Median'] = df['pass_yards']
573
+ elif prop_type_var == "rush_yards":
574
+ df['Median'] = df['rush_yards']
575
+ elif prop_type_var == "rec_yards":
576
+ df['Median'] = df['rec_yards']
577
+ elif prop_type_var == "receptions":
578
+ df['Median'] = df['rec']
579
+ elif prop_type_var == "rush_attempts":
580
+ df['Median'] = df['rush_att']
581
 
582
  flex_file = df
583
  flex_file['Floor'] = flex_file['Median'] * .25
 
600
  for x in range(0,total_sims):
601
  overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
602
 
603
+ overall_file=overall_file.drop(['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
604
 
605
  players_only = hold_file[['Player']]
606
 
 
617
  players_only['Under'] = prop_check[prop_check < 0].count(axis=1)/float(total_sims)
618
  players_only['Imp Under'] = players_only['Player'].map(under_dict)
619
  players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
 
620
  players_only['Book'] = players_only['Player'].map(book_dict)
621
+ players_only['Prop'] = players_only['Player'].map(prop_dict)
622
  players_only['Prop_avg'] = players_only['Prop'].mean() / 100
623
  players_only['prop_threshold'] = .10
624
  players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
 
628
  players_only['Bet_suggest'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], "Over" , "Under")
629
  players_only['Bet?'] = np.where(players_only['Bet_check'] >= players_only['prop_threshold'], players_only['Bet_suggest'], "No Bet")
630
  players_only['Edge'] = players_only['Bet_check']
 
631
 
632
  players_only['Player'] = hold_file[['Player']]
633
  players_only['Team'] = players_only['Player'].map(team_dict)
634
 
635
+ leg_outcomes = players_only[['Player', 'Team', 'Book', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
636
  sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
637
 
638
  final_outcomes = sim_all_hold
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
639
 
640
  final_outcomes = final_outcomes.dropna()
641
  final_outcomes = final_outcomes.sort_values(by='Edge', ascending=False)