Skip to content

Commit

Permalink
fix for yardage neb turnover on downs play
Browse files Browse the repository at this point in the history
  • Loading branch information
akeaswaran committed Sep 1, 2024
1 parent a041ca7 commit d578302
Show file tree
Hide file tree
Showing 3 changed files with 23 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.13",
version="0.0.36.2.14",
description="Retrieve Sports data in Python",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
8 changes: 3 additions & 5 deletions sportsdataverse/cfb/cfb_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,7 @@ def __add_yardage_cols(self, play_df):
& (play_df.text.str.contains(" for .* y\w*ds?", regex = True, case = False)),

(play_df["pass"] == True)
& (play_df.text.str.contains(" complete to", case=False)),
& (play_df.text.str.contains(" complete to", case=False)) & (play_df.downs_turnover == True),

(play_df["pass"] == True)
& (play_df.text.str.contains(" complete to", case=False)),
Expand Down Expand Up @@ -2734,11 +2734,9 @@ def __add_yardage_cols(self, play_df):
.str.extract(r"(\d+)")[0]
.astype(float),

play_df['start.yardsToEndzone'] - play_df['end.yardsToEndzone'],
play_df['start.yardsToEndzone'] - (100 - play_df['end.yardsToEndzone']),

play_df.text.str.extract(r"((?<=for)[^,]+)", flags=re.IGNORECASE)[0]
.str.extract(r"(\d+)")[0]
.astype(float),
play_df['start.yardsToEndzone'] - play_df['end.yardsToEndzone'],

0.0,

Expand Down
20 changes: 19 additions & 1 deletion tests/cfb/test_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,22 @@ def test_bugged_pass_yards():
(edge_plays['text'].str.contains("Hudson Card pass complete to Drew Biber for 2 yds fumbled, forced by Maddix Blackwell, recovered by INST Garret Ollendieck G. Ollendieck return for 0 yds"))
]
LOGGER.info(edge_yards_play[["id", "text", "yds_receiving", "statYardage", "start.yardsToEndzone", "end.yardsToEndzone"]].to_json(orient = "records", indent = 2))
assert edge_yards_play.loc[edge_yards_play.index[0], 'yds_receiving'] == 2
assert edge_yards_play.loc[edge_yards_play.index[0], 'yds_receiving'] == 2


def test_neb_24wk1():
test = CFBPlayProcess(gameId = 401628454)
test.espn_cfb_pbp()
json_dict_stuff = test.run_processing_pipeline()

box = test.create_box_score()
LOGGER.info(box['pass'][0])
assert box['pass'][0]['Yds'] == (238.0 - 6.0)
# LOGGER.info(box['rush'][0])

# plays = test.plays_json
# bad_yards_play = plays[
# (plays['text'].str.contains(" pass complete ")) & (plays['text'].str.contains('Raiola '))
# ]
# LOGGER.info(bad_yards_play[["id", "text", "yds_passing", "yds_receiving", "statYardage", "start.yardsToEndzone", "end.yardsToEndzone", "yds_sacked"]].to_json(orient = "records", indent = 2))

0 comments on commit d578302

Please sign in to comment.