```python
import pandas as pd
import numpy as np
import xgboost as xgb
from patsy import dmatrices

pd.options.display.max_columns = 999
pd.options.display.max_rows = 999
```

```python
# pbp_data = pd.read_csv("./results/base-epa.csv", encoding="utf-8")
pbp_data = pd.DataFrame()
years = range(2014,2020)
for i in years:
    url = f"https://raw.githubusercontent.com/saiemgilani/cfbscrapR-data/master/data/parquet/pbp_players_pos_{i}.parquet"
    print(f"Pulling url {url}")
    i_data = pd.read_parquet(url, engine='pyarrow')

    #sort=True eliminates a warning and alphabetically sorts columns
    pbp_data = pbp_data.append(i_data, sort=True)

#Give each row a unique index
pbp_data.reset_index(drop=True, inplace=True)
pbp_data.head()
```

    Pulling url https://raw.githubusercontent.com/saiemgilani/cfbscrapR-data/master/data/parquet/pbp_players_pos_2014.parquet
    Pulling url https://raw.githubusercontent.com/saiemgilani/cfbscrapR-data/master/data/parquet/pbp_players_pos_2015.parquet
    Pulling url https://raw.githubusercontent.com/saiemgilani/cfbscrapR-data/master/data/parquet/pbp_players_pos_2016.parquet
    Pulling url https://raw.githubusercontent.com/saiemgilani/cfbscrapR-data/master/data/parquet/pbp_players_pos_2017.parquet
    Pulling url https://raw.githubusercontent.com/saiemgilani/cfbscrapR-data/master/data/parquet/pbp_players_pos_2018.parquet
    Pulling url https://raw.githubusercontent.com/saiemgilani/cfbscrapR-data/master/data/parquet/pbp_players_pos_2019.parquet

      EPA
      ExpScoreDiff
      ExpScoreDiff_Time_Ratio
      FG_after
      FG_before
      Goal_To_Go
      Goal_To_Go_end
      No_Score_after
      No_Score_before
      Opp_FG_after
      Opp_FG_before
      Opp_Safety_after
      Opp_Safety_before
      Opp_TD_after
      Opp_TD_before
      Safety_after
      Safety_before
      TD_after
      TD_before
      TimeSecsRem
      TimeSecsRem_end
      Under_three
      Under_two
      Under_two_end
      adj_TimeSecsRem
      away
      away_EPA
      away_EPA_pass
      away_EPA_rush
      away_wp_after
      away_wp_before
      change_of_pos_team
      change_of_poss
      clock.minutes
      clock.seconds
      completion
      completion_player
      completion_player_id
      completion_yds
      def_EPA
      def_pos_team
      def_pos_team_score
      def_pos_team_timeouts
      def_pos_team_timeouts_rem_before
      def_timeout_called
      def_timeouts_rem_before
      def_wp_after
      def_wp_before
      defense_conference
      defense_play
      defense_score
      defense_score_play
      defense_timeouts
      distance
      distance_end
      down
      down_end
      downs_turnover
      drive_end_period
      drive_end_yards_to_goal
      drive_event_number
      drive_id
      drive_num
      drive_number
      drive_numbers
      drive_play_number
      drive_pts
      drive_result
      drive_result2
      drive_result_detailed
      drive_result_detailed_flag
      drive_scoring
      drive_start_period
      drive_start_yards_to_goal
      drive_time_minutes_elapsed
      drive_time_minutes_end
      drive_time_minutes_start
      drive_time_seconds_elapsed
      drive_time_seconds_end
      drive_time_seconds_start
      drive_yards
      end_of_half
      ep_after
      ep_before
      epa_success
      fg_block_player_name
      fg_inds
      fg_kicker_player_name
      fg_made
      fg_make_prob
      fg_return_player_name
      firstD_by_kickoff
      firstD_by_penalty
      firstD_by_poss
      firstD_by_yards
      first_by_penalty
      first_by_yards
      fumble_forced_player
      fumble_forced_player_id
      fumble_forced_player_name
      fumble_forced_stat
      fumble_player
      fumble_player_id
      fumble_player_name
      fumble_recovered_player
      fumble_recovered_player_id
      fumble_recovered_player_name
      fumble_recovered_stat
      fumble_stat
      fumble_vec
      game_id
      game_play_number
      half
      half_clock.minutes
      half_play_number
      home
      home_EPA
      home_EPA_pass
      home_EPA_rush
      home_wp_after
      home_wp_before
      id_drive
      id_play
      incompletion_player
      incompletion_player_id
      incompletion_stat
      int
      int_td
      interception_player
      interception_player_id
      interception_player_name
      interception_stat
      interception_thrown_player
      interception_thrown_player_id
      interception_thrown_stat
      kick_play
      kickoff_downed
      kickoff_fair_catch
      kickoff_onside
      kickoff_oob
      kickoff_play
      kickoff_player_name
      kickoff_returner_player_name
      kickoff_safety
      kickoff_tb
      lag_change_of_pos_team
      lag_change_of_pos_team2
      lag_change_of_poss
      lag_defense_score_play
      lag_downs_turnover
      lag_drive_result_detailed
      lag_first_by_penalty
      lag_first_by_penalty2
      lag_first_by_yards
      lag_first_by_yards2
      lag_kickoff_play
      lag_new_drive_pts
      lag_play_text
      lag_play_text2
      lag_play_type
      lag_play_type2
      lag_play_type3
      lag_pos_team
      lag_punt
      lag_punt2
      lag_scoring_play
      lag_turnover_vec
      lead_drive_result_detailed
      lead_play_text
      lead_play_type
      lead_pos_team
      log_ydstogo
      log_ydstogo_end
      middle_8
      missing_yard_flag
      net_away_EPA
      net_away_EPA_pass
      net_away_EPA_rush
      net_home_EPA
      net_home_EPA_pass
      net_home_EPA_rush
      new_drive_pts
      new_id
      new_series
      number_of_drives
      off_timeout_called
      off_timeouts_rem_before
      offense_conference
      offense_play
      offense_receives_2H_kickoff
      offense_score
      offense_score_play
      offense_timeouts
      opponent
      opponent_score
      orig_drive_number
      orig_play_type
      pass
      pass_attempt
      pass_breakup_player
      pass_breakup_player_id
      pass_breakup_player_name
      pass_breakup_stat
      pass_td
      passer_player_name
      penalty_1st_conv
      penalty_declined
      penalty_detail
      penalty_flag
      penalty_no_play
      penalty_offset
      penalty_play_text
      penalty_safety
      penalty_text
      period
      play_after_turnover
      play_id
      play_text
      play_type
      pos_score_diff
      pos_score_diff_start
      pos_score_diff_start_end
      pos_score_pts
      pos_team
      pos_team_receives_2H_kickoff
      pos_team_score
      pos_team_timeouts
      pos_team_timeouts_rem_before
      position_completion
      position_fumble
      position_fumble_forced
      position_fumble_recovered
      position_incompletion
      position_interception
      position_interception_thrown
      position_pass_breakup
      position_reception
      position_rush
      position_sack
      position_sack_taken
      position_target
      position_touchdown
      ppa
      pts_scored
      punt
      punt_block_player_name
      punt_block_return_player_name
      punt_blocked
      punt_downed
      punt_fair_catch
      punt_oob
      punt_play
      punt_returner_player_name
      punt_safety
      punt_tb
      punter_player_name
      receiver_player_name
      receives_2H_kickoff
      reception_player
      reception_player_id
      reception_yds
      row
      rush
      rush_player
      rush_player_id
      rush_td
      rush_yds
      rusher_player_name
      rz_play
      sack
      sack_player
      sack_player_id
      sack_player_name
      sack_player_name2
      sack_players
      sack_stat
      sack_taken_player
      sack_taken_player_id
      sack_taken_stat
      sack_vec
      safety
      score_diff
      score_diff_start
      score_pts
      scoring
      scoring_opp
      scoring_play
      season
      stuffed_run
      success
      target
      target_player
      target_player_id
      target_stat
      td_play
      team_score
      total_away_EPA
      total_away_EPA_pass
      total_away_EPA_rush
      total_home_EPA
      total_home_EPA_pass
      total_home_EPA_rush
      touchdown
      touchdown_player
      touchdown_player_id
      touchdown_stat
      turnover
      turnover_indicator
      turnover_vec
      turnover_vec_lag
      week
      wp_after
      wp_before
      wpa
      yard_line
      yards_gained
      yards_to_goal
      yards_to_goal_end
      yds_fg
      yds_fumble_return
      yds_int_return
      yds_kickoff
      yds_kickoff_return
      yds_penalty
      yds_punt_gained
      yds_punt_return
      yds_punted
      yds_receiving
      yds_rushed
      yds_sacked
      year

      0
      -0.565384
      0.835848
      0.000232
      0.132497
      0.170311
      False
      False
      0.002218
      0.001810
      0.123708
      0.089125
      0.004623
      0.001920
      0.349311
      0.260266
      0.002997
      0.002954
      0.384646
      0.473614
      1795
      1795.0
      False
      False
      False
      3595
      Temple
      -0.565384
      NaN
      NaN
      0.469500
      0.491924
      0
      1
      14
      55
      0
      None
      NaN
      NaN
      0.565384
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.530500
      0.508076
      American Athletic
      Temple
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      63
      1
      4.005476e+09
      1
      1
      1
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      0.270464
      0.835848
      0.0
      None
      0.0
      None
      False
      NaN
      None
      1.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      1
      1
      29
      1
      Vanderbilt
      0.565384
      NaN
      NaN
      0.530500
      0.508076
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      1
      0
      0
      0
      0
      1
      Hayden Lekacz
      Khalif Herbin
      0.0
      0
      0.0
      0.0
      0.0
      NaN
      0.0
      None
      0
      NaN
      0.0
      NaN
      0.0
      NaN
      None
      None
      None
      None
      None
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      TEMPLE Penalty, False Start (5 Yards) to the T...
      Penalty
      Temple
      2.302585
      2.302585
      False
      False
      -1.130768
      0.000000
      0.000000
      1.130768
      0.000000
      0.000000
      0
      101854401
      1.0
      1
      0.0
      3.0
      SEC
      Vanderbilt
      1
      0
      0
      3.0
      None
      NaN
      1
      Kickoff Return (Offense)
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      NaN
      None
      Hayden Lekacz kickoff for 64 yds , Khalif Herb...
      Kickoff Return (Offense)
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      1.0
      None
      NaN
      NaN
      1
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      1.0
      0
      None
      NaN
      NaN
      0
      NaN
      -0.565384
      0.000000
      0.000000
      0.565384
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      NaN
      1
      0.469500
      0.491924
      -0.022424
      35
      18
      65
      81.0
      NaN
      NaN
      NaN
      64.0
      18.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014

      1
      -0.469578
      0.270464
      0.000075
      0.120739
      0.132497
      False
      False
      0.002423
      0.002218
      0.134912
      0.123708
      0.006027
      0.004623
      0.377211
      0.349311
      0.002977
      0.002997
      0.355712
      0.384646
      1795
      1785.0
      False
      False
      False
      3595
      Temple
      -0.469578
      NaN
      NaN
      0.442379
      0.469500
      0
      0
      14
      55
      0
      None
      NaN
      NaN
      0.469578
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.557621
      0.530500
      SEC
      Vanderbilt
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      63
      2
      4.005476e+09
      1
      1
      0
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      -0.199114
      0.270464
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      1
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      1
      1
      29
      1
      Vanderbilt
      0.469578
      NaN
      NaN
      0.557621
      0.530500
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Punt
      0
      NaN
      0.0
      NaN
      1.0
      0.0
      Hayden Lekacz kickoff for 64 yds , Khalif Herb...
      None
      Kickoff Return (Offense)
      None
      None
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Pass Reception
      Temple
      2.302585
      2.302585
      False
      False
      -2.069924
      0.000000
      0.000000
      2.069924
      0.000000
      0.000000
      0
      101854402
      0.0
      1
      0.0
      3.0
      American Athletic
      Temple
      0
      0
      0
      3.0
      None
      NaN
      1
      Penalty
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      False Start
      True
      False
      False
      Penalty, False Start (5 Yards) to the Temp 14
      0
      False
      1
      0.0
      None
      TEMPLE Penalty, False Start (5 Yards) to the T...
      Penalty
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      1.0
      None
      NaN
      NaN
      2
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      0.0
      0
      None
      NaN
      NaN
      0
      NaN
      -1.034962
      0.000000
      0.000000
      1.034962
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.442379
      0.469500
      -0.027121
      81
      -5
      81
      86.0
      NaN
      NaN
      NaN
      NaN
      NaN
      -5.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014

      2
      -0.484325
      -0.488417
      -0.000136
      0.111865
      0.139679
      False
      False
      0.002728
      0.002383
      0.149630
      0.134811
      0.005772
      0.006593
      0.424451
      0.392052
      0.003125
      0.003371
      0.302429
      0.321112
      1785
      1760.0
      False
      False
      False
      3585
      Temple
      -0.484325
      -0.484325
      NaN
      0.430545
      0.442379
      0
      0
      14
      45
      1
      None
      NaN
      NaN
      0.484325
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.569455
      0.557621
      SEC
      Vanderbilt
      0
      0
      3.0
      15.0
      12.0
      1.0
      2.0
      0
      1
      63
      3
      4.005476e+09
      1
      1
      0
      2
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      -0.972742
      -0.488417
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      2
      1
      29
      2
      Vanderbilt
      0.484325
      NaN
      NaN
      0.569455
      0.557621
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      TEMPLE Penalty, False Start (5 Yards) to the T...
      Hayden Lekacz kickoff for 64 yds , Khalif Herb...
      Penalty
      Kickoff Return (Offense)
      None
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      Kenneth Harper run for 5 yds to the Temp 22
      Rush
      Temple
      2.708050
      2.484907
      False
      False
      -3.038574
      -0.484325
      0.000000
      3.038574
      0.484325
      0.000000
      0
      101855401
      0.0
      1
      0.0
      3.0
      American Athletic
      Temple
      0
      0
      0
      3.0
      Vanderbilt
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      P.J. Walker
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Pass Reception
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      -0.100269
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Jalen Fitzpatrick
      1.0
      Jalen Fitzpatrick
      513398.0
      3.0
      3
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      None
      NaN
      NaN
      0
      0.0
      -1.519287
      -0.484325
      0.000000
      1.519287
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.430545
      0.442379
      -0.011835
      86
      3
      86
      83.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      3.0
      NaN
      NaN
      2014

      3
      -0.214516
      -0.972742
      -0.000273
      0.093482
      0.111865
      False
      False
      0.002888
      0.002728
      0.155241
      0.149630
      0.004866
      0.005772
      0.441455
      0.424451
      0.003306
      0.003125
      0.298761
      0.302429
      1760
      1730.0
      False
      False
      False
      3560
      Temple
      -0.214516
      NaN
      -0.214516
      0.430455
      0.430545
      0
      0
      14
      20
      0
      None
      NaN
      NaN
      0.214516
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.569545
      0.569455
      SEC
      Vanderbilt
      0
      0
      3.0
      12.0
      7.0
      2.0
      3.0
      0
      1
      63
      4
      4.005476e+09
      1
      1
      0
      3
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      -1.187259
      -0.972742
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      3
      1
      29
      3
      Vanderbilt
      0.214516
      NaN
      NaN
      0.569545
      0.569455
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      P.J. Walker pass complete to Jalen Fitzpatrick...
      TEMPLE Penalty, False Start (5 Yards) to the T...
      Pass Reception
      Penalty
      Kickoff Return (Offense)
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Pass Reception
      Temple
      2.484907
      1.945910
      False
      False
      -3.467607
      -0.484325
      -0.214516
      3.467607
      0.484325
      0.214516
      0
      101857901
      0.0
      1
      0.0
      3.0
      American Athletic
      Temple
      0
      0
      0
      3.0
      Vanderbilt
      0.0
      1
      Rush
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Kenneth Harper run for 5 yds to the Temp 22
      Rush
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      RB
      None
      None
      None
      None
      0.024724
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      1.0
      None
      NaN
      NaN
      4
      1
      Kenneth Harper
      513403.0
      0
      5.0
      Kenneth Harper
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      -1.733803
      -0.484325
      -0.214516
      1.733803
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.430455
      0.430545
      -0.000090
      83
      5
      83
      78.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      5.0
      NaN
      2014

      4
      2.529815
      -1.187259
      -0.000336
      0.158063
      0.093482
      False
      False
      0.002756
      0.002888
      0.097974
      0.155241
      0.002650
      0.004866
      0.284786
      0.441455
      0.003061
      0.003306
      0.450710
      0.298761
      1730
      1705.0
      False
      False
      False
      3530
      Temple
      2.529815
      2.529815
      NaN
      0.537439
      0.430455
      0
      0
      13
      50
      1
      None
      NaN
      NaN
      -2.529815
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.462561
      0.569545
      SEC
      Vanderbilt
      0
      0
      3.0
      7.0
      10.0
      3.0
      1.0
      0
      1
      63
      5
      4.005476e+09
      1
      1
      0
      4
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      1.342556
      -1.187259
      1.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      1.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      4
      1
      28
      4
      Vanderbilt
      -2.529815
      NaN
      NaN
      0.462561
      0.569545
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Kenneth Harper run for 5 yds to the Temp 22
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Rush
      Pass Reception
      Penalty
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      P.J. Walker pass complete to Nate Hairston for...
      Pass Reception
      Temple
      1.945910
      2.302585
      False
      False
      1.592023
      2.045490
      -0.214516
      -1.592023
      -2.045490
      0.214516
      0
      101864901
      0.0
      1
      0.0
      3.0
      American Athletic
      Temple
      0
      0
      0
      3.0
      Vanderbilt
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      P.J. Walker
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Pass Reception
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      1.385952
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Jalen Fitzpatrick
      1.0
      Jalen Fitzpatrick
      513398.0
      8.0
      5
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      1.0
      1
      None
      NaN
      NaN
      0
      0.0
      0.796012
      2.045490
      -0.214516
      -0.796012
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.537439
      0.430455
      0.106984
      78
      8
      78
      70.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      8.0
      NaN
      NaN
      2014

```python
game_data = pd.DataFrame()
spread_data = pd.DataFrame()

# downloaded files from collegefootballdata.com
def retrieveCfbDataFile(endpoint, year):
    return pd.read_csv(f"data/{endpoint}/{year}.csv", encoding='latin-1')

for i in range(2014, 2020):
    gm = retrieveCfbDataFile('games',i)
    gm['game_id'] = gm['id']
    gm['year'] = i
    gm['winner'] = np.where(gm.home_points > gm.away_points, gm.home_team, gm.away_team)
    game_data = game_data.append(gm, sort=False)

    bets = retrieveCfbDataFile('lines', i)
    bets = bets[bets.lineProvider == "consensus"]
    bets['game_id'] = bets['id']
    bets['year'] = i
    bets['spread'] = -1 * bets.spread # spread is negative for home favorite; positive for away favorite, but NFLfastR uses "(how many points home team was favored by) for this"
    spread_data = spread_data.append(bets, sort=False)

print(f"Total Games: {len(game_data)}")
print(f"Total Spreads: {len(spread_data)}")
```

    Total Games: 5018
    Total Spreads: 4775

```python
pbp_data = pd.merge(pbp_data, game_data[['game_id','winner']], left_on="game_id", right_on="game_id")
pbp_data = pbp_data[pbp_data.game_id != 400603838]
pbp_data.head()
```

      EPA
      ExpScoreDiff
      ExpScoreDiff_Time_Ratio
      FG_after
      FG_before
      Goal_To_Go
      Goal_To_Go_end
      No_Score_after
      No_Score_before
      Opp_FG_after
      Opp_FG_before
      Opp_Safety_after
      Opp_Safety_before
      Opp_TD_after
      Opp_TD_before
      Safety_after
      Safety_before
      TD_after
      TD_before
      TimeSecsRem
      TimeSecsRem_end
      Under_three
      Under_two
      Under_two_end
      adj_TimeSecsRem
      away
      away_EPA
      away_EPA_pass
      away_EPA_rush
      away_wp_after
      away_wp_before
      change_of_pos_team
      change_of_poss
      clock.minutes
      clock.seconds
      completion
      completion_player
      completion_player_id
      completion_yds
      def_EPA
      def_pos_team
      def_pos_team_score
      def_pos_team_timeouts
      def_pos_team_timeouts_rem_before
      def_timeout_called
      def_timeouts_rem_before
      def_wp_after
      def_wp_before
      defense_conference
      defense_play
      defense_score
      defense_score_play
      defense_timeouts
      distance
      distance_end
      down
      down_end
      downs_turnover
      drive_end_period
      drive_end_yards_to_goal
      drive_event_number
      drive_id
      drive_num
      drive_number
      drive_numbers
      drive_play_number
      drive_pts
      drive_result
      drive_result2
      drive_result_detailed
      drive_result_detailed_flag
      drive_scoring
      drive_start_period
      drive_start_yards_to_goal
      drive_time_minutes_elapsed
      drive_time_minutes_end
      drive_time_minutes_start
      drive_time_seconds_elapsed
      drive_time_seconds_end
      drive_time_seconds_start
      drive_yards
      end_of_half
      ep_after
      ep_before
      epa_success
      fg_block_player_name
      fg_inds
      fg_kicker_player_name
      fg_made
      fg_make_prob
      fg_return_player_name
      firstD_by_kickoff
      firstD_by_penalty
      firstD_by_poss
      firstD_by_yards
      first_by_penalty
      first_by_yards
      fumble_forced_player
      fumble_forced_player_id
      fumble_forced_player_name
      fumble_forced_stat
      fumble_player
      fumble_player_id
      fumble_player_name
      fumble_recovered_player
      fumble_recovered_player_id
      fumble_recovered_player_name
      fumble_recovered_stat
      fumble_stat
      fumble_vec
      game_id
      game_play_number
      half
      half_clock.minutes
      half_play_number
      home
      home_EPA
      home_EPA_pass
      home_EPA_rush
      home_wp_after
      home_wp_before
      id_drive
      id_play
      incompletion_player
      incompletion_player_id
      incompletion_stat
      int
      int_td
      interception_player
      interception_player_id
      interception_player_name
      interception_stat
      interception_thrown_player
      interception_thrown_player_id
      interception_thrown_stat
      kick_play
      kickoff_downed
      kickoff_fair_catch
      kickoff_onside
      kickoff_oob
      kickoff_play
      kickoff_player_name
      kickoff_returner_player_name
      kickoff_safety
      kickoff_tb
      lag_change_of_pos_team
      lag_change_of_pos_team2
      lag_change_of_poss
      lag_defense_score_play
      lag_downs_turnover
      lag_drive_result_detailed
      lag_first_by_penalty
      lag_first_by_penalty2
      lag_first_by_yards
      lag_first_by_yards2
      lag_kickoff_play
      lag_new_drive_pts
      lag_play_text
      lag_play_text2
      lag_play_type
      lag_play_type2
      lag_play_type3
      lag_pos_team
      lag_punt
      lag_punt2
      lag_scoring_play
      lag_turnover_vec
      lead_drive_result_detailed
      lead_play_text
      lead_play_type
      lead_pos_team
      log_ydstogo
      log_ydstogo_end
      middle_8
      missing_yard_flag
      net_away_EPA
      net_away_EPA_pass
      net_away_EPA_rush
      net_home_EPA
      net_home_EPA_pass
      net_home_EPA_rush
      new_drive_pts
      new_id
      new_series
      number_of_drives
      off_timeout_called
      off_timeouts_rem_before
      offense_conference
      offense_play
      offense_receives_2H_kickoff
      offense_score
      offense_score_play
      offense_timeouts
      opponent
      opponent_score
      orig_drive_number
      orig_play_type
      pass
      pass_attempt
      pass_breakup_player
      pass_breakup_player_id
      pass_breakup_player_name
      pass_breakup_stat
      pass_td
      passer_player_name
      penalty_1st_conv
      penalty_declined
      penalty_detail
      penalty_flag
      penalty_no_play
      penalty_offset
      penalty_play_text
      penalty_safety
      penalty_text
      period
      play_after_turnover
      play_id
      play_text
      play_type
      pos_score_diff
      pos_score_diff_start
      pos_score_diff_start_end
      pos_score_pts
      pos_team
      pos_team_receives_2H_kickoff
      pos_team_score
      pos_team_timeouts
      pos_team_timeouts_rem_before
      position_completion
      position_fumble
      position_fumble_forced
      position_fumble_recovered
      position_incompletion
      position_interception
      position_interception_thrown
      position_pass_breakup
      position_reception
      position_rush
      position_sack
      position_sack_taken
      position_target
      position_touchdown
      ppa
      pts_scored
      punt
      punt_block_player_name
      punt_block_return_player_name
      punt_blocked
      punt_downed
      punt_fair_catch
      punt_oob
      punt_play
      punt_returner_player_name
      punt_safety
      punt_tb
      punter_player_name
      receiver_player_name
      receives_2H_kickoff
      reception_player
      reception_player_id
      reception_yds
      row
      rush
      rush_player
      rush_player_id
      rush_td
      rush_yds
      rusher_player_name
      rz_play
      sack
      sack_player
      sack_player_id
      sack_player_name
      sack_player_name2
      sack_players
      sack_stat
      sack_taken_player
      sack_taken_player_id
      sack_taken_stat
      sack_vec
      safety
      score_diff
      score_diff_start
      score_pts
      scoring
      scoring_opp
      scoring_play
      season
      stuffed_run
      success
      target
      target_player
      target_player_id
      target_stat
      td_play
      team_score
      total_away_EPA
      total_away_EPA_pass
      total_away_EPA_rush
      total_home_EPA
      total_home_EPA_pass
      total_home_EPA_rush
      touchdown
      touchdown_player
      touchdown_player_id
      touchdown_stat
      turnover
      turnover_indicator
      turnover_vec
      turnover_vec_lag
      week
      wp_after
      wp_before
      wpa
      yard_line
      yards_gained
      yards_to_goal
      yards_to_goal_end
      yds_fg
      yds_fumble_return
      yds_int_return
      yds_kickoff
      yds_kickoff_return
      yds_penalty
      yds_punt_gained
      yds_punt_return
      yds_punted
      yds_receiving
      yds_rushed
      yds_sacked
      year
      winner

      0
      -0.565384
      0.835848
      0.000232
      0.132497
      0.170311
      False
      False
      0.002218
      0.001810
      0.123708
      0.089125
      0.004623
      0.001920
      0.349311
      0.260266
      0.002997
      0.002954
      0.384646
      0.473614
      1795
      1795.0
      False
      False
      False
      3595
      Temple
      -0.565384
      NaN
      NaN
      0.469500
      0.491924
      0
      1
      14
      55
      0
      None
      NaN
      NaN
      0.565384
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.530500
      0.508076
      American Athletic
      Temple
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      63
      1
      4.005476e+09
      1
      1
      1
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      0.270464
      0.835848
      0.0
      None
      0.0
      None
      False
      NaN
      None
      1.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      1
      1
      29
      1
      Vanderbilt
      0.565384
      NaN
      NaN
      0.530500
      0.508076
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      1
      0
      0
      0
      0
      1
      Hayden Lekacz
      Khalif Herbin
      0.0
      0
      0.0
      0.0
      0.0
      NaN
      0.0
      None
      0
      NaN
      0.0
      NaN
      0.0
      NaN
      None
      None
      None
      None
      None
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      TEMPLE Penalty, False Start (5 Yards) to the T...
      Penalty
      Temple
      2.302585
      2.302585
      False
      False
      -1.130768
      0.000000
      0.000000
      1.130768
      0.000000
      0.000000
      0
      101854401
      1.0
      1
      0.0
      3.0
      SEC
      Vanderbilt
      1
      0
      0
      3.0
      None
      NaN
      1
      Kickoff Return (Offense)
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      NaN
      None
      Hayden Lekacz kickoff for 64 yds , Khalif Herb...
      Kickoff Return (Offense)
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      1.0
      None
      NaN
      NaN
      1
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      1.0
      0
      None
      NaN
      NaN
      0
      NaN
      -0.565384
      0.000000
      0.000000
      0.565384
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      NaN
      1
      0.469500
      0.491924
      -0.022424
      35
      18
      65
      81.0
      NaN
      NaN
      NaN
      64.0
      18.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      Temple

      1
      -0.469578
      0.270464
      0.000075
      0.120739
      0.132497
      False
      False
      0.002423
      0.002218
      0.134912
      0.123708
      0.006027
      0.004623
      0.377211
      0.349311
      0.002977
      0.002997
      0.355712
      0.384646
      1795
      1785.0
      False
      False
      False
      3595
      Temple
      -0.469578
      NaN
      NaN
      0.442379
      0.469500
      0
      0
      14
      55
      0
      None
      NaN
      NaN
      0.469578
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.557621
      0.530500
      SEC
      Vanderbilt
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      63
      2
      4.005476e+09
      1
      1
      0
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      -0.199114
      0.270464
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      1
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      1
      1
      29
      1
      Vanderbilt
      0.469578
      NaN
      NaN
      0.557621
      0.530500
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Punt
      0
      NaN
      0.0
      NaN
      1.0
      0.0
      Hayden Lekacz kickoff for 64 yds , Khalif Herb...
      None
      Kickoff Return (Offense)
      None
      None
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Pass Reception
      Temple
      2.302585
      2.302585
      False
      False
      -2.069924
      0.000000
      0.000000
      2.069924
      0.000000
      0.000000
      0
      101854402
      0.0
      1
      0.0
      3.0
      American Athletic
      Temple
      0
      0
      0
      3.0
      None
      NaN
      1
      Penalty
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      False Start
      True
      False
      False
      Penalty, False Start (5 Yards) to the Temp 14
      0
      False
      1
      0.0
      None
      TEMPLE Penalty, False Start (5 Yards) to the T...
      Penalty
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      1.0
      None
      NaN
      NaN
      2
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      0.0
      0
      None
      NaN
      NaN
      0
      NaN
      -1.034962
      0.000000
      0.000000
      1.034962
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.442379
      0.469500
      -0.027121
      81
      -5
      81
      86.0
      NaN
      NaN
      NaN
      NaN
      NaN
      -5.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      Temple

      2
      -0.484325
      -0.488417
      -0.000136
      0.111865
      0.139679
      False
      False
      0.002728
      0.002383
      0.149630
      0.134811
      0.005772
      0.006593
      0.424451
      0.392052
      0.003125
      0.003371
      0.302429
      0.321112
      1785
      1760.0
      False
      False
      False
      3585
      Temple
      -0.484325
      -0.484325
      NaN
      0.430545
      0.442379
      0
      0
      14
      45
      1
      None
      NaN
      NaN
      0.484325
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.569455
      0.557621
      SEC
      Vanderbilt
      0
      0
      3.0
      15.0
      12.0
      1.0
      2.0
      0
      1
      63
      3
      4.005476e+09
      1
      1
      0
      2
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      -0.972742
      -0.488417
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      2
      1
      29
      2
      Vanderbilt
      0.484325
      NaN
      NaN
      0.569455
      0.557621
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      TEMPLE Penalty, False Start (5 Yards) to the T...
      Hayden Lekacz kickoff for 64 yds , Khalif Herb...
      Penalty
      Kickoff Return (Offense)
      None
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      Kenneth Harper run for 5 yds to the Temp 22
      Rush
      Temple
      2.708050
      2.484907
      False
      False
      -3.038574
      -0.484325
      0.000000
      3.038574
      0.484325
      0.000000
      0
      101855401
      0.0
      1
      0.0
      3.0
      American Athletic
      Temple
      0
      0
      0
      3.0
      Vanderbilt
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      P.J. Walker
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Pass Reception
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      -0.100269
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Jalen Fitzpatrick
      1.0
      Jalen Fitzpatrick
      513398.0
      3.0
      3
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      None
      NaN
      NaN
      0
      0.0
      -1.519287
      -0.484325
      0.000000
      1.519287
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.430545
      0.442379
      -0.011835
      86
      3
      86
      83.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      3.0
      NaN
      NaN
      2014
      Temple

      3
      -0.214516
      -0.972742
      -0.000273
      0.093482
      0.111865
      False
      False
      0.002888
      0.002728
      0.155241
      0.149630
      0.004866
      0.005772
      0.441455
      0.424451
      0.003306
      0.003125
      0.298761
      0.302429
      1760
      1730.0
      False
      False
      False
      3560
      Temple
      -0.214516
      NaN
      -0.214516
      0.430455
      0.430545
      0
      0
      14
      20
      0
      None
      NaN
      NaN
      0.214516
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.569545
      0.569455
      SEC
      Vanderbilt
      0
      0
      3.0
      12.0
      7.0
      2.0
      3.0
      0
      1
      63
      4
      4.005476e+09
      1
      1
      0
      3
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      -1.187259
      -0.972742
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      3
      1
      29
      3
      Vanderbilt
      0.214516
      NaN
      NaN
      0.569545
      0.569455
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      P.J. Walker pass complete to Jalen Fitzpatrick...
      TEMPLE Penalty, False Start (5 Yards) to the T...
      Pass Reception
      Penalty
      Kickoff Return (Offense)
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Pass Reception
      Temple
      2.484907
      1.945910
      False
      False
      -3.467607
      -0.484325
      -0.214516
      3.467607
      0.484325
      0.214516
      0
      101857901
      0.0
      1
      0.0
      3.0
      American Athletic
      Temple
      0
      0
      0
      3.0
      Vanderbilt
      0.0
      1
      Rush
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Kenneth Harper run for 5 yds to the Temp 22
      Rush
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      RB
      None
      None
      None
      None
      0.024724
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      1.0
      None
      NaN
      NaN
      4
      1
      Kenneth Harper
      513403.0
      0
      5.0
      Kenneth Harper
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      -1.733803
      -0.484325
      -0.214516
      1.733803
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.430455
      0.430545
      -0.000090
      83
      5
      83
      78.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      5.0
      NaN
      2014
      Temple

      4
      2.529815
      -1.187259
      -0.000336
      0.158063
      0.093482
      False
      False
      0.002756
      0.002888
      0.097974
      0.155241
      0.002650
      0.004866
      0.284786
      0.441455
      0.003061
      0.003306
      0.450710
      0.298761
      1730
      1705.0
      False
      False
      False
      3530
      Temple
      2.529815
      2.529815
      NaN
      0.537439
      0.430455
      0
      0
      13
      50
      1
      None
      NaN
      NaN
      -2.529815
      Vanderbilt
      0
      3.0
      3.0
      0.0
      3.0
      0.462561
      0.569545
      SEC
      Vanderbilt
      0
      0
      3.0
      7.0
      10.0
      3.0
      1.0
      0
      1
      63
      5
      4.005476e+09
      1
      1
      0
      4
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      35
      2
      12
      15
      53
      7
      0
      18
      0
      1.342556
      -1.187259
      1.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      1.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547640
      4
      1
      28
      4
      Vanderbilt
      -2.529815
      NaN
      NaN
      0.462561
      0.569545
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Kenneth Harper run for 5 yds to the Temp 22
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Rush
      Pass Reception
      Penalty
      Temple
      0.0
      0.0
      0.0
      0.0
      Punt
      P.J. Walker pass complete to Nate Hairston for...
      Pass Reception
      Temple
      1.945910
      2.302585
      False
      False
      1.592023
      2.045490
      -0.214516
      -1.592023
      -2.045490
      0.214516
      0
      101864901
      0.0
      1
      0.0
      3.0
      American Athletic
      Temple
      0
      0
      0
      3.0
      Vanderbilt
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      P.J. Walker
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      P.J. Walker pass complete to Jalen Fitzpatrick...
      Pass Reception
      0
      0
      0.0
      0.0
      Temple
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      1.385952
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Jalen Fitzpatrick
      1.0
      Jalen Fitzpatrick
      513398.0
      8.0
      5
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      1.0
      1
      None
      NaN
      NaN
      0
      0.0
      0.796012
      2.045490
      -0.214516
      -0.796012
      0.0
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.537439
      0.430455
      0.106984
      78
      8
      78
      70.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      8.0
      NaN
      NaN
      2014
      Temple

```python
pbp_data = pd.merge(pbp_data, spread_data[['game_id','spread']], left_on="game_id", right_on="game_id")
pbp_data.head()
```

      EPA
      ExpScoreDiff
      ExpScoreDiff_Time_Ratio
      FG_after
      FG_before
      Goal_To_Go
      Goal_To_Go_end
      No_Score_after
      No_Score_before
      Opp_FG_after
      Opp_FG_before
      Opp_Safety_after
      Opp_Safety_before
      Opp_TD_after
      Opp_TD_before
      Safety_after
      Safety_before
      TD_after
      TD_before
      TimeSecsRem
      TimeSecsRem_end
      Under_three
      Under_two
      Under_two_end
      adj_TimeSecsRem
      away
      away_EPA
      away_EPA_pass
      away_EPA_rush
      away_wp_after
      away_wp_before
      change_of_pos_team
      change_of_poss
      clock.minutes
      clock.seconds
      completion
      completion_player
      completion_player_id
      completion_yds
      def_EPA
      def_pos_team
      def_pos_team_score
      def_pos_team_timeouts
      def_pos_team_timeouts_rem_before
      def_timeout_called
      def_timeouts_rem_before
      def_wp_after
      def_wp_before
      defense_conference
      defense_play
      defense_score
      defense_score_play
      defense_timeouts
      distance
      distance_end
      down
      down_end
      downs_turnover
      drive_end_period
      drive_end_yards_to_goal
      drive_event_number
      drive_id
      drive_num
      drive_number
      drive_numbers
      drive_play_number
      drive_pts
      drive_result
      drive_result2
      drive_result_detailed
      drive_result_detailed_flag
      drive_scoring
      drive_start_period
      drive_start_yards_to_goal
      drive_time_minutes_elapsed
      drive_time_minutes_end
      drive_time_minutes_start
      drive_time_seconds_elapsed
      drive_time_seconds_end
      drive_time_seconds_start
      drive_yards
      end_of_half
      ep_after
      ep_before
      epa_success
      fg_block_player_name
      fg_inds
      fg_kicker_player_name
      fg_made
      fg_make_prob
      fg_return_player_name
      firstD_by_kickoff
      firstD_by_penalty
      firstD_by_poss
      firstD_by_yards
      first_by_penalty
      first_by_yards
      fumble_forced_player
      fumble_forced_player_id
      fumble_forced_player_name
      fumble_forced_stat
      fumble_player
      fumble_player_id
      fumble_player_name
      fumble_recovered_player
      fumble_recovered_player_id
      fumble_recovered_player_name
      fumble_recovered_stat
      fumble_stat
      fumble_vec
      game_id
      game_play_number
      half
      half_clock.minutes
      half_play_number
      home
      home_EPA
      home_EPA_pass
      home_EPA_rush
      home_wp_after
      home_wp_before
      id_drive
      id_play
      incompletion_player
      incompletion_player_id
      incompletion_stat
      int
      int_td
      interception_player
      interception_player_id
      interception_player_name
      interception_stat
      interception_thrown_player
      interception_thrown_player_id
      interception_thrown_stat
      kick_play
      kickoff_downed
      kickoff_fair_catch
      kickoff_onside
      kickoff_oob
      kickoff_play
      kickoff_player_name
      kickoff_returner_player_name
      kickoff_safety
      kickoff_tb
      lag_change_of_pos_team
      lag_change_of_pos_team2
      lag_change_of_poss
      lag_defense_score_play
      lag_downs_turnover
      lag_drive_result_detailed
      lag_first_by_penalty
      lag_first_by_penalty2
      lag_first_by_yards
      lag_first_by_yards2
      lag_kickoff_play
      lag_new_drive_pts
      lag_play_text
      lag_play_text2
      lag_play_type
      lag_play_type2
      lag_play_type3
      lag_pos_team
      lag_punt
      lag_punt2
      lag_scoring_play
      lag_turnover_vec
      lead_drive_result_detailed
      lead_play_text
      lead_play_type
      lead_pos_team
      log_ydstogo
      log_ydstogo_end
      middle_8
      missing_yard_flag
      net_away_EPA
      net_away_EPA_pass
      net_away_EPA_rush
      net_home_EPA
      net_home_EPA_pass
      net_home_EPA_rush
      new_drive_pts
      new_id
      new_series
      number_of_drives
      off_timeout_called
      off_timeouts_rem_before
      offense_conference
      offense_play
      offense_receives_2H_kickoff
      offense_score
      offense_score_play
      offense_timeouts
      opponent
      opponent_score
      orig_drive_number
      orig_play_type
      pass
      pass_attempt
      pass_breakup_player
      pass_breakup_player_id
      pass_breakup_player_name
      pass_breakup_stat
      pass_td
      passer_player_name
      penalty_1st_conv
      penalty_declined
      penalty_detail
      penalty_flag
      penalty_no_play
      penalty_offset
      penalty_play_text
      penalty_safety
      penalty_text
      period
      play_after_turnover
      play_id
      play_text
      play_type
      pos_score_diff
      pos_score_diff_start
      pos_score_diff_start_end
      pos_score_pts
      pos_team
      pos_team_receives_2H_kickoff
      pos_team_score
      pos_team_timeouts
      pos_team_timeouts_rem_before
      position_completion
      position_fumble
      position_fumble_forced
      position_fumble_recovered
      position_incompletion
      position_interception
      position_interception_thrown
      position_pass_breakup
      position_reception
      position_rush
      position_sack
      position_sack_taken
      position_target
      position_touchdown
      ppa
      pts_scored
      punt
      punt_block_player_name
      punt_block_return_player_name
      punt_blocked
      punt_downed
      punt_fair_catch
      punt_oob
      punt_play
      punt_returner_player_name
      punt_safety
      punt_tb
      punter_player_name
      receiver_player_name
      receives_2H_kickoff
      reception_player
      reception_player_id
      reception_yds
      row
      rush
      rush_player
      rush_player_id
      rush_td
      rush_yds
      rusher_player_name
      rz_play
      sack
      sack_player
      sack_player_id
      sack_player_name
      sack_player_name2
      sack_players
      sack_stat
      sack_taken_player
      sack_taken_player_id
      sack_taken_stat
      sack_vec
      safety
      score_diff
      score_diff_start
      score_pts
      scoring
      scoring_opp
      scoring_play
      season
      stuffed_run
      success
      target
      target_player
      target_player_id
      target_stat
      td_play
      team_score
      total_away_EPA
      total_away_EPA_pass
      total_away_EPA_rush
      total_home_EPA
      total_home_EPA_pass
      total_home_EPA_rush
      touchdown
      touchdown_player
      touchdown_player_id
      touchdown_stat
      turnover
      turnover_indicator
      turnover_vec
      turnover_vec_lag
      week
      wp_after
      wp_before
      wpa
      yard_line
      yards_gained
      yards_to_goal
      yards_to_goal_end
      yds_fg
      yds_fumble_return
      yds_int_return
      yds_kickoff
      yds_kickoff_return
      yds_penalty
      yds_punt_gained
      yds_punt_return
      yds_punted
      yds_receiving
      yds_rushed
      yds_sacked
      year
      winner
      spread

      0
      -0.470573
      0.833168
      0.000231
      0.134882
      0.170347
      False
      False
      0.002152
      0.001775
      0.121537
      0.089202
      0.004375
      0.001915
      0.343792
      0.260404
      0.002997
      0.002950
      0.390266
      0.473408
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.470573
      NaN
      NaN
      0.528336
      0.509680
      0
      1
      15
      0
      0
      None
      NaN
      NaN
      0.470573
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.528336
      0.509680
      American Athletic
      East Carolina
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      66
      1
      4.005476e+09
      1
      1
      1
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.362595
      0.833168
      0.0
      None
      0.0
      None
      False
      NaN
      None
      1.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      1
      1
      30
      1
      East Carolina
      -0.470573
      NaN
      NaN
      0.471664
      0.490320
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      1
      0
      0
      0
      0
      1
      Brandon McLaren
      Isaiah Jones
      0.0
      0
      0.0
      0.0
      0.0
      NaN
      0.0
      None
      0
      NaN
      0.0
      NaN
      0.0
      NaN
      None
      None
      None
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      East Carolina
      2.302585
      2.302585
      False
      False
      0.941145
      0.000000
      0.0
      -0.941145
      0.000000
      0.0
      0
      101849902
      1.0
      1
      0.0
      3.0
      None
      North Carolina Central
      1
      0
      0
      3.0
      None
      NaN
      1
      Kickoff
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      NaN
      None
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Kickoff
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      0.0
      None
      NaN
      NaN
      1
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      1.0
      0
      None
      NaN
      NaN
      0
      NaN
      0.470573
      0.0
      0.0
      -0.470573
      0.000000
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      NaN
      1
      0.471664
      0.490320
      -0.018655
      65
      6
      65
      80.0
      NaN
      NaN
      NaN
      51.0
      6.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0

      1
      -0.168094
      0.362595
      0.000101
      0.128390
      0.134882
      False
      False
      0.002141
      0.002152
      0.124954
      0.121537
      0.003679
      0.004375
      0.355615
      0.343792
      0.003138
      0.002997
      0.382083
      0.390266
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.168094
      NaN
      NaN
      0.535004
      0.528336
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      4.0
      0.168094
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.535004
      0.528336
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      6.0
      1.0
      2.0
      0
      1
      66
      2
      4.005476e+09
      1
      1
      0
      2
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.194501
      0.362595
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      1
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      2
      1
      30
      2
      East Carolina
      -0.168094
      -0.168094
      NaN
      0.464996
      0.471664
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Punt
      0
      NaN
      0.0
      NaN
      1.0
      0.0
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      None
      Kickoff
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      East Carolina
      2.302585
      1.791759
      False
      False
      1.277333
      0.168094
      0.0
      -1.277333
      -0.168094
      0.0
      0
      101849903
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      -0.088432
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      Justin Hardy
      505407.0
      4.0
      2
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      None
      NaN
      NaN
      0
      0.0
      0.638667
      0.0
      0.0
      -0.638667
      -0.168094
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.464996
      0.471664
      -0.006668
      20
      4
      80
      76.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      4.0
      NaN
      NaN
      2014
      East Carolina
      39.0

      2
      2.283941
      0.194501
      0.000054
      0.190673
      0.128390
      False
      False
      0.001539
      0.002141
      0.072094
      0.124954
      0.001135
      0.003679
      0.214480
      0.355615
      0.002843
      0.003138
      0.517235
      0.382083
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      -2.283941
      NaN
      NaN
      0.445405
      0.535004
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      20.0
      -2.283941
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.445405
      0.535004
      None
      North Carolina Central
      0
      0
      3.0
      6.0
      10.0
      2.0
      1.0
      0
      1
      66
      3
      4.005476e+09
      1
      1
      0
      3
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      2.478443
      0.194501
      1.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      1.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      3
      1
      30
      3
      East Carolina
      2.283941
      2.283941
      NaN
      0.554595
      0.464996
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Justin Hardy for...
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Pass Reception
      Kickoff
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      East Carolina
      1.791759
      2.302585
      False
      False
      -3.290549
      -2.115847
      0.0
      3.290549
      2.115847
      0.0
      0
      101849904
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      2.104307
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Cam Worthy
      0.0
      Cam Worthy
      552953.0
      20.0
      3
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      1.0
      1
      None
      NaN
      NaN
      0
      0.0
      -1.645275
      0.0
      0.0
      1.645275
      2.115847
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.554595
      0.464996
      0.089599
      24
      20
      76
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      20.0
      NaN
      NaN
      2014
      East Carolina
      39.0

      3
      -0.855503
      2.478443
      0.000688
      0.193531
      0.190673
      False
      False
      0.001703
      0.001539
      0.087026
      0.072094
      0.001516
      0.001135
      0.263697
      0.214480
      0.003072
      0.002843
      0.449456
      0.517235
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.855503
      NaN
      NaN
      0.478562
      0.445405
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      0.855503
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.478562
      0.445405
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      1.0
      2.0
      0
      1
      66
      4
      4.005476e+09
      1
      1
      0
      4
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      1.622940
      2.478443
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      1.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      4
      1
      30
      4
      East Carolina
      -0.855503
      -0.855503
      NaN
      0.521438
      0.554595
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      1.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Cam Worthy for 2...
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      Pass Reception
      Kickoff
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      East Carolina
      2.302585
      2.302585
      False
      False
      -1.579543
      -1.260344
      0.0
      1.579543
      1.260344
      0.0
      0
      101849905
      1.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      East Carolina
      0.0
      1
      Pass Incompletion
      1
      1
      Michael Jones
      164873.0
      Michael Jones
      1.0
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -1.161247
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      None
      NaN
      NaN
      4
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Justin Hardy
      505407.0
      1.0
      0
      0.0
      -0.789771
      0.0
      0.0
      0.789771
      1.260344
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.521438
      0.554595
      -0.033156
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0

      4
      -1.130810
      1.622940
      0.000451
      0.185681
      0.193531
      False
      False
      0.001837
      0.001703
      0.109427
      0.087026
      0.002270
      0.001516
      0.329919
      0.263697
      0.003745
      0.003072
      0.367121
      0.449456
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      1.130810
      NaN
      NaN
      0.523197
      0.478562
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      1.130810
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.523197
      0.478562
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      2.0
      3.0
      0
      1
      66
      5
      4.005476e+09
      1
      1
      0
      5
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.492129
      1.622940
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      5
      1
      30
      5
      East Carolina
      -1.130810
      -1.130810
      NaN
      0.476803
      0.521438
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Shane Carden pass incomplete to Justin Hardy, ...
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Incompletion
      Pass Reception
      Pass Reception
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      EAST CAROLINA Penalty, false start (-5 Yards) ...
      Penalty
      East Carolina
      2.302585
      2.302585
      False
      False
      0.682078
      -0.129534
      0.0
      -0.682078
      0.129534
      0.0
      0
      101849906
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Incompletion
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -0.881290
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Davon Grayson
      0.0
      None
      NaN
      NaN
      5
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Davon Grayson
      552937.0
      1.0
      0
      0.0
      0.341039
      0.0
      0.0
      -0.341039
      0.129534
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.476803
      0.521438
      -0.044636
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0

```python
pbp_data['pos_team_spread'] = np.where(pbp_data.pos_team == pbp_data.home, pbp_data.spread, -1 * pbp_data.spread)
pbp_data['elapsed_share'] = (3600 - pbp_data.adj_TimeSecsRem) / 3600
pbp_data['spread_time'] = pbp_data.pos_team_spread * np.exp(-4 * pbp_data.elapsed_share)
pbp_data['is_home'] = np.where(pbp_data.pos_team == pbp_data.home, 1, 0)
pbp_data.head()
```

      EPA
      ExpScoreDiff
      ExpScoreDiff_Time_Ratio
      FG_after
      FG_before
      Goal_To_Go
      Goal_To_Go_end
      No_Score_after
      No_Score_before
      Opp_FG_after
      Opp_FG_before
      Opp_Safety_after
      Opp_Safety_before
      Opp_TD_after
      Opp_TD_before
      Safety_after
      Safety_before
      TD_after
      TD_before
      TimeSecsRem
      TimeSecsRem_end
      Under_three
      Under_two
      Under_two_end
      adj_TimeSecsRem
      away
      away_EPA
      away_EPA_pass
      away_EPA_rush
      away_wp_after
      away_wp_before
      change_of_pos_team
      change_of_poss
      clock.minutes
      clock.seconds
      completion
      completion_player
      completion_player_id
      completion_yds
      def_EPA
      def_pos_team
      def_pos_team_score
      def_pos_team_timeouts
      def_pos_team_timeouts_rem_before
      def_timeout_called
      def_timeouts_rem_before
      def_wp_after
      def_wp_before
      defense_conference
      defense_play
      defense_score
      defense_score_play
      defense_timeouts
      distance
      distance_end
      down
      down_end
      downs_turnover
      drive_end_period
      drive_end_yards_to_goal
      drive_event_number
      drive_id
      drive_num
      drive_number
      drive_numbers
      drive_play_number
      drive_pts
      drive_result
      drive_result2
      drive_result_detailed
      drive_result_detailed_flag
      drive_scoring
      drive_start_period
      drive_start_yards_to_goal
      drive_time_minutes_elapsed
      drive_time_minutes_end
      drive_time_minutes_start
      drive_time_seconds_elapsed
      drive_time_seconds_end
      drive_time_seconds_start
      drive_yards
      end_of_half
      ep_after
      ep_before
      epa_success
      fg_block_player_name
      fg_inds
      fg_kicker_player_name
      fg_made
      fg_make_prob
      fg_return_player_name
      firstD_by_kickoff
      firstD_by_penalty
      firstD_by_poss
      firstD_by_yards
      first_by_penalty
      first_by_yards
      fumble_forced_player
      fumble_forced_player_id
      fumble_forced_player_name
      fumble_forced_stat
      fumble_player
      fumble_player_id
      fumble_player_name
      fumble_recovered_player
      fumble_recovered_player_id
      fumble_recovered_player_name
      fumble_recovered_stat
      fumble_stat
      fumble_vec
      game_id
      game_play_number
      half
      half_clock.minutes
      half_play_number
      home
      home_EPA
      home_EPA_pass
      home_EPA_rush
      home_wp_after
      home_wp_before
      id_drive
      id_play
      incompletion_player
      incompletion_player_id
      incompletion_stat
      int
      int_td
      interception_player
      interception_player_id
      interception_player_name
      interception_stat
      interception_thrown_player
      interception_thrown_player_id
      interception_thrown_stat
      kick_play
      kickoff_downed
      kickoff_fair_catch
      kickoff_onside
      kickoff_oob
      kickoff_play
      kickoff_player_name
      kickoff_returner_player_name
      kickoff_safety
      kickoff_tb
      lag_change_of_pos_team
      lag_change_of_pos_team2
      lag_change_of_poss
      lag_defense_score_play
      lag_downs_turnover
      lag_drive_result_detailed
      lag_first_by_penalty
      lag_first_by_penalty2
      lag_first_by_yards
      lag_first_by_yards2
      lag_kickoff_play
      lag_new_drive_pts
      lag_play_text
      lag_play_text2
      lag_play_type
      lag_play_type2
      lag_play_type3
      lag_pos_team
      lag_punt
      lag_punt2
      lag_scoring_play
      lag_turnover_vec
      lead_drive_result_detailed
      lead_play_text
      lead_play_type
      lead_pos_team
      log_ydstogo
      log_ydstogo_end
      middle_8
      missing_yard_flag
      net_away_EPA
      net_away_EPA_pass
      net_away_EPA_rush
      net_home_EPA
      net_home_EPA_pass
      net_home_EPA_rush
      new_drive_pts
      new_id
      new_series
      number_of_drives
      off_timeout_called
      off_timeouts_rem_before
      offense_conference
      offense_play
      offense_receives_2H_kickoff
      offense_score
      offense_score_play
      offense_timeouts
      opponent
      opponent_score
      orig_drive_number
      orig_play_type
      pass
      pass_attempt
      pass_breakup_player
      pass_breakup_player_id
      pass_breakup_player_name
      pass_breakup_stat
      pass_td
      passer_player_name
      penalty_1st_conv
      penalty_declined
      penalty_detail
      penalty_flag
      penalty_no_play
      penalty_offset
      penalty_play_text
      penalty_safety
      penalty_text
      period
      play_after_turnover
      play_id
      play_text
      play_type
      pos_score_diff
      pos_score_diff_start
      pos_score_diff_start_end
      pos_score_pts
      pos_team
      pos_team_receives_2H_kickoff
      pos_team_score
      pos_team_timeouts
      pos_team_timeouts_rem_before
      position_completion
      position_fumble
      position_fumble_forced
      position_fumble_recovered
      position_incompletion
      position_interception
      position_interception_thrown
      position_pass_breakup
      position_reception
      position_rush
      position_sack
      position_sack_taken
      position_target
      position_touchdown
      ppa
      pts_scored
      punt
      punt_block_player_name
      punt_block_return_player_name
      punt_blocked
      punt_downed
      punt_fair_catch
      punt_oob
      punt_play
      punt_returner_player_name
      punt_safety
      punt_tb
      punter_player_name
      receiver_player_name
      receives_2H_kickoff
      reception_player
      reception_player_id
      reception_yds
      row
      rush
      rush_player
      rush_player_id
      rush_td
      rush_yds
      rusher_player_name
      rz_play
      sack
      sack_player
      sack_player_id
      sack_player_name
      sack_player_name2
      sack_players
      sack_stat
      sack_taken_player
      sack_taken_player_id
      sack_taken_stat
      sack_vec
      safety
      score_diff
      score_diff_start
      score_pts
      scoring
      scoring_opp
      scoring_play
      season
      stuffed_run
      success
      target
      target_player
      target_player_id
      target_stat
      td_play
      team_score
      total_away_EPA
      total_away_EPA_pass
      total_away_EPA_rush
      total_home_EPA
      total_home_EPA_pass
      total_home_EPA_rush
      touchdown
      touchdown_player
      touchdown_player_id
      touchdown_stat
      turnover
      turnover_indicator
      turnover_vec
      turnover_vec_lag
      week
      wp_after
      wp_before
      wpa
      yard_line
      yards_gained
      yards_to_goal
      yards_to_goal_end
      yds_fg
      yds_fumble_return
      yds_int_return
      yds_kickoff
      yds_kickoff_return
      yds_penalty
      yds_punt_gained
      yds_punt_return
      yds_punted
      yds_receiving
      yds_rushed
      yds_sacked
      year
      winner
      spread
      pos_team_spread
      elapsed_share
      spread_time
      is_home

      0
      -0.470573
      0.833168
      0.000231
      0.134882
      0.170347
      False
      False
      0.002152
      0.001775
      0.121537
      0.089202
      0.004375
      0.001915
      0.343792
      0.260404
      0.002997
      0.002950
      0.390266
      0.473408
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.470573
      NaN
      NaN
      0.528336
      0.509680
      0
      1
      15
      0
      0
      None
      NaN
      NaN
      0.470573
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.528336
      0.509680
      American Athletic
      East Carolina
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      66
      1
      4.005476e+09
      1
      1
      1
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.362595
      0.833168
      0.0
      None
      0.0
      None
      False
      NaN
      None
      1.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      1
      1
      30
      1
      East Carolina
      -0.470573
      NaN
      NaN
      0.471664
      0.490320
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      1
      0
      0
      0
      0
      1
      Brandon McLaren
      Isaiah Jones
      0.0
      0
      0.0
      0.0
      0.0
      NaN
      0.0
      None
      0
      NaN
      0.0
      NaN
      0.0
      NaN
      None
      None
      None
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      East Carolina
      2.302585
      2.302585
      False
      False
      0.941145
      0.000000
      0.0
      -0.941145
      0.000000
      0.0
      0
      101849902
      1.0
      1
      0.0
      3.0
      None
      North Carolina Central
      1
      0
      0
      3.0
      None
      NaN
      1
      Kickoff
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      NaN
      None
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Kickoff
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      0.0
      None
      NaN
      NaN
      1
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      1.0
      0
      None
      NaN
      NaN
      0
      NaN
      0.470573
      0.0
      0.0
      -0.470573
      0.000000
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      NaN
      1
      0.471664
      0.490320
      -0.018655
      65
      6
      65
      80.0
      NaN
      NaN
      NaN
      51.0
      6.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1

      1
      -0.168094
      0.362595
      0.000101
      0.128390
      0.134882
      False
      False
      0.002141
      0.002152
      0.124954
      0.121537
      0.003679
      0.004375
      0.355615
      0.343792
      0.003138
      0.002997
      0.382083
      0.390266
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.168094
      NaN
      NaN
      0.535004
      0.528336
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      4.0
      0.168094
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.535004
      0.528336
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      6.0
      1.0
      2.0
      0
      1
      66
      2
      4.005476e+09
      1
      1
      0
      2
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.194501
      0.362595
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      1
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      2
      1
      30
      2
      East Carolina
      -0.168094
      -0.168094
      NaN
      0.464996
      0.471664
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Punt
      0
      NaN
      0.0
      NaN
      1.0
      0.0
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      None
      Kickoff
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      East Carolina
      2.302585
      1.791759
      False
      False
      1.277333
      0.168094
      0.0
      -1.277333
      -0.168094
      0.0
      0
      101849903
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      -0.088432
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      Justin Hardy
      505407.0
      4.0
      2
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      None
      NaN
      NaN
      0
      0.0
      0.638667
      0.0
      0.0
      -0.638667
      -0.168094
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.464996
      0.471664
      -0.006668
      20
      4
      80
      76.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      4.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1

      2
      2.283941
      0.194501
      0.000054
      0.190673
      0.128390
      False
      False
      0.001539
      0.002141
      0.072094
      0.124954
      0.001135
      0.003679
      0.214480
      0.355615
      0.002843
      0.003138
      0.517235
      0.382083
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      -2.283941
      NaN
      NaN
      0.445405
      0.535004
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      20.0
      -2.283941
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.445405
      0.535004
      None
      North Carolina Central
      0
      0
      3.0
      6.0
      10.0
      2.0
      1.0
      0
      1
      66
      3
      4.005476e+09
      1
      1
      0
      3
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      2.478443
      0.194501
      1.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      1.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      3
      1
      30
      3
      East Carolina
      2.283941
      2.283941
      NaN
      0.554595
      0.464996
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Justin Hardy for...
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Pass Reception
      Kickoff
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      East Carolina
      1.791759
      2.302585
      False
      False
      -3.290549
      -2.115847
      0.0
      3.290549
      2.115847
      0.0
      0
      101849904
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      2.104307
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Cam Worthy
      0.0
      Cam Worthy
      552953.0
      20.0
      3
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      1.0
      1
      None
      NaN
      NaN
      0
      0.0
      -1.645275
      0.0
      0.0
      1.645275
      2.115847
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.554595
      0.464996
      0.089599
      24
      20
      76
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      20.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1

      3
      -0.855503
      2.478443
      0.000688
      0.193531
      0.190673
      False
      False
      0.001703
      0.001539
      0.087026
      0.072094
      0.001516
      0.001135
      0.263697
      0.214480
      0.003072
      0.002843
      0.449456
      0.517235
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.855503
      NaN
      NaN
      0.478562
      0.445405
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      0.855503
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.478562
      0.445405
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      1.0
      2.0
      0
      1
      66
      4
      4.005476e+09
      1
      1
      0
      4
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      1.622940
      2.478443
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      1.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      4
      1
      30
      4
      East Carolina
      -0.855503
      -0.855503
      NaN
      0.521438
      0.554595
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      1.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Cam Worthy for 2...
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      Pass Reception
      Kickoff
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      East Carolina
      2.302585
      2.302585
      False
      False
      -1.579543
      -1.260344
      0.0
      1.579543
      1.260344
      0.0
      0
      101849905
      1.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      East Carolina
      0.0
      1
      Pass Incompletion
      1
      1
      Michael Jones
      164873.0
      Michael Jones
      1.0
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -1.161247
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      None
      NaN
      NaN
      4
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Justin Hardy
      505407.0
      1.0
      0
      0.0
      -0.789771
      0.0
      0.0
      0.789771
      1.260344
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.521438
      0.554595
      -0.033156
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1

      4
      -1.130810
      1.622940
      0.000451
      0.185681
      0.193531
      False
      False
      0.001837
      0.001703
      0.109427
      0.087026
      0.002270
      0.001516
      0.329919
      0.263697
      0.003745
      0.003072
      0.367121
      0.449456
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      1.130810
      NaN
      NaN
      0.523197
      0.478562
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      1.130810
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.523197
      0.478562
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      2.0
      3.0
      0
      1
      66
      5
      4.005476e+09
      1
      1
      0
      5
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.492129
      1.622940
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      5
      1
      30
      5
      East Carolina
      -1.130810
      -1.130810
      NaN
      0.476803
      0.521438
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Shane Carden pass incomplete to Justin Hardy, ...
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Incompletion
      Pass Reception
      Pass Reception
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      EAST CAROLINA Penalty, false start (-5 Yards) ...
      Penalty
      East Carolina
      2.302585
      2.302585
      False
      False
      0.682078
      -0.129534
      0.0
      -0.682078
      0.129534
      0.0
      0
      101849906
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Incompletion
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -0.881290
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Davon Grayson
      0.0
      None
      NaN
      NaN
      5
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Davon Grayson
      552937.0
      1.0
      0
      0.0
      0.341039
      0.0
      0.0
      -0.341039
      0.129534
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.476803
      0.521438
      -0.044636
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1

```python
pbp_data['win_indicator'] = pbp_data.pos_team == pbp_data.winner
pbp_data.half = pbp_data.half.astype(int)
pbp_data.loc[pbp_data.off_timeouts_rem_before.isna(), "off_timeouts_rem_before"] = 0
pbp_data.loc[pbp_data.def_timeouts_rem_before.isna(), "def_timeouts_rem_before"] = 0

# https://zacharyst.com/2019/03/06/group_by-mutate-using-pandas/
# def determine_receive_2h_ko(data):
# #     print(data.game_id.iloc[0])
#     val = data.sort_values(by="play_id")[(data.period == 3) & (~data.play_type.str.contains("Kickoff"))].pos_team
#     ret_val = None
#     if (len(val) != 0):
#         ret_val = val.iloc[0]
#     data['receive_2h_ko'] = ret_val
#     return data

# pbp_data = pbp_data.groupby('game_id').apply(determine_receive_2h_ko)
# pbp_data.loc[pbp_data.turnover_vec_lag.isna(), 'turnover_vec_lag'] = 0
pbp_data.head()
```

      EPA
      ExpScoreDiff
      ExpScoreDiff_Time_Ratio
      FG_after
      FG_before
      Goal_To_Go
      Goal_To_Go_end
      No_Score_after
      No_Score_before
      Opp_FG_after
      Opp_FG_before
      Opp_Safety_after
      Opp_Safety_before
      Opp_TD_after
      Opp_TD_before
      Safety_after
      Safety_before
      TD_after
      TD_before
      TimeSecsRem
      TimeSecsRem_end
      Under_three
      Under_two
      Under_two_end
      adj_TimeSecsRem
      away
      away_EPA
      away_EPA_pass
      away_EPA_rush
      away_wp_after
      away_wp_before
      change_of_pos_team
      change_of_poss
      clock.minutes
      clock.seconds
      completion
      completion_player
      completion_player_id
      completion_yds
      def_EPA
      def_pos_team
      def_pos_team_score
      def_pos_team_timeouts
      def_pos_team_timeouts_rem_before
      def_timeout_called
      def_timeouts_rem_before
      def_wp_after
      def_wp_before
      defense_conference
      defense_play
      defense_score
      defense_score_play
      defense_timeouts
      distance
      distance_end
      down
      down_end
      downs_turnover
      drive_end_period
      drive_end_yards_to_goal
      drive_event_number
      drive_id
      drive_num
      drive_number
      drive_numbers
      drive_play_number
      drive_pts
      drive_result
      drive_result2
      drive_result_detailed
      drive_result_detailed_flag
      drive_scoring
      drive_start_period
      drive_start_yards_to_goal
      drive_time_minutes_elapsed
      drive_time_minutes_end
      drive_time_minutes_start
      drive_time_seconds_elapsed
      drive_time_seconds_end
      drive_time_seconds_start
      drive_yards
      end_of_half
      ep_after
      ep_before
      epa_success
      fg_block_player_name
      fg_inds
      fg_kicker_player_name
      fg_made
      fg_make_prob
      fg_return_player_name
      firstD_by_kickoff
      firstD_by_penalty
      firstD_by_poss
      firstD_by_yards
      first_by_penalty
      first_by_yards
      fumble_forced_player
      fumble_forced_player_id
      fumble_forced_player_name
      fumble_forced_stat
      fumble_player
      fumble_player_id
      fumble_player_name
      fumble_recovered_player
      fumble_recovered_player_id
      fumble_recovered_player_name
      fumble_recovered_stat
      fumble_stat
      fumble_vec
      game_id
      game_play_number
      half
      half_clock.minutes
      half_play_number
      home
      home_EPA
      home_EPA_pass
      home_EPA_rush
      home_wp_after
      home_wp_before
      id_drive
      id_play
      incompletion_player
      incompletion_player_id
      incompletion_stat
      int
      int_td
      interception_player
      interception_player_id
      interception_player_name
      interception_stat
      interception_thrown_player
      interception_thrown_player_id
      interception_thrown_stat
      kick_play
      kickoff_downed
      kickoff_fair_catch
      kickoff_onside
      kickoff_oob
      kickoff_play
      kickoff_player_name
      kickoff_returner_player_name
      kickoff_safety
      kickoff_tb
      lag_change_of_pos_team
      lag_change_of_pos_team2
      lag_change_of_poss
      lag_defense_score_play
      lag_downs_turnover
      lag_drive_result_detailed
      lag_first_by_penalty
      lag_first_by_penalty2
      lag_first_by_yards
      lag_first_by_yards2
      lag_kickoff_play
      lag_new_drive_pts
      lag_play_text
      lag_play_text2
      lag_play_type
      lag_play_type2
      lag_play_type3
      lag_pos_team
      lag_punt
      lag_punt2
      lag_scoring_play
      lag_turnover_vec
      lead_drive_result_detailed
      lead_play_text
      lead_play_type
      lead_pos_team
      log_ydstogo
      log_ydstogo_end
      middle_8
      missing_yard_flag
      net_away_EPA
      net_away_EPA_pass
      net_away_EPA_rush
      net_home_EPA
      net_home_EPA_pass
      net_home_EPA_rush
      new_drive_pts
      new_id
      new_series
      number_of_drives
      off_timeout_called
      off_timeouts_rem_before
      offense_conference
      offense_play
      offense_receives_2H_kickoff
      offense_score
      offense_score_play
      offense_timeouts
      opponent
      opponent_score
      orig_drive_number
      orig_play_type
      pass
      pass_attempt
      pass_breakup_player
      pass_breakup_player_id
      pass_breakup_player_name
      pass_breakup_stat
      pass_td
      passer_player_name
      penalty_1st_conv
      penalty_declined
      penalty_detail
      penalty_flag
      penalty_no_play
      penalty_offset
      penalty_play_text
      penalty_safety
      penalty_text
      period
      play_after_turnover
      play_id
      play_text
      play_type
      pos_score_diff
      pos_score_diff_start
      pos_score_diff_start_end
      pos_score_pts
      pos_team
      pos_team_receives_2H_kickoff
      pos_team_score
      pos_team_timeouts
      pos_team_timeouts_rem_before
      position_completion
      position_fumble
      position_fumble_forced
      position_fumble_recovered
      position_incompletion
      position_interception
      position_interception_thrown
      position_pass_breakup
      position_reception
      position_rush
      position_sack
      position_sack_taken
      position_target
      position_touchdown
      ppa
      pts_scored
      punt
      punt_block_player_name
      punt_block_return_player_name
      punt_blocked
      punt_downed
      punt_fair_catch
      punt_oob
      punt_play
      punt_returner_player_name
      punt_safety
      punt_tb
      punter_player_name
      receiver_player_name
      receives_2H_kickoff
      reception_player
      reception_player_id
      reception_yds
      row
      rush
      rush_player
      rush_player_id
      rush_td
      rush_yds
      rusher_player_name
      rz_play
      sack
      sack_player
      sack_player_id
      sack_player_name
      sack_player_name2
      sack_players
      sack_stat
      sack_taken_player
      sack_taken_player_id
      sack_taken_stat
      sack_vec
      safety
      score_diff
      score_diff_start
      score_pts
      scoring
      scoring_opp
      scoring_play
      season
      stuffed_run
      success
      target
      target_player
      target_player_id
      target_stat
      td_play
      team_score
      total_away_EPA
      total_away_EPA_pass
      total_away_EPA_rush
      total_home_EPA
      total_home_EPA_pass
      total_home_EPA_rush
      touchdown
      touchdown_player
      touchdown_player_id
      touchdown_stat
      turnover
      turnover_indicator
      turnover_vec
      turnover_vec_lag
      week
      wp_after
      wp_before
      wpa
      yard_line
      yards_gained
      yards_to_goal
      yards_to_goal_end
      yds_fg
      yds_fumble_return
      yds_int_return
      yds_kickoff
      yds_kickoff_return
      yds_penalty
      yds_punt_gained
      yds_punt_return
      yds_punted
      yds_receiving
      yds_rushed
      yds_sacked
      year
      winner
      spread
      pos_team_spread
      elapsed_share
      spread_time
      is_home
      win_indicator

      0
      -0.470573
      0.833168
      0.000231
      0.134882
      0.170347
      False
      False
      0.002152
      0.001775
      0.121537
      0.089202
      0.004375
      0.001915
      0.343792
      0.260404
      0.002997
      0.002950
      0.390266
      0.473408
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.470573
      NaN
      NaN
      0.528336
      0.509680
      0
      1
      15
      0
      0
      None
      NaN
      NaN
      0.470573
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.528336
      0.509680
      American Athletic
      East Carolina
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      66
      1
      4.005476e+09
      1
      1
      1
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.362595
      0.833168
      0.0
      None
      0.0
      None
      False
      NaN
      None
      1.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      1
      1
      30
      1
      East Carolina
      -0.470573
      NaN
      NaN
      0.471664
      0.490320
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      1
      0
      0
      0
      0
      1
      Brandon McLaren
      Isaiah Jones
      0.0
      0
      0.0
      0.0
      0.0
      NaN
      0.0
      None
      0
      NaN
      0.0
      NaN
      0.0
      NaN
      None
      None
      None
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      East Carolina
      2.302585
      2.302585
      False
      False
      0.941145
      0.000000
      0.0
      -0.941145
      0.000000
      0.0
      0
      101849902
      1.0
      1
      0.0
      3.0
      None
      North Carolina Central
      1
      0
      0
      3.0
      None
      NaN
      1
      Kickoff
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      NaN
      None
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Kickoff
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      0.0
      None
      NaN
      NaN
      1
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      1.0
      0
      None
      NaN
      NaN
      0
      NaN
      0.470573
      0.0
      0.0
      -0.470573
      0.000000
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      NaN
      1
      0.471664
      0.490320
      -0.018655
      65
      6
      65
      80.0
      NaN
      NaN
      NaN
      51.0
      6.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

      1
      -0.168094
      0.362595
      0.000101
      0.128390
      0.134882
      False
      False
      0.002141
      0.002152
      0.124954
      0.121537
      0.003679
      0.004375
      0.355615
      0.343792
      0.003138
      0.002997
      0.382083
      0.390266
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.168094
      NaN
      NaN
      0.535004
      0.528336
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      4.0
      0.168094
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.535004
      0.528336
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      6.0
      1.0
      2.0
      0
      1
      66
      2
      4.005476e+09
      1
      1
      0
      2
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.194501
      0.362595
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      1
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      2
      1
      30
      2
      East Carolina
      -0.168094
      -0.168094
      NaN
      0.464996
      0.471664
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Punt
      0
      NaN
      0.0
      NaN
      1.0
      0.0
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      None
      Kickoff
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      East Carolina
      2.302585
      1.791759
      False
      False
      1.277333
      0.168094
      0.0
      -1.277333
      -0.168094
      0.0
      0
      101849903
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      -0.088432
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      Justin Hardy
      505407.0
      4.0
      2
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      None
      NaN
      NaN
      0
      0.0
      0.638667
      0.0
      0.0
      -0.638667
      -0.168094
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.464996
      0.471664
      -0.006668
      20
      4
      80
      76.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      4.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

      2
      2.283941
      0.194501
      0.000054
      0.190673
      0.128390
      False
      False
      0.001539
      0.002141
      0.072094
      0.124954
      0.001135
      0.003679
      0.214480
      0.355615
      0.002843
      0.003138
      0.517235
      0.382083
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      -2.283941
      NaN
      NaN
      0.445405
      0.535004
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      20.0
      -2.283941
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.445405
      0.535004
      None
      North Carolina Central
      0
      0
      3.0
      6.0
      10.0
      2.0
      1.0
      0
      1
      66
      3
      4.005476e+09
      1
      1
      0
      3
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      2.478443
      0.194501
      1.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      1.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      3
      1
      30
      3
      East Carolina
      2.283941
      2.283941
      NaN
      0.554595
      0.464996
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Justin Hardy for...
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Pass Reception
      Kickoff
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      East Carolina
      1.791759
      2.302585
      False
      False
      -3.290549
      -2.115847
      0.0
      3.290549
      2.115847
      0.0
      0
      101849904
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      2.104307
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Cam Worthy
      0.0
      Cam Worthy
      552953.0
      20.0
      3
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      1.0
      1
      None
      NaN
      NaN
      0
      0.0
      -1.645275
      0.0
      0.0
      1.645275
      2.115847
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.554595
      0.464996
      0.089599
      24
      20
      76
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      20.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

      3
      -0.855503
      2.478443
      0.000688
      0.193531
      0.190673
      False
      False
      0.001703
      0.001539
      0.087026
      0.072094
      0.001516
      0.001135
      0.263697
      0.214480
      0.003072
      0.002843
      0.449456
      0.517235
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.855503
      NaN
      NaN
      0.478562
      0.445405
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      0.855503
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.478562
      0.445405
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      1.0
      2.0
      0
      1
      66
      4
      4.005476e+09
      1
      1
      0
      4
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      1.622940
      2.478443
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      1.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      4
      1
      30
      4
      East Carolina
      -0.855503
      -0.855503
      NaN
      0.521438
      0.554595
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      1.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Cam Worthy for 2...
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      Pass Reception
      Kickoff
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      East Carolina
      2.302585
      2.302585
      False
      False
      -1.579543
      -1.260344
      0.0
      1.579543
      1.260344
      0.0
      0
      101849905
      1.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      East Carolina
      0.0
      1
      Pass Incompletion
      1
      1
      Michael Jones
      164873.0
      Michael Jones
      1.0
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -1.161247
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      None
      NaN
      NaN
      4
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Justin Hardy
      505407.0
      1.0
      0
      0.0
      -0.789771
      0.0
      0.0
      0.789771
      1.260344
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.521438
      0.554595
      -0.033156
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

      4
      -1.130810
      1.622940
      0.000451
      0.185681
      0.193531
      False
      False
      0.001837
      0.001703
      0.109427
      0.087026
      0.002270
      0.001516
      0.329919
      0.263697
      0.003745
      0.003072
      0.367121
      0.449456
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      1.130810
      NaN
      NaN
      0.523197
      0.478562
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      1.130810
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.523197
      0.478562
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      2.0
      3.0
      0
      1
      66
      5
      4.005476e+09
      1
      1
      0
      5
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.492129
      1.622940
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      5
      1
      30
      5
      East Carolina
      -1.130810
      -1.130810
      NaN
      0.476803
      0.521438
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Shane Carden pass incomplete to Justin Hardy, ...
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Incompletion
      Pass Reception
      Pass Reception
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      EAST CAROLINA Penalty, false start (-5 Yards) ...
      Penalty
      East Carolina
      2.302585
      2.302585
      False
      False
      0.682078
      -0.129534
      0.0
      -0.682078
      0.129534
      0.0
      0
      101849906
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Incompletion
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -0.881290
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Davon Grayson
      0.0
      None
      NaN
      NaN
      5
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Davon Grayson
      552937.0
      1.0
      0
      0.0
      0.341039
      0.0
      0.0
      -0.341039
      0.129534
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.476803
      0.521438
      -0.044636
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

```python
filtered_pbp_data = pbp_data[
    (pbp_data.ep_before.notna())
    & (pbp_data.score_diff.notna())
    & (pbp_data.play_type.notna())
    & (pbp_data.win_indicator.notna())
    & (pbp_data.off_timeouts_rem_before.notna())
    & (pbp_data.def_timeouts_rem_before.notna())
    & (pbp_data.yards_to_goal.notna())
    & (pbp_data.period <= 4)
]
```

```python
spread_nrounds = 760
spread_params = {
    "booster":"gbtree",
    "objective":"binary:logistic",
    "eval_metric": ["logloss"],
    "eta":0.02,
    "gamma":0.3445502,
    "subsample":0.7204741,
    "colsample_bytree":0.5714286,
    "max_depth":5,
    "min_child_weight":14
}
before_spread_columns = ["pos_team_receives_2H_kickoff","spread_time","TimeSecsRem","adj_TimeSecsRem","ExpScoreDiff_Time_Ratio","pos_score_diff_start","down","distance","yards_to_goal","is_home","pos_team_timeouts_rem_before","def_pos_team_timeouts_rem_before","period"]
after_spread_columns = ["pos_team_receives_2H_kickoff","spread_time_end","TimeSecsRem_end","adj_TimeSecsRem_end","ExpScoreDiff_Time_Ratio_end","pos_score_diff_start_end","down_end","distance_end","yards_to_goal_end","is_home","pos_team_timeouts","def_pos_team_timeouts","period"]

dtrain_spread = xgb.DMatrix(filtered_pbp_data[before_spread_columns], label=filtered_pbp_data.win_indicator)
dtrain_spread
```

    <xgboost.core.DMatrix at 0x7fb6dfd54590>

```python
wp_model_spread = xgb.train(spread_params, dtrain_spread, num_boost_round=spread_nrounds, verbose_eval=2)
# save for debug
wp_model_spread.dump_model('wp_spread_xgb_dump.json', with_stats=True, dump_format='json')
wp_model_spread.save_model('wp_spread.model')
```

```python
no_spread_nrounds = 65
no_spread_params = {
    "booster":"gbtree",
    "objective":"binary:logistic",
    "eval_metric": ["logloss"],
    "eta":0.2,
    "gamma":0,
    "subsample":0.8,
    "colsample_bytree":0.8,
    "max_depth":4,
    "min_child_weight":1
}

before_no_spread_columns = ["pos_team_receives_2H_kickoff","TimeSecsRem","adj_TimeSecsRem","ExpScoreDiff_Time_Ratio","pos_score_diff_start","down","distance","yards_to_goal","is_home","pos_team_timeouts_rem_before","def_pos_team_timeouts_rem_before","period"]
after_no_spread_columns = ["pos_team_receives_2H_kickoff","TimeSecsRem_end","adj_TimeSecsRem_end","ExpScoreDiff_Time_Ratio_end","pos_score_diff_start_end","down_end","distance_end","yards_to_goal_end","is_home","pos_team_timeouts","def_pos_team_timeouts","period"]

no_spread_dtrain = xgb.DMatrix(filtered_pbp_data[before_no_spread_columns], label=filtered_pbp_data.win_indicator)
no_spread_dtrain
```

    <xgboost.core.DMatrix at 0x7fb6dfee5a90>

```python
no_spread_wp_model = xgb.train(no_spread_params, no_spread_dtrain, num_boost_round=no_spread_nrounds, verbose_eval=2)
# save for debug
no_spread_wp_model.dump_model('wp_xgb_dump.json', with_stats=True, dump_format='json')
no_spread_wp_model.save_model('wp_no_spread.model')
```

```python
wp_model = wp_model_spread
target_file_name = "CFBSpreadWPA"
model_columns_before = before_spread_columns
model_columns_after = after_spread_columns

print("MODEL DETAILS:")
print(f"Filename: {target_file_name}.mlmodel")
print(f"Using Spread: { 'spread_time' in model_columns_before}")
print(f"Model Columns: {model_columns_before}")

```

    MODEL DETAILS:
    Filename: CFBSpreadWPA.mlmodel
    Using Spread: True
    Model Columns: ['pos_team_receives_2H_kickoff', 'spread_time', 'TimeSecsRem', 'adj_TimeSecsRem', 'ExpScoreDiff_Time_Ratio', 'pos_score_diff_start', 'down', 'distance', 'yards_to_goal', 'is_home', 'pos_team_timeouts_rem_before', 'def_pos_team_timeouts_rem_before', 'period']

```python
# Test with all data
base_data = pbp_data.copy() #pd.read_parquet("https://raw.githubusercontent.com/saiemgilani/cfbscrapR-data/master/data/parquet/pbp_players_pos_2020.parquet")
# print(base_data.columns.to_list())

# games_2020 = retrieveCfbDataFile('games', 2020)
# games_2020['game_id'] = games_2020['ï»¿id']
# games_2020['year'] = 2020
# games_2020 = games_2020[games_2020.home_points != games_2020.away_points]
# games_2020['winner'] = np.where(games_2020.home_points > games_2020.away_points, games_2020.home_team, games_2020.away_team)

# spread_2020 = retrieveCfbDataFile('lines', 2020)
# spread_2020 = spread_2020[spread_2020.lineProvider == "consensus"]
# spread_2020['spread'] = -1 * spread_2020.spread # spread is negative for home favorite; positive for away favorite, but NFLfastR uses "(how many points home team was favored by) for this"
# spread_2020['game_id'] = spread_2020['ï»¿id']
# spread_2020['year'] = 2020
# base_data = pd.merge(base_data, spread_2020[['game_id','spread']], left_on="game_id", right_on="game_id")
# base_data = pd.merge(base_data, games_2020[['game_id','winner']], left_on="game_id", right_on="game_id")
base_data.head()
```

      EPA
      ExpScoreDiff
      ExpScoreDiff_Time_Ratio
      FG_after
      FG_before
      Goal_To_Go
      Goal_To_Go_end
      No_Score_after
      No_Score_before
      Opp_FG_after
      Opp_FG_before
      Opp_Safety_after
      Opp_Safety_before
      Opp_TD_after
      Opp_TD_before
      Safety_after
      Safety_before
      TD_after
      TD_before
      TimeSecsRem
      TimeSecsRem_end
      Under_three
      Under_two
      Under_two_end
      adj_TimeSecsRem
      away
      away_EPA
      away_EPA_pass
      away_EPA_rush
      away_wp_after
      away_wp_before
      change_of_pos_team
      change_of_poss
      clock.minutes
      clock.seconds
      completion
      completion_player
      completion_player_id
      completion_yds
      def_EPA
      def_pos_team
      def_pos_team_score
      def_pos_team_timeouts
      def_pos_team_timeouts_rem_before
      def_timeout_called
      def_timeouts_rem_before
      def_wp_after
      def_wp_before
      defense_conference
      defense_play
      defense_score
      defense_score_play
      defense_timeouts
      distance
      distance_end
      down
      down_end
      downs_turnover
      drive_end_period
      drive_end_yards_to_goal
      drive_event_number
      drive_id
      drive_num
      drive_number
      drive_numbers
      drive_play_number
      drive_pts
      drive_result
      drive_result2
      drive_result_detailed
      drive_result_detailed_flag
      drive_scoring
      drive_start_period
      drive_start_yards_to_goal
      drive_time_minutes_elapsed
      drive_time_minutes_end
      drive_time_minutes_start
      drive_time_seconds_elapsed
      drive_time_seconds_end
      drive_time_seconds_start
      drive_yards
      end_of_half
      ep_after
      ep_before
      epa_success
      fg_block_player_name
      fg_inds
      fg_kicker_player_name
      fg_made
      fg_make_prob
      fg_return_player_name
      firstD_by_kickoff
      firstD_by_penalty
      firstD_by_poss
      firstD_by_yards
      first_by_penalty
      first_by_yards
      fumble_forced_player
      fumble_forced_player_id
      fumble_forced_player_name
      fumble_forced_stat
      fumble_player
      fumble_player_id
      fumble_player_name
      fumble_recovered_player
      fumble_recovered_player_id
      fumble_recovered_player_name
      fumble_recovered_stat
      fumble_stat
      fumble_vec
      game_id
      game_play_number
      half
      half_clock.minutes
      half_play_number
      home
      home_EPA
      home_EPA_pass
      home_EPA_rush
      home_wp_after
      home_wp_before
      id_drive
      id_play
      incompletion_player
      incompletion_player_id
      incompletion_stat
      int
      int_td
      interception_player
      interception_player_id
      interception_player_name
      interception_stat
      interception_thrown_player
      interception_thrown_player_id
      interception_thrown_stat
      kick_play
      kickoff_downed
      kickoff_fair_catch
      kickoff_onside
      kickoff_oob
      kickoff_play
      kickoff_player_name
      kickoff_returner_player_name
      kickoff_safety
      kickoff_tb
      lag_change_of_pos_team
      lag_change_of_pos_team2
      lag_change_of_poss
      lag_defense_score_play
      lag_downs_turnover
      lag_drive_result_detailed
      lag_first_by_penalty
      lag_first_by_penalty2
      lag_first_by_yards
      lag_first_by_yards2
      lag_kickoff_play
      lag_new_drive_pts
      lag_play_text
      lag_play_text2
      lag_play_type
      lag_play_type2
      lag_play_type3
      lag_pos_team
      lag_punt
      lag_punt2
      lag_scoring_play
      lag_turnover_vec
      lead_drive_result_detailed
      lead_play_text
      lead_play_type
      lead_pos_team
      log_ydstogo
      log_ydstogo_end
      middle_8
      missing_yard_flag
      net_away_EPA
      net_away_EPA_pass
      net_away_EPA_rush
      net_home_EPA
      net_home_EPA_pass
      net_home_EPA_rush
      new_drive_pts
      new_id
      new_series
      number_of_drives
      off_timeout_called
      off_timeouts_rem_before
      offense_conference
      offense_play
      offense_receives_2H_kickoff
      offense_score
      offense_score_play
      offense_timeouts
      opponent
      opponent_score
      orig_drive_number
      orig_play_type
      pass
      pass_attempt
      pass_breakup_player
      pass_breakup_player_id
      pass_breakup_player_name
      pass_breakup_stat
      pass_td
      passer_player_name
      penalty_1st_conv
      penalty_declined
      penalty_detail
      penalty_flag
      penalty_no_play
      penalty_offset
      penalty_play_text
      penalty_safety
      penalty_text
      period
      play_after_turnover
      play_id
      play_text
      play_type
      pos_score_diff
      pos_score_diff_start
      pos_score_diff_start_end
      pos_score_pts
      pos_team
      pos_team_receives_2H_kickoff
      pos_team_score
      pos_team_timeouts
      pos_team_timeouts_rem_before
      position_completion
      position_fumble
      position_fumble_forced
      position_fumble_recovered
      position_incompletion
      position_interception
      position_interception_thrown
      position_pass_breakup
      position_reception
      position_rush
      position_sack
      position_sack_taken
      position_target
      position_touchdown
      ppa
      pts_scored
      punt
      punt_block_player_name
      punt_block_return_player_name
      punt_blocked
      punt_downed
      punt_fair_catch
      punt_oob
      punt_play
      punt_returner_player_name
      punt_safety
      punt_tb
      punter_player_name
      receiver_player_name
      receives_2H_kickoff
      reception_player
      reception_player_id
      reception_yds
      row
      rush
      rush_player
      rush_player_id
      rush_td
      rush_yds
      rusher_player_name
      rz_play
      sack
      sack_player
      sack_player_id
      sack_player_name
      sack_player_name2
      sack_players
      sack_stat
      sack_taken_player
      sack_taken_player_id
      sack_taken_stat
      sack_vec
      safety
      score_diff
      score_diff_start
      score_pts
      scoring
      scoring_opp
      scoring_play
      season
      stuffed_run
      success
      target
      target_player
      target_player_id
      target_stat
      td_play
      team_score
      total_away_EPA
      total_away_EPA_pass
      total_away_EPA_rush
      total_home_EPA
      total_home_EPA_pass
      total_home_EPA_rush
      touchdown
      touchdown_player
      touchdown_player_id
      touchdown_stat
      turnover
      turnover_indicator
      turnover_vec
      turnover_vec_lag
      week
      wp_after
      wp_before
      wpa
      yard_line
      yards_gained
      yards_to_goal
      yards_to_goal_end
      yds_fg
      yds_fumble_return
      yds_int_return
      yds_kickoff
      yds_kickoff_return
      yds_penalty
      yds_punt_gained
      yds_punt_return
      yds_punted
      yds_receiving
      yds_rushed
      yds_sacked
      year
      winner
      spread
      pos_team_spread
      elapsed_share
      spread_time
      is_home
      win_indicator

      0
      -0.470573
      0.833168
      0.000231
      0.134882
      0.170347
      False
      False
      0.002152
      0.001775
      0.121537
      0.089202
      0.004375
      0.001915
      0.343792
      0.260404
      0.002997
      0.002950
      0.390266
      0.473408
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.470573
      NaN
      NaN
      0.528336
      0.509680
      0
      1
      15
      0
      0
      None
      NaN
      NaN
      0.470573
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.528336
      0.509680
      American Athletic
      East Carolina
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      66
      1
      4.005476e+09
      1
      1
      1
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.362595
      0.833168
      0.0
      None
      0.0
      None
      False
      NaN
      None
      1.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      1
      1
      30
      1
      East Carolina
      -0.470573
      NaN
      NaN
      0.471664
      0.490320
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      1
      0
      0
      0
      0
      1
      Brandon McLaren
      Isaiah Jones
      0.0
      0
      0.0
      0.0
      0.0
      NaN
      0.0
      None
      0
      NaN
      0.0
      NaN
      0.0
      NaN
      None
      None
      None
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      East Carolina
      2.302585
      2.302585
      False
      False
      0.941145
      0.000000
      0.0
      -0.941145
      0.000000
      0.0
      0
      101849902
      1.0
      1
      0.0
      3.0
      None
      North Carolina Central
      1
      0
      0
      3.0
      None
      NaN
      1
      Kickoff
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      NaN
      None
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Kickoff
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      0.0
      None
      NaN
      NaN
      1
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      1.0
      0
      None
      NaN
      NaN
      0
      NaN
      0.470573
      0.0
      0.0
      -0.470573
      0.000000
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      NaN
      1
      0.471664
      0.490320
      -0.018655
      65
      6
      65
      80.0
      NaN
      NaN
      NaN
      51.0
      6.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

      1
      -0.168094
      0.362595
      0.000101
      0.128390
      0.134882
      False
      False
      0.002141
      0.002152
      0.124954
      0.121537
      0.003679
      0.004375
      0.355615
      0.343792
      0.003138
      0.002997
      0.382083
      0.390266
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.168094
      NaN
      NaN
      0.535004
      0.528336
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      4.0
      0.168094
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.535004
      0.528336
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      6.0
      1.0
      2.0
      0
      1
      66
      2
      4.005476e+09
      1
      1
      0
      2
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.194501
      0.362595
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      1
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      2
      1
      30
      2
      East Carolina
      -0.168094
      -0.168094
      NaN
      0.464996
      0.471664
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Punt
      0
      NaN
      0.0
      NaN
      1.0
      0.0
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      None
      Kickoff
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      East Carolina
      2.302585
      1.791759
      False
      False
      1.277333
      0.168094
      0.0
      -1.277333
      -0.168094
      0.0
      0
      101849903
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      -0.088432
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      Justin Hardy
      505407.0
      4.0
      2
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      None
      NaN
      NaN
      0
      0.0
      0.638667
      0.0
      0.0
      -0.638667
      -0.168094
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.464996
      0.471664
      -0.006668
      20
      4
      80
      76.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      4.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

      2
      2.283941
      0.194501
      0.000054
      0.190673
      0.128390
      False
      False
      0.001539
      0.002141
      0.072094
      0.124954
      0.001135
      0.003679
      0.214480
      0.355615
      0.002843
      0.003138
      0.517235
      0.382083
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      -2.283941
      NaN
      NaN
      0.445405
      0.535004
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      20.0
      -2.283941
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.445405
      0.535004
      None
      North Carolina Central
      0
      0
      3.0
      6.0
      10.0
      2.0
      1.0
      0
      1
      66
      3
      4.005476e+09
      1
      1
      0
      3
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      2.478443
      0.194501
      1.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      1.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      3
      1
      30
      3
      East Carolina
      2.283941
      2.283941
      NaN
      0.554595
      0.464996
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Justin Hardy for...
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Pass Reception
      Kickoff
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      East Carolina
      1.791759
      2.302585
      False
      False
      -3.290549
      -2.115847
      0.0
      3.290549
      2.115847
      0.0
      0
      101849904
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      2.104307
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Cam Worthy
      0.0
      Cam Worthy
      552953.0
      20.0
      3
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      1.0
      1
      None
      NaN
      NaN
      0
      0.0
      -1.645275
      0.0
      0.0
      1.645275
      2.115847
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.554595
      0.464996
      0.089599
      24
      20
      76
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      20.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

      3
      -0.855503
      2.478443
      0.000688
      0.193531
      0.190673
      False
      False
      0.001703
      0.001539
      0.087026
      0.072094
      0.001516
      0.001135
      0.263697
      0.214480
      0.003072
      0.002843
      0.449456
      0.517235
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.855503
      NaN
      NaN
      0.478562
      0.445405
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      0.855503
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.478562
      0.445405
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      1.0
      2.0
      0
      1
      66
      4
      4.005476e+09
      1
      1
      0
      4
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      1.622940
      2.478443
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      1.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      4
      1
      30
      4
      East Carolina
      -0.855503
      -0.855503
      NaN
      0.521438
      0.554595
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      1.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Cam Worthy for 2...
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      Pass Reception
      Kickoff
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      East Carolina
      2.302585
      2.302585
      False
      False
      -1.579543
      -1.260344
      0.0
      1.579543
      1.260344
      0.0
      0
      101849905
      1.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      East Carolina
      0.0
      1
      Pass Incompletion
      1
      1
      Michael Jones
      164873.0
      Michael Jones
      1.0
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -1.161247
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      None
      NaN
      NaN
      4
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Justin Hardy
      505407.0
      1.0
      0
      0.0
      -0.789771
      0.0
      0.0
      0.789771
      1.260344
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.521438
      0.554595
      -0.033156
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

      4
      -1.130810
      1.622940
      0.000451
      0.185681
      0.193531
      False
      False
      0.001837
      0.001703
      0.109427
      0.087026
      0.002270
      0.001516
      0.329919
      0.263697
      0.003745
      0.003072
      0.367121
      0.449456
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      1.130810
      NaN
      NaN
      0.523197
      0.478562
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      1.130810
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.523197
      0.478562
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      2.0
      3.0
      0
      1
      66
      5
      4.005476e+09
      1
      1
      0
      5
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.492129
      1.622940
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      5
      1
      30
      5
      East Carolina
      -1.130810
      -1.130810
      NaN
      0.476803
      0.521438
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Shane Carden pass incomplete to Justin Hardy, ...
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Incompletion
      Pass Reception
      Pass Reception
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      EAST CAROLINA Penalty, false start (-5 Yards) ...
      Penalty
      East Carolina
      2.302585
      2.302585
      False
      False
      0.682078
      -0.129534
      0.0
      -0.682078
      0.129534
      0.0
      0
      101849906
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Incompletion
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -0.881290
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Davon Grayson
      0.0
      None
      NaN
      NaN
      5
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Davon Grayson
      552937.0
      1.0
      0
      0.0
      0.341039
      0.0
      0.0
      -0.341039
      0.129534
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.476803
      0.521438
      -0.044636
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      True

```python
base_data[base_data.down_end.isna()].play_type.value_counts()
```

    End Period                       10801
    End of Half                       4716
    End of Game                       3119
    Rush                              1158
    Pass Incompletion                  378
    Pass Reception                     313
    Rushing Touchdown                  158
    Timeout                            156
    Passing Touchdown                  155
    Penalty                            127
    Field Goal Good                    121
    Sack                                55
    Field Goal Missed                   46
    Interception Return                 34
    Fumble Recovery (Own)               16
    Fumble Recovery (Opponent)          14
    Blocked Field Goal                   5
    Uncategorized                        3
    Fumble Return Touchdown              2
    Defensive 2pt Conversion             2
    Interception Return Touchdown        1
    Two Point Rush                       1
    Coin Toss                            1
    Name: play_type, dtype: int64

```python
base_data['win_indicator'] = np.where(base_data.pos_team == base_data.winner, 1, 0)
base_data['ExpScoreDiff_end'] = base_data.score_diff_start + base_data.ep_after
base_data['adj_TimeSecsRem_end'] = np.where(base_data.half == 1, 1800 + base_data.adj_TimeSecsRem, base_data.adj_TimeSecsRem)
base_data['ExpScoreDiff_Time_Ratio_end'] = base_data.ExpScoreDiff_end / (base_data.adj_TimeSecsRem_end + 1)
base_data['pos_team_spread'] = np.where(base_data.pos_team == base_data.home, base_data.spread, -1 * base_data.spread)
base_data['elapsed_share'] = (3600 - base_data.adj_TimeSecsRem) / 3600
base_data['elapsed_share_end'] = (3600 - base_data.adj_TimeSecsRem_end) / 3600
base_data['spread_time'] = base_data.pos_team_spread * np.exp(-4 * base_data.elapsed_share)
base_data['spread_time_end'] = base_data.pos_team_spread * np.exp(-4 * base_data.elapsed_share_end)
base_data['is_home'] = np.where(base_data.pos_team == base_data.home, 1, 0)
base_data.head()

```

      EPA
      ExpScoreDiff
      ExpScoreDiff_Time_Ratio
      FG_after
      FG_before
      Goal_To_Go
      Goal_To_Go_end
      No_Score_after
      No_Score_before
      Opp_FG_after
      Opp_FG_before
      Opp_Safety_after
      Opp_Safety_before
      Opp_TD_after
      Opp_TD_before
      Safety_after
      Safety_before
      TD_after
      TD_before
      TimeSecsRem
      TimeSecsRem_end
      Under_three
      Under_two
      Under_two_end
      adj_TimeSecsRem
      away
      away_EPA
      away_EPA_pass
      away_EPA_rush
      away_wp_after
      away_wp_before
      change_of_pos_team
      change_of_poss
      clock.minutes
      clock.seconds
      completion
      completion_player
      completion_player_id
      completion_yds
      def_EPA
      def_pos_team
      def_pos_team_score
      def_pos_team_timeouts
      def_pos_team_timeouts_rem_before
      def_timeout_called
      def_timeouts_rem_before
      def_wp_after
      def_wp_before
      defense_conference
      defense_play
      defense_score
      defense_score_play
      defense_timeouts
      distance
      distance_end
      down
      down_end
      downs_turnover
      drive_end_period
      drive_end_yards_to_goal
      drive_event_number
      drive_id
      drive_num
      drive_number
      drive_numbers
      drive_play_number
      drive_pts
      drive_result
      drive_result2
      drive_result_detailed
      drive_result_detailed_flag
      drive_scoring
      drive_start_period
      drive_start_yards_to_goal
      drive_time_minutes_elapsed
      drive_time_minutes_end
      drive_time_minutes_start
      drive_time_seconds_elapsed
      drive_time_seconds_end
      drive_time_seconds_start
      drive_yards
      end_of_half
      ep_after
      ep_before
      epa_success
      fg_block_player_name
      fg_inds
      fg_kicker_player_name
      fg_made
      fg_make_prob
      fg_return_player_name
      firstD_by_kickoff
      firstD_by_penalty
      firstD_by_poss
      firstD_by_yards
      first_by_penalty
      first_by_yards
      fumble_forced_player
      fumble_forced_player_id
      fumble_forced_player_name
      fumble_forced_stat
      fumble_player
      fumble_player_id
      fumble_player_name
      fumble_recovered_player
      fumble_recovered_player_id
      fumble_recovered_player_name
      fumble_recovered_stat
      fumble_stat
      fumble_vec
      game_id
      game_play_number
      half
      half_clock.minutes
      half_play_number
      home
      home_EPA
      home_EPA_pass
      home_EPA_rush
      home_wp_after
      home_wp_before
      id_drive
      id_play
      incompletion_player
      incompletion_player_id
      incompletion_stat
      int
      int_td
      interception_player
      interception_player_id
      interception_player_name
      interception_stat
      interception_thrown_player
      interception_thrown_player_id
      interception_thrown_stat
      kick_play
      kickoff_downed
      kickoff_fair_catch
      kickoff_onside
      kickoff_oob
      kickoff_play
      kickoff_player_name
      kickoff_returner_player_name
      kickoff_safety
      kickoff_tb
      lag_change_of_pos_team
      lag_change_of_pos_team2
      lag_change_of_poss
      lag_defense_score_play
      lag_downs_turnover
      lag_drive_result_detailed
      lag_first_by_penalty
      lag_first_by_penalty2
      lag_first_by_yards
      lag_first_by_yards2
      lag_kickoff_play
      lag_new_drive_pts
      lag_play_text
      lag_play_text2
      lag_play_type
      lag_play_type2
      lag_play_type3
      lag_pos_team
      lag_punt
      lag_punt2
      lag_scoring_play
      lag_turnover_vec
      lead_drive_result_detailed
      lead_play_text
      lead_play_type
      lead_pos_team
      log_ydstogo
      log_ydstogo_end
      middle_8
      missing_yard_flag
      net_away_EPA
      net_away_EPA_pass
      net_away_EPA_rush
      net_home_EPA
      net_home_EPA_pass
      net_home_EPA_rush
      new_drive_pts
      new_id
      new_series
      number_of_drives
      off_timeout_called
      off_timeouts_rem_before
      offense_conference
      offense_play
      offense_receives_2H_kickoff
      offense_score
      offense_score_play
      offense_timeouts
      opponent
      opponent_score
      orig_drive_number
      orig_play_type
      pass
      pass_attempt
      pass_breakup_player
      pass_breakup_player_id
      pass_breakup_player_name
      pass_breakup_stat
      pass_td
      passer_player_name
      penalty_1st_conv
      penalty_declined
      penalty_detail
      penalty_flag
      penalty_no_play
      penalty_offset
      penalty_play_text
      penalty_safety
      penalty_text
      period
      play_after_turnover
      play_id
      play_text
      play_type
      pos_score_diff
      pos_score_diff_start
      pos_score_diff_start_end
      pos_score_pts
      pos_team
      pos_team_receives_2H_kickoff
      pos_team_score
      pos_team_timeouts
      pos_team_timeouts_rem_before
      position_completion
      position_fumble
      position_fumble_forced
      position_fumble_recovered
      position_incompletion
      position_interception
      position_interception_thrown
      position_pass_breakup
      position_reception
      position_rush
      position_sack
      position_sack_taken
      position_target
      position_touchdown
      ppa
      pts_scored
      punt
      punt_block_player_name
      punt_block_return_player_name
      punt_blocked
      punt_downed
      punt_fair_catch
      punt_oob
      punt_play
      punt_returner_player_name
      punt_safety
      punt_tb
      punter_player_name
      receiver_player_name
      receives_2H_kickoff
      reception_player
      reception_player_id
      reception_yds
      row
      rush
      rush_player
      rush_player_id
      rush_td
      rush_yds
      rusher_player_name
      rz_play
      sack
      sack_player
      sack_player_id
      sack_player_name
      sack_player_name2
      sack_players
      sack_stat
      sack_taken_player
      sack_taken_player_id
      sack_taken_stat
      sack_vec
      safety
      score_diff
      score_diff_start
      score_pts
      scoring
      scoring_opp
      scoring_play
      season
      stuffed_run
      success
      target
      target_player
      target_player_id
      target_stat
      td_play
      team_score
      total_away_EPA
      total_away_EPA_pass
      total_away_EPA_rush
      total_home_EPA
      total_home_EPA_pass
      total_home_EPA_rush
      touchdown
      touchdown_player
      touchdown_player_id
      touchdown_stat
      turnover
      turnover_indicator
      turnover_vec
      turnover_vec_lag
      week
      wp_after
      wp_before
      wpa
      yard_line
      yards_gained
      yards_to_goal
      yards_to_goal_end
      yds_fg
      yds_fumble_return
      yds_int_return
      yds_kickoff
      yds_kickoff_return
      yds_penalty
      yds_punt_gained
      yds_punt_return
      yds_punted
      yds_receiving
      yds_rushed
      yds_sacked
      year
      winner
      spread
      pos_team_spread
      elapsed_share
      spread_time
      is_home
      win_indicator
      ExpScoreDiff_end
      adj_TimeSecsRem_end
      ExpScoreDiff_Time_Ratio_end
      elapsed_share_end
      spread_time_end

      0
      -0.470573
      0.833168
      0.000231
      0.134882
      0.170347
      False
      False
      0.002152
      0.001775
      0.121537
      0.089202
      0.004375
      0.001915
      0.343792
      0.260404
      0.002997
      0.002950
      0.390266
      0.473408
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.470573
      NaN
      NaN
      0.528336
      0.509680
      0
      1
      15
      0
      0
      None
      NaN
      NaN
      0.470573
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.528336
      0.509680
      American Athletic
      East Carolina
      0
      0
      3.0
      10.0
      10.0
      1.0
      1.0
      0
      1
      66
      1
      4.005476e+09
      1
      1
      1
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.362595
      0.833168
      0.0
      None
      0.0
      None
      False
      NaN
      None
      1.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      1
      1
      30
      1
      East Carolina
      -0.470573
      NaN
      NaN
      0.471664
      0.490320
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      1
      0
      0
      0
      0
      1
      Brandon McLaren
      Isaiah Jones
      0.0
      0
      0.0
      0.0
      0.0
      NaN
      0.0
      None
      0
      NaN
      0.0
      NaN
      0.0
      NaN
      None
      None
      None
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      East Carolina
      2.302585
      2.302585
      False
      False
      0.941145
      0.000000
      0.0
      -0.941145
      0.000000
      0.0
      0
      101849902
      1.0
      1
      0.0
      3.0
      None
      North Carolina Central
      1
      0
      0
      3.0
      None
      NaN
      1
      Kickoff
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      NaN
      None
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Kickoff
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      0.0
      None
      NaN
      NaN
      1
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      1.0
      0
      None
      NaN
      NaN
      0
      NaN
      0.470573
      0.0
      0.0
      -0.470573
      0.000000
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      NaN
      1
      0.471664
      0.490320
      -0.018655
      65
      6
      65
      80.0
      NaN
      NaN
      NaN
      51.0
      6.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      0.362595
      5400
      0.000067
      -0.5
      288.173188

      1
      -0.168094
      0.362595
      0.000101
      0.128390
      0.134882
      False
      False
      0.002141
      0.002152
      0.124954
      0.121537
      0.003679
      0.004375
      0.355615
      0.343792
      0.003138
      0.002997
      0.382083
      0.390266
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.168094
      NaN
      NaN
      0.535004
      0.528336
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      4.0
      0.168094
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.535004
      0.528336
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      6.0
      1.0
      2.0
      0
      1
      66
      2
      4.005476e+09
      1
      1
      0
      2
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.194501
      0.362595
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      1
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      2
      1
      30
      2
      East Carolina
      -0.168094
      -0.168094
      NaN
      0.464996
      0.471664
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Punt
      0
      NaN
      0.0
      NaN
      1.0
      0.0
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      None
      Kickoff
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      East Carolina
      2.302585
      1.791759
      False
      False
      1.277333
      0.168094
      0.0
      -1.277333
      -0.168094
      0.0
      0
      101849903
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      -0.088432
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      Justin Hardy
      505407.0
      4.0
      2
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      None
      NaN
      NaN
      0
      0.0
      0.638667
      0.0
      0.0
      -0.638667
      -0.168094
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.464996
      0.471664
      -0.006668
      20
      4
      80
      76.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      4.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      0.194501
      5400
      0.000036
      -0.5
      288.173188

      2
      2.283941
      0.194501
      0.000054
      0.190673
      0.128390
      False
      False
      0.001539
      0.002141
      0.072094
      0.124954
      0.001135
      0.003679
      0.214480
      0.355615
      0.002843
      0.003138
      0.517235
      0.382083
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      -2.283941
      NaN
      NaN
      0.445405
      0.535004
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      20.0
      -2.283941
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.445405
      0.535004
      None
      North Carolina Central
      0
      0
      3.0
      6.0
      10.0
      2.0
      1.0
      0
      1
      66
      3
      4.005476e+09
      1
      1
      0
      3
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      2.478443
      0.194501
      1.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      1.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      3
      1
      30
      3
      East Carolina
      2.283941
      2.283941
      NaN
      0.554595
      0.464996
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Justin Hardy for...
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Pass Reception
      Kickoff
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      East Carolina
      1.791759
      2.302585
      False
      False
      -3.290549
      -2.115847
      0.0
      3.290549
      2.115847
      0.0
      0
      101849904
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      2.104307
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Cam Worthy
      0.0
      Cam Worthy
      552953.0
      20.0
      3
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      1.0
      1
      None
      NaN
      NaN
      0
      0.0
      -1.645275
      0.0
      0.0
      1.645275
      2.115847
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.554595
      0.464996
      0.089599
      24
      20
      76
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      20.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      2.478443
      5400
      0.000459
      -0.5
      288.173188

      3
      -0.855503
      2.478443
      0.000688
      0.193531
      0.190673
      False
      False
      0.001703
      0.001539
      0.087026
      0.072094
      0.001516
      0.001135
      0.263697
      0.214480
      0.003072
      0.002843
      0.449456
      0.517235
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.855503
      NaN
      NaN
      0.478562
      0.445405
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      0.855503
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.478562
      0.445405
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      1.0
      2.0
      0
      1
      66
      4
      4.005476e+09
      1
      1
      0
      4
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      1.622940
      2.478443
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      1.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      4
      1
      30
      4
      East Carolina
      -0.855503
      -0.855503
      NaN
      0.521438
      0.554595
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      1.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Cam Worthy for 2...
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      Pass Reception
      Kickoff
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      East Carolina
      2.302585
      2.302585
      False
      False
      -1.579543
      -1.260344
      0.0
      1.579543
      1.260344
      0.0
      0
      101849905
      1.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      East Carolina
      0.0
      1
      Pass Incompletion
      1
      1
      Michael Jones
      164873.0
      Michael Jones
      1.0
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -1.161247
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      None
      NaN
      NaN
      4
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Justin Hardy
      505407.0
      1.0
      0
      0.0
      -0.789771
      0.0
      0.0
      0.789771
      1.260344
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.521438
      0.554595
      -0.033156
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      1.622940
      5400
      0.000300
      -0.5
      288.173188

      4
      -1.130810
      1.622940
      0.000451
      0.185681
      0.193531
      False
      False
      0.001837
      0.001703
      0.109427
      0.087026
      0.002270
      0.001516
      0.329919
      0.263697
      0.003745
      0.003072
      0.367121
      0.449456
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      1.130810
      NaN
      NaN
      0.523197
      0.478562
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      1.130810
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.523197
      0.478562
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      2.0
      3.0
      0
      1
      66
      5
      4.005476e+09
      1
      1
      0
      5
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.492129
      1.622940
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      5
      1
      30
      5
      East Carolina
      -1.130810
      -1.130810
      NaN
      0.476803
      0.521438
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Shane Carden pass incomplete to Justin Hardy, ...
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Incompletion
      Pass Reception
      Pass Reception
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      EAST CAROLINA Penalty, false start (-5 Yards) ...
      Penalty
      East Carolina
      2.302585
      2.302585
      False
      False
      0.682078
      -0.129534
      0.0
      -0.682078
      0.129534
      0.0
      0
      101849906
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Incompletion
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -0.881290
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Davon Grayson
      0.0
      None
      NaN
      NaN
      5
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Davon Grayson
      552937.0
      1.0
      0
      0.0
      0.341039
      0.0
      0.0
      -0.341039
      0.129534
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.476803
      0.521438
      -0.044636
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      0.492129
      5400
      0.000091
      -0.5
      288.173188

```python
base_data = base_data[
    (base_data.ep_before.notna())
    & (base_data.pos_score_diff_start.notna())
    & (base_data.play_type.notna())
    & (base_data.win_indicator.notna())
    & (base_data.pos_team_timeouts_rem_before.notna())
    & (base_data.def_pos_team_timeouts_rem_before.notna())
    & (base_data.yards_to_goal.notna())
    & (base_data.period <= 4)

    & (base_data.ep_after.notna())
    & (base_data.pos_score_diff_start_end.notna())
    & (base_data.pos_team_timeouts.notna())
    & (base_data.def_pos_team_timeouts.notna())
    & (base_data.yards_to_goal_end.notna())

    & (base_data.down_end.notna())
]
base_data.down_end = base_data.down_end.astype(int)
```

```python
# leave-one-season-out
def calculate_wpa(yr):
    data = base_data[base_data.year != yr]
    dtest_start = xgb.DMatrix(data[model_columns_before], label=data.win_indicator)
    WP_start = wp_model.predict(dtest_start)

    end_data = data[model_columns_after]
    end_data.columns = model_columns_before

    dtest_end = xgb.DMatrix(end_data, label=data.win_indicator)
    WP_end = wp_model.predict(dtest_end)

    base_data.loc[data.index, 'WP_NFL_start'] = WP_start
    base_data.loc[data.index,'WP_NFL_end'] = WP_end
    base_data.loc[data.index,'WPA_NFL'] = base_data['WP_NFL_end'] - base_data['WP_NFL_start']

years_range = range(min(pbp_data.year), max(pbp_data.year) + 1)
for yr in years_range:
    calculate_wpa(yr)

base_data.head()
```

      EPA
      ExpScoreDiff
      ExpScoreDiff_Time_Ratio
      FG_after
      FG_before
      Goal_To_Go
      Goal_To_Go_end
      No_Score_after
      No_Score_before
      Opp_FG_after
      Opp_FG_before
      Opp_Safety_after
      Opp_Safety_before
      Opp_TD_after
      Opp_TD_before
      Safety_after
      Safety_before
      TD_after
      TD_before
      TimeSecsRem
      TimeSecsRem_end
      Under_three
      Under_two
      Under_two_end
      adj_TimeSecsRem
      away
      away_EPA
      away_EPA_pass
      away_EPA_rush
      away_wp_after
      away_wp_before
      change_of_pos_team
      change_of_poss
      clock.minutes
      clock.seconds
      completion
      completion_player
      completion_player_id
      completion_yds
      def_EPA
      def_pos_team
      def_pos_team_score
      def_pos_team_timeouts
      def_pos_team_timeouts_rem_before
      def_timeout_called
      def_timeouts_rem_before
      def_wp_after
      def_wp_before
      defense_conference
      defense_play
      defense_score
      defense_score_play
      defense_timeouts
      distance
      distance_end
      down
      down_end
      downs_turnover
      drive_end_period
      drive_end_yards_to_goal
      drive_event_number
      drive_id
      drive_num
      drive_number
      drive_numbers
      drive_play_number
      drive_pts
      drive_result
      drive_result2
      drive_result_detailed
      drive_result_detailed_flag
      drive_scoring
      drive_start_period
      drive_start_yards_to_goal
      drive_time_minutes_elapsed
      drive_time_minutes_end
      drive_time_minutes_start
      drive_time_seconds_elapsed
      drive_time_seconds_end
      drive_time_seconds_start
      drive_yards
      end_of_half
      ep_after
      ep_before
      epa_success
      fg_block_player_name
      fg_inds
      fg_kicker_player_name
      fg_made
      fg_make_prob
      fg_return_player_name
      firstD_by_kickoff
      firstD_by_penalty
      firstD_by_poss
      firstD_by_yards
      first_by_penalty
      first_by_yards
      fumble_forced_player
      fumble_forced_player_id
      fumble_forced_player_name
      fumble_forced_stat
      fumble_player
      fumble_player_id
      fumble_player_name
      fumble_recovered_player
      fumble_recovered_player_id
      fumble_recovered_player_name
      fumble_recovered_stat
      fumble_stat
      fumble_vec
      game_id
      game_play_number
      half
      half_clock.minutes
      half_play_number
      home
      home_EPA
      home_EPA_pass
      home_EPA_rush
      home_wp_after
      home_wp_before
      id_drive
      id_play
      incompletion_player
      incompletion_player_id
      incompletion_stat
      int
      int_td
      interception_player
      interception_player_id
      interception_player_name
      interception_stat
      interception_thrown_player
      interception_thrown_player_id
      interception_thrown_stat
      kick_play
      kickoff_downed
      kickoff_fair_catch
      kickoff_onside
      kickoff_oob
      kickoff_play
      kickoff_player_name
      kickoff_returner_player_name
      kickoff_safety
      kickoff_tb
      lag_change_of_pos_team
      lag_change_of_pos_team2
      lag_change_of_poss
      lag_defense_score_play
      lag_downs_turnover
      lag_drive_result_detailed
      lag_first_by_penalty
      lag_first_by_penalty2
      lag_first_by_yards
      lag_first_by_yards2
      lag_kickoff_play
      lag_new_drive_pts
      lag_play_text
      lag_play_text2
      lag_play_type
      lag_play_type2
      lag_play_type3
      lag_pos_team
      lag_punt
      lag_punt2
      lag_scoring_play
      lag_turnover_vec
      lead_drive_result_detailed
      lead_play_text
      lead_play_type
      lead_pos_team
      log_ydstogo
      log_ydstogo_end
      middle_8
      missing_yard_flag
      net_away_EPA
      net_away_EPA_pass
      net_away_EPA_rush
      net_home_EPA
      net_home_EPA_pass
      net_home_EPA_rush
      new_drive_pts
      new_id
      new_series
      number_of_drives
      off_timeout_called
      off_timeouts_rem_before
      offense_conference
      offense_play
      offense_receives_2H_kickoff
      offense_score
      offense_score_play
      offense_timeouts
      opponent
      opponent_score
      orig_drive_number
      orig_play_type
      pass
      pass_attempt
      pass_breakup_player
      pass_breakup_player_id
      pass_breakup_player_name
      pass_breakup_stat
      pass_td
      passer_player_name
      penalty_1st_conv
      penalty_declined
      penalty_detail
      penalty_flag
      penalty_no_play
      penalty_offset
      penalty_play_text
      penalty_safety
      penalty_text
      period
      play_after_turnover
      play_id
      play_text
      play_type
      pos_score_diff
      pos_score_diff_start
      pos_score_diff_start_end
      pos_score_pts
      pos_team
      pos_team_receives_2H_kickoff
      pos_team_score
      pos_team_timeouts
      pos_team_timeouts_rem_before
      position_completion
      position_fumble
      position_fumble_forced
      position_fumble_recovered
      position_incompletion
      position_interception
      position_interception_thrown
      position_pass_breakup
      position_reception
      position_rush
      position_sack
      position_sack_taken
      position_target
      position_touchdown
      ppa
      pts_scored
      punt
      punt_block_player_name
      punt_block_return_player_name
      punt_blocked
      punt_downed
      punt_fair_catch
      punt_oob
      punt_play
      punt_returner_player_name
      punt_safety
      punt_tb
      punter_player_name
      receiver_player_name
      receives_2H_kickoff
      reception_player
      reception_player_id
      reception_yds
      row
      rush
      rush_player
      rush_player_id
      rush_td
      rush_yds
      rusher_player_name
      rz_play
      sack
      sack_player
      sack_player_id
      sack_player_name
      sack_player_name2
      sack_players
      sack_stat
      sack_taken_player
      sack_taken_player_id
      sack_taken_stat
      sack_vec
      safety
      score_diff
      score_diff_start
      score_pts
      scoring
      scoring_opp
      scoring_play
      season
      stuffed_run
      success
      target
      target_player
      target_player_id
      target_stat
      td_play
      team_score
      total_away_EPA
      total_away_EPA_pass
      total_away_EPA_rush
      total_home_EPA
      total_home_EPA_pass
      total_home_EPA_rush
      touchdown
      touchdown_player
      touchdown_player_id
      touchdown_stat
      turnover
      turnover_indicator
      turnover_vec
      turnover_vec_lag
      week
      wp_after
      wp_before
      wpa
      yard_line
      yards_gained
      yards_to_goal
      yards_to_goal_end
      yds_fg
      yds_fumble_return
      yds_int_return
      yds_kickoff
      yds_kickoff_return
      yds_penalty
      yds_punt_gained
      yds_punt_return
      yds_punted
      yds_receiving
      yds_rushed
      yds_sacked
      year
      winner
      spread
      pos_team_spread
      elapsed_share
      spread_time
      is_home
      win_indicator
      ExpScoreDiff_end
      adj_TimeSecsRem_end
      ExpScoreDiff_Time_Ratio_end
      elapsed_share_end
      spread_time_end
      WP_NFL_start
      WP_NFL_end
      WPA_NFL

      0
      -0.470573
      0.833168
      0.000231
      0.134882
      0.170347
      False
      False
      0.002152
      0.001775
      0.121537
      0.089202
      0.004375
      0.001915
      0.343792
      0.260404
      0.002997
      0.002950
      0.390266
      0.473408
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.470573
      NaN
      NaN
      0.528336
      0.509680
      0
      1
      15
      0
      0
      None
      NaN
      NaN
      0.470573
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.528336
      0.509680
      American Athletic
      East Carolina
      0
      0
      3.0
      10.0
      10.0
      1.0
      1
      0
      1
      66
      1
      4.005476e+09
      1
      1
      1
      1
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.362595
      0.833168
      0.0
      None
      0.0
      None
      False
      NaN
      None
      1.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      1
      1
      30
      1
      East Carolina
      -0.470573
      NaN
      NaN
      0.471664
      0.490320
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      1
      0
      0
      0
      0
      1
      Brandon McLaren
      Isaiah Jones
      0.0
      0
      0.0
      0.0
      0.0
      NaN
      0.0
      None
      0
      NaN
      0.0
      NaN
      0.0
      NaN
      None
      None
      None
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      East Carolina
      2.302585
      2.302585
      False
      False
      0.941145
      0.000000
      0.0
      -0.941145
      0.000000
      0.0
      0
      101849902
      1.0
      1
      0.0
      3.0
      None
      North Carolina Central
      1
      0
      0
      3.0
      None
      NaN
      1
      Kickoff
      0
      0
      None
      NaN
      None
      NaN
      0
      None
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      NaN
      None
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Kickoff
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      None
      NaN
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      None
      0.0
      None
      NaN
      NaN
      1
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      NaN
      0
      1.0
      0
      None
      NaN
      NaN
      0
      NaN
      0.470573
      0.0
      0.0
      -0.470573
      0.000000
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      NaN
      1
      0.471664
      0.490320
      -0.018655
      65
      6
      65
      80.0
      NaN
      NaN
      NaN
      51.0
      6.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      0.362595
      5400
      0.000067
      -0.5
      288.173188
      0.985915
      0.983851
      -0.002065

      1
      -0.168094
      0.362595
      0.000101
      0.128390
      0.134882
      False
      False
      0.002141
      0.002152
      0.124954
      0.121537
      0.003679
      0.004375
      0.355615
      0.343792
      0.003138
      0.002997
      0.382083
      0.390266
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.168094
      NaN
      NaN
      0.535004
      0.528336
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      4.0
      0.168094
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.535004
      0.528336
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      6.0
      1.0
      2
      0
      1
      66
      2
      4.005476e+09
      1
      1
      0
      2
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.194501
      0.362595
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      1
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      2
      1
      30
      2
      East Carolina
      -0.168094
      -0.168094
      NaN
      0.464996
      0.471664
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Punt
      0
      NaN
      0.0
      NaN
      1.0
      0.0
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      None
      Kickoff
      None
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      East Carolina
      2.302585
      1.791759
      False
      False
      1.277333
      0.168094
      0.0
      -1.277333
      -0.168094
      0.0
      0
      101849903
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      -0.088432
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      Justin Hardy
      505407.0
      4.0
      2
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      None
      NaN
      NaN
      0
      0.0
      0.638667
      0.0
      0.0
      -0.638667
      -0.168094
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.464996
      0.471664
      -0.006668
      20
      4
      80
      76.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      4.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      0.194501
      5400
      0.000036
      -0.5
      288.173188
      0.984520
      0.983389
      -0.001131

      2
      2.283941
      0.194501
      0.000054
      0.190673
      0.128390
      False
      False
      0.001539
      0.002141
      0.072094
      0.124954
      0.001135
      0.003679
      0.214480
      0.355615
      0.002843
      0.003138
      0.517235
      0.382083
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      -2.283941
      NaN
      NaN
      0.445405
      0.535004
      0
      0
      15
      0
      1
      Shane Carden
      500938.0
      20.0
      -2.283941
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.445405
      0.535004
      None
      North Carolina Central
      0
      0
      3.0
      6.0
      10.0
      2.0
      1
      0
      1
      66
      3
      4.005476e+09
      1
      1
      0
      3
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      2.478443
      0.194501
      1.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      1.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      3
      1
      30
      3
      East Carolina
      2.283941
      2.283941
      NaN
      0.554595
      0.464996
      4.005476e+09
      4.005476e+17
      None
      NaN
      NaN
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Justin Hardy for...
      Brandon McLaren kickoff for 51 yds , Isaiah Jo...
      Pass Reception
      Kickoff
      None
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      East Carolina
      1.791759
      2.302585
      False
      False
      -3.290549
      -2.115847
      0.0
      3.290549
      2.115847
      0.0
      0
      101849904
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Reception
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Reception
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      None
      None
      WR
      None
      2.104307
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Cam Worthy
      0.0
      Cam Worthy
      552953.0
      20.0
      3
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      1.0
      1
      None
      NaN
      NaN
      0
      0.0
      -1.645275
      0.0
      0.0
      1.645275
      2.115847
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.554595
      0.464996
      0.089599
      24
      20
      76
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      20.0
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      2.478443
      5400
      0.000459
      -0.5
      288.173188
      0.983777
      0.989738
      0.005961

      3
      -0.855503
      2.478443
      0.000688
      0.193531
      0.190673
      False
      False
      0.001703
      0.001539
      0.087026
      0.072094
      0.001516
      0.001135
      0.263697
      0.214480
      0.003072
      0.002843
      0.449456
      0.517235
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      0.855503
      NaN
      NaN
      0.478562
      0.445405
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      0.855503
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.478562
      0.445405
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      1.0
      2
      0
      1
      66
      4
      4.005476e+09
      1
      1
      0
      4
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      1.622940
      2.478443
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      1.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      4
      1
      30
      4
      East Carolina
      -0.855503
      -0.855503
      NaN
      0.521438
      0.554595
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      1.0
      0.0
      0.0
      0.0
      Shane Carden pass complete to Cam Worthy for 2...
      Shane Carden pass complete to Justin Hardy for...
      Pass Reception
      Pass Reception
      Kickoff
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      East Carolina
      2.302585
      2.302585
      False
      False
      -1.579543
      -1.260344
      0.0
      1.579543
      1.260344
      0.0
      0
      101849905
      1.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      East Carolina
      0.0
      1
      Pass Incompletion
      1
      1
      Michael Jones
      164873.0
      Michael Jones
      1.0
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Justin Hardy, ...
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -1.161247
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Justin Hardy
      0.0
      None
      NaN
      NaN
      4
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Justin Hardy
      505407.0
      1.0
      0
      0.0
      -0.789771
      0.0
      0.0
      0.789771
      1.260344
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.521438
      0.554595
      -0.033156
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      1.622940
      5400
      0.000300
      -0.5
      288.173188
      0.991003
      0.989213
      -0.001790

      4
      -1.130810
      1.622940
      0.000451
      0.185681
      0.193531
      False
      False
      0.001837
      0.001703
      0.109427
      0.087026
      0.002270
      0.001516
      0.329919
      0.263697
      0.003745
      0.003072
      0.367121
      0.449456
      1800
      1800.0
      False
      False
      False
      3600
      North Carolina Central
      1.130810
      NaN
      NaN
      0.523197
      0.478562
      0
      0
      15
      0
      0
      None
      NaN
      NaN
      1.130810
      North Carolina Central
      0
      3.0
      3.0
      0.0
      3.0
      0.523197
      0.478562
      None
      North Carolina Central
      0
      0
      3.0
      10.0
      10.0
      2.0
      3
      0
      1
      66
      5
      4.005476e+09
      1
      1
      0
      5
      0
      PUNT
      PUNT
      Punt
      None
      0
      1
      80
      1
      13
      15
      26
      34
      0
      14
      0
      0.492129
      1.622940
      0.0
      None
      0.0
      None
      False
      NaN
      None
      0.0
      0
      0
      0.0
      0
      0.0
      None
      NaN
      None
      NaN
      None
      NaN
      None
      None
      NaN
      None
      NaN
      NaN
      0
      400547643
      5
      1
      30
      5
      East Carolina
      -1.130810
      -1.130810
      NaN
      0.476803
      0.521438
      4.005476e+09
      4.005476e+17
      Shane Carden
      500938.0
      1.0
      0
      0
      None
      NaN
      None
      NaN
      None
      NaN
      NaN
      0
      0
      0
      0
      0
      0
      None
      None
      0.0
      0
      0.0
      0.0
      0.0
      0.0
      0.0
      Punt
      0
      0.0
      0.0
      1.0
      0.0
      0.0
      Shane Carden pass incomplete to Justin Hardy, ...
      Shane Carden pass complete to Cam Worthy for 2...
      Pass Incompletion
      Pass Reception
      Pass Reception
      East Carolina
      0.0
      0.0
      0.0
      0.0
      Punt
      EAST CAROLINA Penalty, false start (-5 Yards) ...
      Penalty
      East Carolina
      2.302585
      2.302585
      False
      False
      0.682078
      -0.129534
      0.0
      -0.682078
      0.129534
      0.0
      0
      101849906
      0.0
      1
      0.0
      3.0
      American Athletic
      East Carolina
      0
      0
      0
      3.0
      North Carolina Central
      0.0
      1
      Pass Incompletion
      1
      1
      None
      NaN
      None
      NaN
      0
      Shane Carden
      False
      False
      None
      False
      False
      False
      None
      0
      False
      1
      0.0
      None
      Shane Carden pass incomplete to Davon Grayson
      Pass Incompletion
      0
      0
      0.0
      0.0
      East Carolina
      0
      0
      3.0
      3.0
      None
      None
      None
      None
      QB
      None
      None
      None
      None
      None
      None
      None
      WR
      None
      -0.881290
      0
      0
      None
      None
      0.0
      0
      0
      0
      0
      None
      0.0
      0
      None
      Davon Grayson
      0.0
      None
      NaN
      NaN
      5
      0
      None
      NaN
      0
      NaN
      None
      0
      0
      None
      NaN
      None
      None
      None
      NaN
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      0.0
      False
      0
      0
      2014.0
      0
      0.0
      1
      Davon Grayson
      552937.0
      1.0
      0
      0.0
      0.341039
      0.0
      0.0
      -0.341039
      0.129534
      0.0
      0
      None
      NaN
      NaN
      0
      0.0
      0
      0.0
      1
      0.476803
      0.521438
      -0.044636
      44
      0
      56
      56.0
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      2014
      East Carolina
      39.0
      39.0
      0.0
      39.0
      1
      1
      0.492129
      5400
      0.000091
      -0.5
      288.173188
      0.989819
      0.984534
      -0.005285

```python
print("Diff from cfbscrapR model:")
print(f"Diff of WPA: {(base_data['wpa'] - base_data['WPA_NFL']).mean()}")
print(f"Diff of WP_start: {(base_data['wp_before'] - base_data['WP_NFL_start']).mean()}")
print(f"Diff of WP_end: {(base_data['wp_after'] - base_data['WP_NFL_end']).mean()}")
```

    Diff from cfbscrapR model:
    Diff of WPA: -0.0007160050340341484
    Diff of WP_start: -0.0016404073332568982
    Diff of WP_end: -0.0024357032654589513

```python
base_data[["wp_before","wp_after","wpa","WP_NFL_start","WP_NFL_end","WPA_NFL"]].head()
```

      wp_before
      wp_after
      wpa
      WP_NFL_start
      WP_NFL_end
      WPA_NFL

      0
      0.490320
      0.471664
      -0.018655
      0.985915
      0.983851
      -0.002065

      1
      0.471664
      0.464996
      -0.006668
      0.984520
      0.983389
      -0.001131

      2
      0.464996
      0.554595
      0.089599
      0.983777
      0.989738
      0.005961

      3
      0.554595
      0.521438
      -0.033156
      0.991003
      0.989213
      -0.001790

      4
      0.521438
      0.476803
      -0.044636
      0.989819
      0.984534
      -0.005285

```python
gathered = base_data.melt(id_vars=["period","win_indicator"], value_vars=["WP_NFL_start"],value_name="pred_prob")
gathered
```

      period
      win_indicator
      variable
      pred_prob

      0
      1
      1
      WP_NFL_start
      0.985915

      1
      1
      1
      WP_NFL_start
      0.984520

      2
      1
      1
      WP_NFL_start
      0.983777

      3
      1
      1
      WP_NFL_start
      0.991003

      4
      1
      1
      WP_NFL_start
      0.989819

      ...
      ...
      ...
      ...
      ...

      845808
      4
      0
      WP_NFL_start
      0.012452

      845809
      4
      1
      WP_NFL_start
      0.977425

      845810
      4
      1
      WP_NFL_start
      0.982198

      845811
      4
      1
      WP_NFL_start
      0.981976

      845812
      4
      1
      WP_NFL_start
      0.958588

845813 rows × 4 columns

```python
gathered['bin_pred_prob'] = (round(gathered.pred_prob / 0.05) * .05)
gathered
```

      period
      win_indicator
      variable
      pred_prob
      bin_pred_prob

      0
      1
      1
      WP_NFL_start
      0.985915
      1.00

      1
      1
      1
      WP_NFL_start
      0.984520
      1.00

      2
      1
      1
      WP_NFL_start
      0.983777
      1.00

      3
      1
      1
      WP_NFL_start
      0.991003
      1.00

      4
      1
      1
      WP_NFL_start
      0.989819
      1.00

      ...
      ...
      ...
      ...
      ...
      ...

      845808
      4
      0
      WP_NFL_start
      0.012452
      0.00

      845809
      4
      1
      WP_NFL_start
      0.977425
      1.00

      845810
      4
      1
      WP_NFL_start
      0.982198
      1.00

      845811
      4
      1
      WP_NFL_start
      0.981976
      1.00

      845812
      4
      1
      WP_NFL_start
      0.958588
      0.95

845813 rows × 5 columns

```python
gathered['bin_pred_prob'].value_counts()
```

    0.00    132152
    1.00    127837
    0.05     60967
    0.95     60185
    0.90     41096
    0.10     40615
    0.85     32765
    0.15     32151
    0.20     29521
    0.80     28438
    0.25     26931
    0.75     26711
    0.70     25440
    0.30     24750
    0.65     23929
    0.35     23432
    0.60     22842
    0.55     21968
    0.40     21943
    0.45     21173
    0.50     20967
    Name: bin_pred_prob, dtype: int64

```python
grouped_score = gathered.groupby(['period','bin_pred_prob'])
def organize(grp):
    d = {}
    d['n_plays'] = len(grp)
    d['n_wins'] = len(grp[grp.win_indicator == True])
    d['bin_actual_prob'] = d['n_wins'] / d['n_plays']
    return pd.Series(d, index=['n_plays','n_wins','bin_actual_prob'])

organized = grouped_score.apply(organize)
organized = organized.reset_index()
organized
```

      period
      bin_pred_prob
      n_plays
      n_wins
      bin_actual_prob

      0
      1
      0.00
      15064.0
      65.0
      0.004315

      1
      1
      0.05
      13636.0
      656.0
      0.048108

      2
      1
      0.10
      10373.0
      939.0
      0.090523

      3
      1
      0.15
      9494.0
      1380.0
      0.145355

      4
      1
      0.20
      10012.0
      2041.0
      0.203855

      5
      1
      0.25
      9238.0
      2451.0
      0.265317

      6
      1
      0.30
      8494.0
      2475.0
      0.291382

      7
      1
      0.35
      7565.0
      2675.0
      0.353602

      8
      1
      0.40
      7659.0
      3016.0
      0.393785

      9
      1
      0.45
      7285.0
      3277.0
      0.449828

      10
      1
      0.50
      7239.0
      3569.0
      0.493024

      11
      1
      0.55
      7439.0
      4192.0
      0.563517

      12
      1
      0.60
      7752.0
      4676.0
      0.603199

      13
      1
      0.65
      7279.0
      4677.0
      0.642533

      14
      1
      0.70
      8129.0
      5751.0
      0.707467

      15
      1
      0.75
      9212.0
      6937.0
      0.753040

      16
      1
      0.80
      9731.0
      7697.0
      0.790977

      17
      1
      0.85
      10655.0
      8987.0
      0.843454

      18
      1
      0.90
      11170.0
      10108.0
      0.904924

      19
      1
      0.95
      13981.0
      13437.0
      0.961090

      20
      1
      1.00
      13584.0
      13500.0
      0.993816

      21
      2
      0.00
      24279.0
      99.0
      0.004078

      22
      2
      0.05
      19178.0
      784.0
      0.040880

      23
      2
      0.10
      13734.0
      1370.0
      0.099752

      24
      2
      0.15
      10834.0
      1628.0
      0.150268

      25
      2
      0.20
      9308.0
      1889.0
      0.202944

      26
      2
      0.25
      8199.0
      2146.0
      0.261739

      27
      2
      0.30
      7447.0
      2226.0
      0.298912

      28
      2
      0.35
      7529.0
      2544.0
      0.337893

      29
      2
      0.40
      6615.0
      2605.0
      0.393802

      30
      2
      0.45
      6309.0
      2780.0
      0.440640

      31
      2
      0.50
      6224.0
      3176.0
      0.510283

      32
      2
      0.55
      6609.0
      3600.0
      0.544712

      33
      2
      0.60
      6888.0
      4286.0
      0.622242

      34
      2
      0.65
      7700.0
      4975.0
      0.646104

      35
      2
      0.70
      8082.0
      5685.0
      0.703415

      36
      2
      0.75
      8224.0
      6164.0
      0.749514

      37
      2
      0.80
      8951.0
      7075.0
      0.790414

      38
      2
      0.85
      10528.0
      8929.0
      0.848119

      39
      2
      0.90
      13933.0
      12546.0
      0.900452

      40
      2
      0.95
      17790.0
      17095.0
      0.960933

      41
      2
      1.00
      23880.0
      23765.0
      0.995184

      42
      3
      0.00
      36908.0
      143.0
      0.003874

      43
      3
      0.05
      15314.0
      612.0
      0.039963

      44
      3
      0.10
      9229.0
      803.0
      0.087008

      45
      3
      0.15
      6305.0
      905.0
      0.143537

      46
      3
      0.20
      5809.0
      1181.0
      0.203305

      47
      3
      0.25
      5527.0
      1347.0
      0.243713

      48
      3
      0.30
      5185.0
      1569.0
      0.302604

      49
      3
      0.35
      5071.0
      1818.0
      0.358509

      50
      3
      0.40
      4501.0
      1835.0
      0.407687

      51
      3
      0.45
      4629.0
      2053.0
      0.443508

      52
      3
      0.50
      4512.0
      2261.0
      0.501108

      53
      3
      0.55
      4742.0
      2525.0
      0.532476

      54
      3
      0.60
      4860.0
      2852.0
      0.586831

      55
      3
      0.65
      5458.0
      3537.0
      0.648040

      56
      3
      0.70
      5753.0
      3997.0
      0.694768

      57
      3
      0.75
      5593.0
      4309.0
      0.770427

      58
      3
      0.80
      5603.0
      4498.0
      0.802784

      59
      3
      0.85
      6372.0
      5508.0
      0.864407

      60
      3
      0.90
      8816.0
      8022.0
      0.909936

      61
      3
      0.95
      15604.0
      15046.0
      0.964240

      62
      3
      1.00
      34933.0
      34756.0
      0.994933

      63
      4
      0.00
      55901.0
      89.0
      0.001592

      64
      4
      0.05
      12839.0
      499.0
      0.038866

      65
      4
      0.10
      7279.0
      665.0
      0.091359

      66
      4
      0.15
      5518.0
      785.0
      0.142262

      67
      4
      0.20
      4392.0
      835.0
      0.190118

      68
      4
      0.25
      3967.0
      1022.0
      0.257625

      69
      4
      0.30
      3624.0
      1072.0
      0.295806

      70
      4
      0.35
      3267.0
      1167.0
      0.357208

      71
      4
      0.40
      3168.0
      1356.0
      0.428030

      72
      4
      0.45
      2950.0
      1339.0
      0.453898

      73
      4
      0.50
      2992.0
      1486.0
      0.496658

      74
      4
      0.55
      3178.0
      1696.0
      0.533669

      75
      4
      0.60
      3342.0
      1971.0
      0.589767

      76
      4
      0.65
      3492.0
      2229.0
      0.638316

      77
      4
      0.70
      3476.0
      2481.0
      0.713751

      78
      4
      0.75
      3682.0
      2776.0
      0.753938

      79
      4
      0.80
      4153.0
      3362.0
      0.809535

      80
      4
      0.85
      5210.0
      4466.0
      0.857198

      81
      4
      0.90
      7177.0
      6459.0
      0.899958

      82
      4
      0.95
      12810.0
      12316.0
      0.961436

      83
      4
      1.00
      55440.0
      55337.0
      0.998142

```python
organized['cal_diff'] = abs(organized.bin_pred_prob - organized.bin_actual_prob)
organized
```

      period
      bin_pred_prob
      n_plays
      n_wins
      bin_actual_prob
      cal_diff

      0
      1
      0.00
      15064.0
      65.0
      0.004315
      0.004315

      1
      1
      0.05
      13636.0
      656.0
      0.048108
      0.001892

      2
      1
      0.10
      10373.0
      939.0
      0.090523
      0.009477

      3
      1
      0.15
      9494.0
      1380.0
      0.145355
      0.004645

      4
      1
      0.20
      10012.0
      2041.0
      0.203855
      0.003855

      5
      1
      0.25
      9238.0
      2451.0
      0.265317
      0.015317

      6
      1
      0.30
      8494.0
      2475.0
      0.291382
      0.008618

      7
      1
      0.35
      7565.0
      2675.0
      0.353602
      0.003602

      8
      1
      0.40
      7659.0
      3016.0
      0.393785
      0.006215

      9
      1
      0.45
      7285.0
      3277.0
      0.449828
      0.000172

      10
      1
      0.50
      7239.0
      3569.0
      0.493024
      0.006976

      11
      1
      0.55
      7439.0
      4192.0
      0.563517
      0.013517

      12
      1
      0.60
      7752.0
      4676.0
      0.603199
      0.003199

      13
      1
      0.65
      7279.0
      4677.0
      0.642533
      0.007467

      14
      1
      0.70
      8129.0
      5751.0
      0.707467
      0.007467

      15
      1
      0.75
      9212.0
      6937.0
      0.753040
      0.003040

      16
      1
      0.80
      9731.0
      7697.0
      0.790977
      0.009023

      17
      1
      0.85
      10655.0
      8987.0
      0.843454
      0.006546

      18
      1
      0.90
      11170.0
      10108.0
      0.904924
      0.004924

      19
      1
      0.95
      13981.0
      13437.0
      0.961090
      0.011090

      20
      1
      1.00
      13584.0
      13500.0
      0.993816
      0.006184

      21
      2
      0.00
      24279.0
      99.0
      0.004078
      0.004078

      22
      2
      0.05
      19178.0
      784.0
      0.040880
      0.009120

      23
      2
      0.10
      13734.0
      1370.0
      0.099752
      0.000248

      24
      2
      0.15
      10834.0
      1628.0
      0.150268
      0.000268

      25
      2
      0.20
      9308.0
      1889.0
      0.202944
      0.002944

      26
      2
      0.25
      8199.0
      2146.0
      0.261739
      0.011739

      27
      2
      0.30
      7447.0
      2226.0
      0.298912
      0.001088

      28
      2
      0.35
      7529.0
      2544.0
      0.337893
      0.012107

      29
      2
      0.40
      6615.0
      2605.0
      0.393802
      0.006198

      30
      2
      0.45
      6309.0
      2780.0
      0.440640
      0.009360

      31
      2
      0.50
      6224.0
      3176.0
      0.510283
      0.010283

      32
      2
      0.55
      6609.0
      3600.0
      0.544712
      0.005288

      33
      2
      0.60
      6888.0
      4286.0
      0.622242
      0.022242

      34
      2
      0.65
      7700.0
      4975.0
      0.646104
      0.003896

      35
      2
      0.70
      8082.0
      5685.0
      0.703415
      0.003415

      36
      2
      0.75
      8224.0
      6164.0
      0.749514
      0.000486

      37
      2
      0.80
      8951.0
      7075.0
      0.790414
      0.009586

      38
      2
      0.85
      10528.0
      8929.0
      0.848119
      0.001881

      39
      2
      0.90
      13933.0
      12546.0
      0.900452
      0.000452

      40
      2
      0.95
      17790.0
      17095.0
      0.960933
      0.010933

      41
      2
      1.00
      23880.0
      23765.0
      0.995184
      0.004816

      42
      3
      0.00
      36908.0
      143.0
      0.003874
      0.003874

      43
      3
      0.05
      15314.0
      612.0
      0.039963
      0.010037

      44
      3
      0.10
      9229.0
      803.0
      0.087008
      0.012992

      45
      3
      0.15
      6305.0
      905.0
      0.143537
      0.006463

      46
      3
      0.20
      5809.0
      1181.0
      0.203305
      0.003305

      47
      3
      0.25
      5527.0
      1347.0
      0.243713
      0.006287

      48
      3
      0.30
      5185.0
      1569.0
      0.302604
      0.002604

      49
      3
      0.35
      5071.0
      1818.0
      0.358509
      0.008509

      50
      3
      0.40
      4501.0
      1835.0
      0.407687
      0.007687

      51
      3
      0.45
      4629.0
      2053.0
      0.443508
      0.006492

      52
      3
      0.50
      4512.0
      2261.0
      0.501108
      0.001108

      53
      3
      0.55
      4742.0
      2525.0
      0.532476
      0.017524

      54
      3
      0.60
      4860.0
      2852.0
      0.586831
      0.013169

      55
      3
      0.65
      5458.0
      3537.0
      0.648040
      0.001960

      56
      3
      0.70
      5753.0
      3997.0
      0.694768
      0.005232

      57
      3
      0.75
      5593.0
      4309.0
      0.770427
      0.020427

      58
      3
      0.80
      5603.0
      4498.0
      0.802784
      0.002784

      59
      3
      0.85
      6372.0
      5508.0
      0.864407
      0.014407

      60
      3
      0.90
      8816.0
      8022.0
      0.909936
      0.009936

      61
      3
      0.95
      15604.0
      15046.0
      0.964240
      0.014240

      62
      3
      1.00
      34933.0
      34756.0
      0.994933
      0.005067

      63
      4
      0.00
      55901.0
      89.0
      0.001592
      0.001592

      64
      4
      0.05
      12839.0
      499.0
      0.038866
      0.011134

      65
      4
      0.10
      7279.0
      665.0
      0.091359
      0.008641

      66
      4
      0.15
      5518.0
      785.0
      0.142262
      0.007738

      67
      4
      0.20
      4392.0
      835.0
      0.190118
      0.009882

      68
      4
      0.25
      3967.0
      1022.0
      0.257625
      0.007625

      69
      4
      0.30
      3624.0
      1072.0
      0.295806
      0.004194

      70
      4
      0.35
      3267.0
      1167.0
      0.357208
      0.007208

      71
      4
      0.40
      3168.0
      1356.0
      0.428030
      0.028030

      72
      4
      0.45
      2950.0
      1339.0
      0.453898
      0.003898

      73
      4
      0.50
      2992.0
      1486.0
      0.496658
      0.003342

      74
      4
      0.55
      3178.0
      1696.0
      0.533669
      0.016331

      75
      4
      0.60
      3342.0
      1971.0
      0.589767
      0.010233

      76
      4
      0.65
      3492.0
      2229.0
      0.638316
      0.011684

      77
      4
      0.70
      3476.0
      2481.0
      0.713751
      0.013751

      78
      4
      0.75
      3682.0
      2776.0
      0.753938
      0.003938

      79
      4
      0.80
      4153.0
      3362.0
      0.809535
      0.009535

      80
      4
      0.85
      5210.0
      4466.0
      0.857198
      0.007198

      81
      4
      0.90
      7177.0
      6459.0
      0.899958
      0.000042

      82
      4
      0.95
      12810.0
      12316.0
      0.961436
      0.011436

      83
      4
      1.00
      55440.0
      55337.0
      0.998142
      0.001858

```python
def organize_cal_err(grp):
    d = {}
    d['weight_cal_err'] = np.average(grp.cal_diff, weights=grp.n_plays)
    d['n_wins'] = sum(grp.n_wins)
    return pd.Series(d, index=['weight_cal_err', 'n_wins'])

cv_cal_error = organized.groupby('period')
final_cal_error = cv_cal_error.apply(organize_cal_err)
final_cal_error = final_cal_error.reset_index()
final_cal_error
```

      period
      weight_cal_err
      n_wins

      0
      1
      0.006503
      102506.0

      1
      2
      0.005763
      115367.0

      2
      3
      0.007642
      99577.0

      3
      4
      0.005178
      103408.0

```python
weighted_cal_err_final = np.average(final_cal_error.weight_cal_err, weights=final_cal_error.n_wins)
print(f"Weighted calibration error: {weighted_cal_err_final}")
```

    Weighted calibration error: 0.00624410573370445

```python
import sys
!{sys.executable} -m pip install coremltools==4.0
```

    Requirement already satisfied: coremltools==4.0 in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (4.0)
    Requirement already satisfied: tqdm in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (4.54.0)
    Requirement already satisfied: scipy in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (1.5.3)
    Requirement already satisfied: attr in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (0.3.1)
    Requirement already satisfied: packaging in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (20.4)
    Requirement already satisfied: protobuf>=3.1.0 in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (3.13.0)
    Requirement already satisfied: sympy in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (1.7)
    Requirement already satisfied: numpy>=1.14.5 in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (1.19.4)
    Requirement already satisfied: attrs in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (20.3.0)
    Requirement already satisfied: six>=1.10.0 in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from coremltools==4.0) (1.15.0)
    Requirement already satisfied: pyparsing>=2.0.2 in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from packaging->coremltools==4.0) (2.4.7)
    Requirement already satisfied: setuptools in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from protobuf>=3.1.0->coremltools==4.0) (49.6.0.post20201009)
    Requirement already satisfied: mpmath>=0.19 in /Users/akeaswaran/anaconda3/lib/python3.7/site-packages (from sympy->coremltools==4.0) (1.1.0)

```python
# # CoreML model
import coremltools as cml
# print(cml.version)

cml_inputs = {
    "pos_team_receives_2H_kickoff" : "If the current offense will receive the second half kickoff",
    "spread_time" : "The number of points that the offense is favored by, scaled by e^x, where x is the elapsed portion of the game ((3600 - adj_TimeSecsRem) / 3600)",
    "TimeSecsRem" : "The number of seconds left in the half.",
    "adj_TimeSecsRem" : "The number of seconds left in the game.",
    "ExpScoreDiff_Time_Ratio" : "The expected point differential divided by the number of seconds remaining in the game (plus 1).",
    "pos_score_diff_start" : "The current difference in score from the offense's perspective.",
    "down" : "The current down.",
    "distance" : "How many yards the offense must gain for a first down.",
    "yards_to_goal" : "The yards left until the current offense reaches the goal line.",
    "is_home" : "If the current offense is the home team",
    "pos_team_timeouts_rem_before" : "How many timeouts the current offense has remaining",
    "def_pos_team_timeouts_rem_before" : "How many timeouts the current defense has remaining",
    "period" : "The current quarter."
}

target_outputs = {
    "column" : "win_indicator",
    "description" : "The probability of the current offense winning the game."
}

def create_coreml_model(xgb_model, author, description, input_details, target_details, file_name):
    cml_model = cml.converters.xgboost.convert(xgb_model, mode="regressor", target=target_details['column'])

    cml_model.author = author#'Ben Baldwin (@benbbaldwin on Twitter, @guga31bb on GitHub) and Sebastian Carl (@mrcaseb on Twitter/GitHub) for model creation code; Saiem Gilani and Meyappan Subbiah for cfbscrapR training data; Akshay Easwaran for Python port.'
    cml_model.license = 'MIT'
    cml_model.short_description = description #''

    # Set feature descriptions manually
    for (column, desc) in input_details.items():
        cml_model.input_description[column] = desc

    # Set the output descriptions
    cml_model.output_description[target_details['column']] = target_details['description']

    # Save the model
    cml_model.save(f'{file_name}.mlmodel')
#     cml_model.get_spec()
    return cml_model

coreml_mdl_file = create_coreml_model(wp_model, "Ben Baldwin (@benbbaldwin on Twitter, @guga31bb on GitHub) and Sebastian Carl (@mrcaseb on Twitter/GitHub) for model creation code; Saiem Gilani and Meyappan Subbiah for cfbscrapR training data; Akshay Easwaran for Python port.", "Predicts the win probability of the offense for a given play. Translated from R, original model available as part of https://github.com/mrcaseb/nflfastR/.", cml_inputs, target_outputs, target_file_name)
# coreml_mdl_file.get_spec()
```

    WARNING:root:scikit-learn version 0.23.0 is not supported. Minimum required version: 0.17. Maximum required version: 0.19.2. Disabling scikit-learn conversion API.

```python
# test_json = pd.read_json("wp_xgb_dump.json")
# test_json.head()
```

```python
# len(test_json[test_json['split_condition'].isna()])
```

```python
grouped_plays = base_data[(base_data.down < 5) & (base_data.period < 5) & (~((base_data.play_text.str.contains("penalty")) | (base_data.play_text.str.contains("PENALTY"))))].groupby('play_type')
selected_groups = ["Passing Touchdown","Fumble Return Touchdown","Rushing Touchdown","Pass Completion","Field Goal Good","Pass Interception","Pass Incompletion","Rush","Field Goal Missed","Punt","Safety","Sack"]
composite_df = grouped_plays.apply(lambda x: x.sample(1)).reset_index(drop=True)
selection = composite_df[composite_df.play_type.isin(selected_groups)]
selection['time_spent'] = selection.TimeSecsRem - selection.TimeSecsRem_end

cols = ["id_play", "pos_team", "def_pos_team", "home", "away", "offense_score","defense_score","play_type","play_text","clock.minutes","clock.seconds","time_spent"] + model_columns_before + ["ep_before","ep_after","EPA","WP_NFL_start","WP_NFL_end","WPA_NFL"]

selection[cols].to_json("./wpa-model-test-items.json", orient="records")
selection
```

```python

```