Skip to content

Commit

Permalink
add drive start
Browse files Browse the repository at this point in the history
  • Loading branch information
akeaswaran committed Aug 24, 2024
1 parent f6a610d commit bfde13a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 8 additions & 5 deletions sportsdataverse/cfb/cfb_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
],
Expand Down
11 changes: 10 additions & 1 deletion tests/cfb/test_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
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())

0 comments on commit bfde13a

Please sign in to comment.