diff --git a/setup.py b/setup.py index f7f2af7..0e85d47 100755 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version="0.0.36.2.10", + version="0.0.36.2.11", description="Retrieve Sports data in Python", long_description=long_description, long_description_content_type="text/markdown", diff --git a/sportsdataverse/cfb/cfb_pbp.py b/sportsdataverse/cfb/cfb_pbp.py index f00c59d..a5d764f 100755 --- a/sportsdataverse/cfb/cfb_pbp.py +++ b/sportsdataverse/cfb/cfb_pbp.py @@ -5000,11 +5000,14 @@ def __process_wpa(self, play_df): def __add_drive_data(self, play_df): base_groups = play_df.groupby(["drive.id"], group_keys = False) - play_df["drive_start"] = np.where( - play_df["start.pos_team.id"] == play_df["homeTeamId"], - 100 - play_df["drive.start.yardLine"], - play_df["drive.start.yardLine"], - ) + + play_df["drive_start"] = play_df.loc[base_groups['start.yardsToEndzone'].head(1).index, 'start.yardsToEndzone'] #base_groups['start.yardsToEndzone'].head(1) + + # play_df["drive_start"] = np.where( + # play_df["start.pos_team.id"] == play_df["homeTeamId"], + # 100 - play_df["drive_start"], + # play_df["drive_start"], + # ) play_df["drive_stopped"] = np.select([ play_df['drive.result'].isna() ], diff --git a/tests/cfb/test_pbp.py b/tests/cfb/test_pbp.py index b97c07f..6c5dcb3 100755 --- a/tests/cfb/test_pbp.py +++ b/tests/cfb/test_pbp.py @@ -348,4 +348,13 @@ def test_bad_wp_after_situations(): search_cols = sorted(list(set(wp_start_columns + wp_end_columns + ["end.ExpScoreDiff", "start.ExpScoreDiff"]))) LOGGER.info(bad_wpa_play[["id", "text", "lead_play_text", "change_of_poss", "change_of_pos_team", "wp_after_case", "wp_before", "wp_after", "proper_time_set", "game_play_number"] + search_cols].to_json(orient = "records", indent = 2)) - assert bad_wpa_play.proper_time_set.all() \ No newline at end of file + assert bad_wpa_play.proper_time_set.all() + +def test_available_yards(): + test = CFBPlayProcess(gameId = 401635525) # Ohio St/Mich: 401520434 vs BC/SMU: 401551750 + test.espn_cfb_pbp() + json_dict_stuff = test.run_processing_pipeline() + + plays = test.plays_json + + LOGGER.info(plays["drive_start"].unique()) \ No newline at end of file