Skip to main content

NFL — additional Python functions — Play-by-play processing: build_nfl–calculate_nfl

build_nfl_season​

build_nfl_season(game_ids: 'list[int] | None' = None, *, seasons: 'list[int] | None' = None, source: 'str' = 'espn', return_as_pandas: 'bool' = False, raw_dir: "'str | Path | None'" = None, schedule_lookup: "'dict[str, dict[str, Any]] | None'" = None) -> "'pl.DataFrame | pd.DataFrame'"

Compile play-by-play for multiple NFL games into one tidy frame.

The source parameter determines which input parameter is required:

  • source="espn" — requires game_ids; seasons must be None.
  • source="nflverse" — requires seasons; game_ids must be None.
  • source="shield" — requires seasons and raw_dir; game_ids must be None.

For ESPN games the function either loads a previously cached plays frame or processes the game fresh via NFLPlayProcess. Individual game failures are logged and skipped so a single bad game does not abort the whole season build. The per-game frames are concatenated with how="diagonal_relaxed" (schema union, missing columns filled with null) so games with slightly different column sets merge cleanly.

Parameters

ParameterTypeDefaultDescription
game_idslist[int] | NoneNoneESPN event IDs to compile (e.g. [401671801, 401671802]). Required when source="espn"; must be None for other sources.
seasonslist[int] | NoneNoneSeason years to compile (e.g. [2023, 2024]). Required when source="nflverse"; must be None for other sources.
sourcestr'espn'Data source. - "espn" (default): each game is processed via NFLPlayProcess(gameId=gid).espn_nfl_pbp() + run_processing_pipeline(). Pass game_ids. - "nflverse": delegates to sportsdataverse.nfl.load_nfl_pbp for the requested seasons. Pass seasons. Returns the full pre-enriched season frame as-is. - "shield": reconstructs nflverse-shape play-by-play from a committed library of Shield (api.nfl.com) per-game JSON files via sportsdataverse.nfl.shield_pbp.build_season (the nflfastR parser port graduated from nfl-data's native_pbp). Pass seasons and raw_dir. Preseason games are skipped and TIMEOUT rows dropped, matching nflverse's row set. The frame is NOT EP/WP-enriched; feed it to sportsdataverse.nfl.ep_wp.enrich_nfl_pbp for the nfl_model_pbp columns.
return_as_pandasboolFalseIf True, return a pandas.DataFrame instead of polars.
raw_dirstr | Path | NoneNonesource="shield" only. Root of the per-game Shield JSON library laid out as {raw_dir}/{season}/{game_id}.json (the nfl-raw repo's nfl/raw). Required for the shield source; must be None otherwise.
schedule_lookupdict[str, dict[str, Any]] | NoneNonesource="shield" only. {game_id: {"roof": ..., "spread_line": ..., "total_line": ...}} supplying the game-level fields the Shield feed omits. None (default) builds it from sportsdataverse.nfl.load_nfl_schedule for each season, degrading to nulls with a RuntimeWarning if the schedule cannot be loaded. Pass {} to skip the lookup (hermetic; the three columns stay null).

Returns

All plays from the requested games/seasons, concatenated with schema-union semantics (missing columns are null). Returns a zero-row frame if every game failed (ESPN source only). When return_as_pandas is True, returns a pandas.DataFrame instead. For source="shield" the frame carries the nflverse base columns (233; a superset of the EP/WP/CP training contract) with the same names, types and meanings as sportsdataverse.nfl.load_nfl_model_pbp minus the EP/WP/CP enrichment columns: identifiers (game_id, play_id, posteam, defteam), game state (down, ydstogo, yardline_100, qtr, half_seconds_remaining, game_seconds_remaining, score_differential, posteam_timeouts_remaining), play classification (play_type, pass, rush, desc, yards_gained, touchdown, field_goal_result), drive/series (fixed_drive, fixed_drive_result, series, series_result), schedule fields (roof, spread_line, total_line) and game outcome (home_score, away_score, result). When no requested season has a regular-season or postseason game in raw_dir, the shield frame is empty with no columns: the column set comes from the games built, so check frame.height (or frame.width) before selecting columns.

col_nametypedescription
game_play_numberInt64
idInt64ID of the player in the 'name' column.
sequenceNumberInt64
textString
awayScoreInt64
homeScoreInt64
scoringPlayBooleanESPN flag marking the play as a scoring play.
priorityBoolean
modifiedString
wallclockString
teamParticipantsInt64Raw ESPN team-level participants payload carried through from the plays feed (stringified).
isPenaltyBooleanESPN's per-play flag that a penalty occurred on the play.
statYardageInt64Yardage ESPN credits to the play for statistical purposes.
isTurnoverBooleanESPN's per-play turnover flag as shipped in the plays feed (broader than the giveaway-based is_turnover derivation).
type.idStringESPN's numeric identifier for the play type.
type.textStringESPN's text label for the play type.
period.numberInt64Period (quarter) number in which the play occurred.
clock.displayValueStringGame clock at the play, as the displayed mm:ss string.
start.downInt64ESPN's down value for the play state at the start of the play.
start.distanceInt64ESPN's distance value for the play state at the start of the play.
start.yardLineInt64ESPN's yardLine value for the play state at the start of the play.
start.yardsToEndzoneInt64ESPN's yardsToEndzone value for the play state at the start of the play.
start.team.idInt64ESPN's team.id value for the play state at the start of the play.
end.downInt64ESPN's down value for the play state at the end of the play.
end.distanceInt64ESPN's distance value for the play state at the end of the play.
end.yardLineInt64ESPN's yardLine value for the play state at the end of the play.
end.yardsToEndzoneInt64ESPN's yardsToEndzone value for the play state at the end of the play.
end.team.idInt64ESPN's team.id value for the play state at the end of the play.
type.abbreviationStringESPN's abbreviation for the play type.
start.downDistanceTextStringESPN's downDistanceText value for the play state at the start of the play.
start.shortDownDistanceTextStringESPN's shortDownDistanceText value for the play state at the start of the play.
start.possessionTextStringESPN's possessionText value for the play state at the start of the play.
end.downDistanceTextStringESPN's downDistanceText value for the play state at the end of the play.
end.shortDownDistanceTextStringESPN's shortDownDistanceText value for the play state at the end of the play.
end.possessionTextStringESPN's possessionText value for the play state at the end of the play.
scoringType.nameStringESPN's name for the scoring type (e.g. touchdown, field goal).
scoringType.displayNameStringESPN's display label for the scoring type.
scoringType.abbreviationStringESPN's abbreviation for the scoring type.
pointAfterAttempt.idFloat64ESPN identifier for the point-after attempt type on the scoring play.
pointAfterAttempt.textStringESPN description of the point-after attempt and its result.
pointAfterAttempt.abbreviationStringESPN abbreviation of the point-after attempt type; drives the extra-point / two-point result derivation.
pointAfterAttempt.valueFloat64Points ESPN credits for the point-after attempt (1.0 made extra point, 2.0 made two-point try).
drive.idStringESPN's id field for the drive containing this play.
drive.displayResultStringESPN's displayResult field for the drive containing this play.
drive.isScoreBooleanESPN's isScore field for the drive containing this play.
drive.team.shortDisplayNameStringESPN's team.shortDisplayName field for the drive containing this play.
drive.team.displayNameStringESPN's team.displayName field for the drive containing this play.
drive.team.nameStringESPN's team.name field for the drive containing this play.
drive.team.abbreviationStringESPN's team.abbreviation field for the drive containing this play.
drive.yardsInt64ESPN's yards field for the drive containing this play.
drive.offensivePlaysInt64ESPN's offensivePlays field for the drive containing this play.
drive.resultStringESPN's result field for the drive containing this play.
drive.descriptionStringESPN's description field for the drive containing this play.
drive.shortDisplayResultStringESPN's shortDisplayResult field for the drive containing this play.
drive.timeElapsed.displayValueStringESPN's timeElapsed.displayValue field for the drive containing this play.
drive.start.period.numberInt64ESPN's start.period.number field for the drive containing this play.
drive.start.period.typeStringESPN's start.period.type field for the drive containing this play.
drive.start.yardLineInt64ESPN's start.yardLine field for the drive containing this play.
drive.start.clock.displayValueStringESPN's start.clock.displayValue field for the drive containing this play.
drive.start.textStringESPN's start.text field for the drive containing this play.
drive.end.period.numberInt64ESPN's end.period.number field for the drive containing this play.
drive.end.period.typeStringESPN's end.period.type field for the drive containing this play.
drive.end.yardLineInt64ESPN's end.yardLine field for the drive containing this play.
drive.end.clock.displayValueStringESPN's end.clock.displayValue field for the drive containing this play.
game_idInt64Ten digit identifier for NFL game.
seasonInt644 digit number indicating to which season(s) the specified timeframe belongs to.
seasonTypeInt64ESPN season type for the game (2 = regular season, 3 = postseason).
weekInt64Season week.
status_type_completedBoolean
homeTeamIdInt64ESPN's home-team Id for the game, stamped on every play.
awayTeamIdInt64ESPN's away-team Id for the game, stamped on every play.
homeTeamNameStringESPN's home-team Name for the game, stamped on every play.
awayTeamNameStringESPN's away-team Name for the game, stamped on every play.
homeTeamMascotStringESPN's home-team Mascot for the game, stamped on every play.
awayTeamMascotStringESPN's away-team Mascot for the game, stamped on every play.
homeTeamAbbrevStringESPN's home-team Abbrev for the game, stamped on every play.
awayTeamAbbrevStringESPN's away-team Abbrev for the game, stamped on every play.
homeTeamNameAltStringESPN's home-team NameAlt for the game, stamped on every play.
awayTeamNameAltStringESPN's away-team NameAlt for the game, stamped on every play.
gameSpreadFloat64Point spread used as an input to the win-probability model.
homeFavoriteBooleanTrue when the home team was favoured by the spread.
gameSpreadAvailableBooleanTrue when a spread was available for the game.
overUnderFloat64Over/under total used as a model input.
roofStringOne of 'dome', 'outdoors', 'closed', 'open' indicating indicating the roof status of the stadium the game was played in. (Source: Pro-Football-Reference)
homeTeamSpreadFloat64ESPN's home-team Spread for the game, stamped on every play.
clock.minutesInt64Minutes remaining on the game clock at the play.
clock.secondsInt64Seconds component of the game clock at the play.
halfInt64
lag_halfInt64Value of half on the previous play, used for sequence-aware derivations.
lead_halfInt64Value of half on the next play, used for sequence-aware derivations.
start.TimeSecsRemInt64Seconds remaining in the half from ESPN's clock stamp for this play, which is the end-of-play time in 2005 and 2007+ (the snap time in 2004 and most of 2006); tops out at 1800.
start.adj_TimeSecsRemInt64ESPN's adj_TimeSecsRem value for the play state at the start of the play.
orig_play_typeString
lead_textStringValue of text on the next play, used for sequence-aware derivations.
lead_start_teamStringValue of start_team on the next play, used for sequence-aware derivations.
lead_start_yardsToEndzoneInt64Value of start_yardsToEndzone on the next play, used for sequence-aware derivations.
lead_start_downInt64Value of start_down on the next play, used for sequence-aware derivations.
lead_start_distanceInt64Value of start_distance on the next play, used for sequence-aware derivations.
lead_scoringPlayBooleanValue of scoringPlay on the next play, used for sequence-aware derivations.
text_dupeBooleanAlways False in the emitted frame -- the duplicate-row filter it gates runs before the column is returned, so it marks nothing and is retained only for schema stability.
start.pos_team.idInt64ESPN's pos_team.id value for the play state at the start of the play.
start.def_pos_team.idInt64ESPN's def_pos_team.id value for the play state at the start of the play.
end.def_pos_team.idInt64ESPN's def_pos_team.id value for the play state at the end of the play.
end.pos_team.idInt64ESPN's pos_team.id value for the play state at the end of the play.
start.pos_team.nameStringESPN's pos_team.name value for the play state at the start of the play.
start.def_pos_team.nameStringESPN's def_pos_team.name value for the play state at the start of the play.
end.pos_team.nameStringESPN's pos_team.name value for the play state at the end of the play.
end.def_pos_team.nameStringESPN's def_pos_team.name value for the play state at the end of the play.
start.is_homeBooleanESPN's is_home value for the play state at the start of the play.
end.is_homeBooleanESPN's is_home value for the play state at the end of the play.
homeTimeoutCalledBooleanTrue when the home team called a timeout on the play.
awayTimeoutCalledBooleanTrue when the away team called a timeout on the play.
end.homeTeamTimeoutsInt64ESPN's homeTeamTimeouts value for the play state at the end of the play.
end.awayTeamTimeoutsInt64ESPN's awayTeamTimeouts value for the play state at the end of the play.
start.homeTeamTimeoutsInt64ESPN's homeTeamTimeouts value for the play state at the start of the play.
start.awayTeamTimeoutsInt64ESPN's awayTeamTimeouts value for the play state at the start of the play.
end.TimeSecsRemInt64Seconds remaining in the half carried as this play's end state; currently the preceding row's clock stamp.
end.adj_TimeSecsRemInt64ESPN's adj_TimeSecsRem value for the play state at the end of the play.
start.posTeamTimeoutsInt64ESPN's posTeamTimeouts value for the play state at the start of the play.
start.defPosTeamTimeoutsInt64ESPN's defPosTeamTimeouts value for the play state at the start of the play.
end.posTeamTimeoutsInt64ESPN's posTeamTimeouts value for the play state at the end of the play.
end.defPosTeamTimeoutsInt64ESPN's defPosTeamTimeouts value for the play state at the end of the play.
firstHalfKickoffTeamIdInt64ESPN id of the team that kicked the opening kickoff (it receives the second-half kickoff), one value per game.
periodInt64
start.yardInt64ESPN's yard value for the play state at the start of the play.
end.yardInt64ESPN's yard value for the play state at the end of the play.
lag_scoringPlayBooleanValue of scoringPlay on the previous play, used for sequence-aware derivations.
end_of_halfBoolean
down_1BooleanTrue when it is 1st down at the start of the play.
down_2BooleanTrue when it is 2nd down at the start of the play.
down_3BooleanTrue when it is 3rd down at the start of the play.
down_4BooleanTrue when it is 4th down at the start of the play.
down_1_endBooleanTrue when it is 1st down at the end of the play.
down_2_endBooleanTrue when it is 2nd down at the end of the play.
down_3_endBooleanTrue when it is 3rd down at the end of the play.
down_4_endBooleanTrue when it is 4th down at the end of the play.
scoring_playBoolean
td_playBoolean
touchdownBooleanBinary indicator for if the play resulted in a TD.
td_checkBooleanInternal flag used while reconciling whether the play produced a touchdown.
safetyBooleanBinary indicator for whether or not a safety occurred.
fumble_vecBoolean
forced_fumbleBooleanTrue when the defense forced a fumble on the play.
kickoff_playBoolean
kickoff_tbBoolean
kickoff_onsideBoolean
kickoff_oobBoolean
kickoff_fair_catchBooleanBinary indicator for if the kickoff was caught with a fair catch.
kickoff_downedBooleanBinary indicator for if the kickoff was downed.
kick_playBoolean
kickoff_safetyBoolean
puntBoolean
punt_playBoolean
punt_tbBoolean
punt_oobBoolean
punt_fair_catchBooleanBinary indicator for if the punt was caught with a fair catch.
punt_downedBooleanBinary indicator for if the punt was downed.
punt_safetyBoolean
punt_blockedBooleanBinary indicator for if the punt was blocked.
penalty_safetyBoolean
rushBooleanBinary indicator if the play was a rushing play.
passBooleanBinary indicator if the play was a pass play (sacks and scrambles included).
sack_vecBoolean
pos_teamInt64
def_pos_teamInt64
is_homeBoolean
lag_HA_score_diffInt64Value of HA_score_diff on the previous play, used for sequence-aware derivations.
HA_score_diffInt64Home score minus away score for the play.
net_HA_score_ptsInt64Net points the play added to the home-minus-away score margin.
H_score_diffInt64Home team's score minus the away team's, from the home perspective.
A_score_diffInt64Away team's score minus the home team's, from the away perspective.
lag_homeScoreInt64Value of homeScore on the previous play, used for sequence-aware derivations.
lag_awayScoreInt64Value of awayScore on the previous play, used for sequence-aware derivations.
start.homeScoreInt64ESPN's homeScore value for the play state at the start of the play.
start.awayScoreInt64ESPN's awayScore value for the play state at the start of the play.
end.homeScoreInt64ESPN's homeScore value for the play state at the end of the play.
end.awayScoreInt64ESPN's awayScore value for the play state at the end of the play.
pos_team_scoreInt64
def_pos_team_scoreInt64
start.pos_team_scoreInt64ESPN's pos_team_score value for the play state at the start of the play.
start.def_pos_team_scoreInt64ESPN's def_pos_team_score value for the play state at the start of the play.
start.pos_score_diffInt64ESPN's pos_score_diff value for the play state at the start of the play.
end.pos_team_scoreInt64ESPN's pos_team_score value for the play state at the end of the play.
end.def_pos_team_scoreInt64ESPN's def_pos_team_score value for the play state at the end of the play.
end.pos_score_diffInt64ESPN's pos_score_diff value for the play state at the end of the play.
lag_pos_teamInt64
lead_pos_teamInt64
lead_pos_team2Int64Value of pos_team 2 plays ahead, used for sequence-aware derivations.
pos_score_diffInt64
lag_pos_score_diffInt64
pos_score_ptsInt64
pos_score_diff_startInt64
start.pos_team_receives_2H_kickoffBooleanESPN's pos_team_receives_2H_kickoff value for the play state at the start of the play.
end.pos_team_receives_2H_kickoffBooleanESPN's pos_team_receives_2H_kickoff value for the play state at the end of the play.
change_of_possBoolean
penalty_flagBoolean
penalty_declinedBoolean
penalty_no_playBoolean
penalty_offsetBoolean
penalty_1st_convBoolean
penalty_in_textBooleanTrue when the play description mentions a penalty.
penalty_detailString
penalty_textString
yds_penaltyString
penalty_countInt64Number of penalties flagged on the play (0-4 observed).
penalty_declined_countInt64Number of the flagged penalties that were declined.
penalty_all_declinedBooleanWhether every penalty flagged on the play was declined.
penalty_enforcementStringHow the penalty was resolved: one of no_play, declined, offsetting, negating_foul, play_stands, unknown.
penalty_negated_playBooleanWhether the penalty negated the play's result.
sackBooleanBinary indicator for if the play ended in a sack.
intBoolean
int_tdBoolean
completionBoolean
pass_attemptBooleanBinary indicator for if the play was a pass attempt (includes sacks).
targetBoolean
pass_breakupBooleanTrue when a defender broke up the pass.
pass_tdBoolean
rush_tdBoolean
pass_depthStringThrown-pass depth parsed from ESPN play text ("short" or "deep"); null when the text omits it (sacks, screens, pre-2025 text).
pass_directionStringPass direction parsed from ESPN play text ("left", "middle", or "right"); null when the text omits it.
rush_directionStringRush direction parsed from ESPN play text ("left", "middle", or "right"); null when the text omits it.
turnover_vecBoolean
offense_score_playBoolean
defense_score_playBoolean
downs_turnoverBoolean
yds_puntedInt64
yds_punt_gainedInt64
fg_attemptBooleanTrue when the play was a field-goal attempt.
fg_madeBoolean
yds_fgInt64
pos_unitString
def_pos_unitString
lead_play_typeString
spBooleanBinary indicator for whether or not a score occurred on the play.
playBooleanBinary indicator: 1 if the play was a 'normal' play (including penalties), 0 otherwise.
scrimmage_playBooleanTrue when the play is a play from scrimmage rather than a special-teams or administrative row.
change_of_pos_teamBoolean
pos_score_diff_endInt64Score differential from the possessing team's perspective at the end of the play.
fumble_lostBooleanBinary indicator for if the fumble was lost.
fumble_recoveredBooleanTrue when a fumble on the play was recovered.
field_goal_resultStringString indicator for result of field goal attempt: made, missed, or blocked.
extra_point_resultStringString indicator for the result of the extra point attempt: good, failed, blocked, safety (touchback in defensive endzone is 1 point apparently), or aborted.
two_point_conv_resultStringString result of the two-point conversion attempt: success, failure, or safety (touchback in the defensive end zone).
kneel_downBooleanWhether the play is an offensive kneel, from explicit kneel text plus an end-of-half TEAM-rush heuristic.
qb_hurryBooleanWhether ESPN's play text says the quarterback was hurried into the throw ("hurried by ...").
xp_attemptBooleanWhether an extra-point kick was attempted on the play.
xp_madeBooleanWhether the extra-point kick was successful.
two_point_attemptBooleanBinary indicator for two point conversion attempt.
defensive_two_point_attemptBooleanBinary indicator whether or not the defense was able to have an attempt on a two point conversion, this results following a turnover.
defensive_two_point_convBooleanBinary indicator whether or not the defense successfully scored on the two point conversion.
two_point_passBoolean
two_point_rushBoolean
yds_rushedInt64
yds_receivingInt64
yds_int_returnString
yds_kickoffInt64
yds_kickoff_returnInt64
yds_punt_returnInt64
yds_fumble_returnString
yds_sackedInt64
sack_playersString
xp_kicker_player_nameStringName of the kicker attempting the extra point.
passer_player_nameStringString name for the player that attempted the pass.
rusher_player_nameStringString name for the player that attempted the run.
receiver_player_nameStringString name for the targeted receiver.
sack_player_nameStringString name of the player who recorded a solo sack.
sack_player_name2String
pass_breakup_player_nameString
interception_player_nameStringString name for the player that intercepted the pass.
fg_kicker_player_nameString
fg_block_player_nameString
fg_return_player_nameString
kickoff_player_nameString
kickoff_return_player_nameStringName of the player returning the kickoff, when the play was returned.
punter_player_nameStringString name for the punter.
punt_block_player_nameString
punt_return_player_nameStringName of the player returning the punt, when the punt was returned.
punt_block_return_player_nameString
fumble_player_nameString
fumble_forced_player_nameString
fumble_recovered_player_nameString
kicking_teamInt64Team id of the kicking team on kickoff, punt, and field-goal plays.
return_teamInt64Team id of the returning side; set on interception, fumble, kickoff, punt, and blocked-kick returns.
fumble_or_muffBooleanWhether the play includes a fumble or a muffed kick or punt (widened beyond ESPN's fumble play types).
recovery_teamStringTeam id parsed from the play text as recovering the fumble or muff.
recovery_team_2StringTeam id of the second recovery in a multi-recovery scramble, parsed from the play text.
penalty_spot_yardlineInt64Yard line (0-50) at which the penalty was spotted.
penalty_spot_sideStringSide of the field the penalty was spotted on: 'home', 'away' or 'mid' (midfield).
penalty_spot_yardsToEndzoneInt64Yards from the penalty spot to the end zone (0-100).
fumbling_teamStringTeam id of the side that fumbled or muffed the ball, parsed from the play text.
int_turnoverBooleanWhether the play is an interception giveaway.
pos_fumble_lostBooleanWhether the possession team fumbled and lost the ball.
def_fumble_lostBooleanWhether the defending team (e.g. a returner after a takeaway) fumbled and lost the ball back.
is_pos_team_turnoverBooleanWhether the possession team committed a giveaway (interception or fumble lost).
is_def_pos_team_turnoverBooleanWhether the defending team gave the ball back via a lost fumble.
is_turnoverBooleanTrue when the play is a giveaway-based turnover (interception thrown or fumble lost); blocked kicks recovered by the defense are carried by the blocked-kick fields instead.
turnover_teamStringTeam id charged with the giveaway on the play.
is_st_turnoverBooleanWhether the giveaway happened on a special-teams play (kick or punt snap, or a return).
is_blocked_punt_turnoverBooleanBlocked-punt possession loss (blocked-punt TD, or the defense recovered); kept out of is_turnover to match ESPN's giveaway-only box.
is_blocked_fg_turnoverBooleanBlocked-field-goal possession loss (blocked-FG TD, or the defense recovered); kept out of is_turnover to match ESPN's giveaway-only box.
sack_teamInt64Team id credited with the sack (the defense).
interception_teamInt64Team id credited with the interception (the defense).
pass_breakup_teamInt64Team id credited with the pass breakup (the defense).
forced_fumble_teamInt64Team id credited with forcing the fumble -- the side opposite the fumbling player (the covering team on returns).
fumble_recovery_teamStringTeam id that recovered the fumble or muff, from parsed text with a giveaway / own-recovery fallback.
punt_return_teamInt64Team id of the punt-returning side.
kick_return_teamInt64Team id of the kick-returning side.
fg_teamInt64Team id attempting the field goal (the kicking team).
punt_teamInt64Team id punting the ball (the kicking team).
penalized_teamInt64Team id the penalty was assessed against, from the home/away text resolver with a foul-direction fallback.
penalty_yards_signedInt64Penalty yardage parsed from the play text with era-aware bounds; the printed sign is retained but is not a reliable enforcement direction.
penalty_sideStringWhich side committed the penalty -- 'off' (offense) or 'def' (defense).
penalty_yards_netInt64Net yardage assessed for the penalty, signed relative to the possession team (observed -25 to 25).
penalty_team_idInt64Team id of the side that committed the penalty.
lateral_player_nameString
yds_lateralString
yards_after_catchStringNumeric value for distance in yards perpendicular to the yard line where the receiver made the reception to where the play ended.
air_yardsStringNumeric value for distance in yards perpendicular to the line of scrimmage at where the targeted receiver either caught or didn't catch the ball.
air_yardsToEndzoneStringYards to the endzone at the catch spot, parsed from the 2025+ vendor catch-spot text; null before 2025 or when unresolvable.
new_downInt64Down after the play, including any penalty enforcement.
new_distanceInt64Distance to go after the play, including any penalty enforcement.
middle_8Boolean
rz_playBoolean
under_2BooleanWhether the play began with two minutes or less remaining in the half.
goal_to_goBooleanBinary indicator for whether or not the posteam is in a goal down situation.
scoring_oppBoolean
stuffed_runBoolean
stopped_runBooleanTrue when the rush was stopped at or behind the line of scrimmage.
opportunity_runBoolean
highlight_runBooleanTrue when the rush gained 8 or more yards.
adj_rush_yardageInt64Rushing yards capped at 10, the input to the line-yards decomposition. Assets published before the 2026-10 line-yards fix cap at 8.
line_yardsFloat64Yards credited to the offensive line on a rush, on the standard adjusted-line-yards band: 1.2x the yardage on a loss, all of yards 0-4, half of each yard from 5 to 10, and nothing beyond 10 (a 7-yard ceiling). Line, second-level and open-field yards sum to the carry on every gain. Assets published before the 2026-10 line-yards fix carry the old band (all of yards 0-3, half of 4-8, a 5.5-yard ceiling).
second_level_yardsFloat64The ball carrier's half of yards 5-10 of a rush (the line takes the other half); 0 on carries of 4 yards or fewer. Assets published before the 2026-10 line-yards fix carry the old band here: half of yards 4-8 in college football, half of yards 5-8 in the NFL (where the old parts came up half a yard short of the carry).
open_field_yardsInt64Rushing yards gained beyond 10, credited to the ball carrier rather than the line. Assets published before the 2026-10 line-yards fix count the yards beyond 8.
highlight_yardsFloat64Second-level plus open-field yards -- the yardage credited to the carrier.
opp_highlight_yardsFloat64Highlight yards earned on opportunity runs, isolating carrier production on carries where the blocking succeeded. Assets published before the 2026-08 fix are identically 0 here, because the inverted opportunity_run gate could never co-occur with non-zero highlight yards.
short_rush_successBooleanTrue when a short-yardage rush gained the yardage needed.
short_rush_attemptBooleanTrue when the play is a rush in a short-yardage situation.
power_rush_successBooleanTrue when a power rushing attempt gained the yardage needed.
power_rush_attemptBooleanTrue when the play is a short-yardage power rushing attempt.
early_downBooleanTrue when the play is a scrimmage play on first or second down.
late_downBooleanTrue when the play is a scrimmage play on third or fourth down.
early_down_passBooleanTrue when the play is a pass on an early down.
early_down_rushBooleanTrue when the play is a rush on an early down.
late_down_passBooleanTrue when the play is a pass on a late down.
late_down_rushBooleanTrue when the play is a rush on a late down.
standard_downBooleanTrue when the offense is on schedule for the series -- first down, second down needing fewer than 8, or third/fourth down needing fewer than 5.
passing_downBooleanTrue when the offense is behind schedule for the series -- second down needing 8 or more, or third/fourth down needing 5 or more.
TFLBooleanTrue when the play was a tackle for loss.
TFL_passBooleanTrue when the play was a tackle for loss on a pass play (a sack).
TFL_rushBooleanTrue when the play was a tackle for loss on a rush play.
havocBooleanTrue when the defense disrupted the play: a pass breakup, tackle for loss, interception or forced fumble.
first_down_yardsBooleanWhether the play gained enough yardage to earn a first down.
first_down_penaltyBooleanBinary indicator for if a penalty converted the first down.
first_down_earnedBooleanWhether the play earned a first down by means other than yardage (e.g. by penalty).
new_seriesBoolean
firstD_by_kickoffBoolean
firstD_by_possBoolean
firstD_by_penaltyBoolean
firstD_by_yardsBoolean
start.pos_team_spreadFloat64ESPN's pos_team_spread value for the play state at the start of the play.
start.elapsed_shareFloat64ESPN's elapsed_share value for the play state at the start of the play.
start.spread_timeFloat64ESPN's spread_time value for the play state at the start of the play.
end.pos_team_spreadFloat64ESPN's pos_team_spread value for the play state at the end of the play.
end.elapsed_shareFloat64ESPN's elapsed_share value for the play state at the end of the play.
end.spread_timeFloat64ESPN's spread_time value for the play state at the end of the play.
pass_lengthStringString indicator for pass length: short or deep.
pass_locationStringString indicator for pass location: left, middle, or right.
shotgunInt64Binary indicator for whether or not the play was in shotgun formation.
no_huddleInt64Binary indicator for whether or not the play was in no_huddle formation.
pass_middleInt64
downInt64The down for the given play.
distanceInt64
start.yardsToEndzone.touchbackInt64ESPN's yardsToEndzone.touchback value for the play state at the start of the play.
penalty_assessed_on_kickoffBooleanWhether a penalty was assessed on a kickoff; such plays take the kickoff/touchback win-probability handling.
EP_start_touchbackFloat64Expected points the offense would have had from a touchback on this play.
EP_startFloat64Expected points for the offense at the start of the play.
EP_endFloat64Expected points for the offense at the end of the play.
EP_penalty_cfStringCounterfactual expected points for the penalty branch -- the EP had the alternative penalty outcome been taken (null unless a penalty decision existed).
penalty_cf_yardsToEndzoneStringYards to the end zone in the counterfactual penalty branch.
lag_EP_endFloat64Value of EP_end on the previous play, used for sequence-aware derivations.
lag_change_of_pos_teamBoolean
EP_betweenFloat64Change in expected points across the play, before penalty adjustment.
EPAFloat64
def_EPAFloat64
EPA_scrimmageFloat64EPA credited to the play on plays from scrimmage.
EPA_rushFloat64EPA credited to the play on rush plays.
EPA_passFloat64EPA credited to the play on pass plays.
EPA_explosiveBooleanTrue when the play was explosive.
EPA_non_explosiveFloat64EPA credited to the play on non-explosive plays.
EPA_explosive_passBooleanTrue when the pass play was explosive.
EPA_explosive_rushBooleanTrue when the rush play was explosive.
first_down_createdBooleanTrue when the play produced a first down for the offense.
EPA_successBooleanTrue when the play was successful by EPA.
EPA_success_early_downBooleanTrue when the play on an early down was successful by EPA.
EPA_success_early_down_passBooleanTrue when the pass play on an early down was successful by EPA.
EPA_success_early_down_rushBooleanTrue when the rush play on an early down was successful by EPA.
EPA_success_late_downBooleanTrue when the play on a late down was successful by EPA.
EPA_success_late_down_passBooleanTrue when the pass play on a late down was successful by EPA.
EPA_success_late_down_rushBooleanTrue when the rush play on a late down was successful by EPA.
EPA_success_standard_downBooleanTrue when the play on a standard down was successful by EPA.
EPA_success_passing_downBooleanTrue when the play on a passing down was successful by EPA.
EPA_success_passBooleanTrue when the pass play was successful by EPA.
EPA_success_rushBooleanTrue when the rush play was successful by EPA.
EPA_success_EPAFloat64EPA on successful plays.
EPA_success_standard_down_EPAFloat64EPA on successful plays on a standard down.
EPA_success_passing_down_EPAFloat64EPA on successful plays on a passing down.
EPA_success_pass_EPAFloat64EPA on successful pass plays.
EPA_success_rush_EPAFloat64EPA on successful rush plays.
EPA_middle_8_successBooleanTrue when the play in the middle eight was successful by EPA.
EPA_middle_8_success_passBooleanTrue when the pass play in the middle eight was successful by EPA.
EPA_middle_8_success_rushBooleanTrue when the rush play in the middle eight was successful by EPA.
EPA_penaltyFloat64EPA credited to the play attributable to penalties.
EPA_penalty_directFloat64EPA attributable directly to the penalty on the play, separated from the EPA of the play itself (observed -11.7 to 8.05; null when no penalty applied).
EPA_spFloat64EPA credited to the play on special-teams plays.
EPA_fgFloat64EPA credited to the play on field-goal attempts.
EPA_puntFloat64EPA credited to the play on punt plays.
EPA_kickoffFloat64EPA credited to the play on kickoff plays.
qb_epaFloat64Gives QB credit for EPA for up to the point where a receiver lost a fumble after a completed catch and makes EPA work more like passing yards on plays with fumbles.
start.ExpScoreDiff_touchbackFloat64ESPN's ExpScoreDiff_touchback value for the play state at the start of the play.
start.ExpScoreDiffFloat64ESPN's ExpScoreDiff value for the play state at the start of the play.
start.ExpScoreDiff_Time_Ratio_touchbackFloat64ESPN's ExpScoreDiff_Time_Ratio_touchback value for the play state at the start of the play.
start.ExpScoreDiff_Time_RatioFloat64ESPN's ExpScoreDiff_Time_Ratio value for the play state at the start of the play.
end.ExpScoreDiffFloat64ESPN's ExpScoreDiff value for the play state at the end of the play.
end.ExpScoreDiff_Time_RatioFloat64ESPN's ExpScoreDiff_Time_Ratio value for the play state at the end of the play.
wp_beforeFloat64
wp_touchbackFloat64Win probability the offense would have had starting from a touchback.
wp_afterFloat64
def_wp_beforeFloat64
home_wp_beforeFloat64
away_wp_beforeFloat64
lead_wp_beforeFloat64Value of wp_before on the next play, used for sequence-aware derivations.
lead_wp_before2Float64Value of wp_before 2 plays ahead, used for sequence-aware derivations.
def_wp_afterFloat64
home_wp_afterFloat64
away_wp_afterFloat64
wpaFloat64Win probability added (WPA) for the posteam.
wpFloat64Estimated win probability for the posteam given the current situation at the start of the given play.
vegas_wpFloat64Estimated win probability for the posteam given the current situation at the start of the given play, incorporating pre-game Vegas line.
def_wpFloat64Estimated win probability for the defteam.
home_wpFloat64Estimated win probability for the home team.
away_wpFloat64Estimated win probability for the away team.
wp_before_naiveFloat64Pre-snap possession-team win probability from the spread-free (naive) WP model.
wp_after_naiveFloat64End-of-play possession-team win probability from the naive model, after the game-logic adjustment chain.
wpa_naiveFloat64Win probability added on the play under the spread-free (naive) model.
def_wp_before_naiveFloat64Pre-snap defense win probability under the naive model (1 - wp_before_naive).
def_wp_after_naiveFloat64End-of-play defense win probability under the naive model.
home_wp_before_naiveFloat64Pre-snap naive win probability mapped to the home team.
home_wp_after_naiveFloat64End-of-play naive win probability mapped to the home team.
lead_wp_before_naiveFloat64Next play's pre-snap naive win probability, used in the end-of-half and change-of-possession adjustments.
lead_wp_before2_naiveFloat64Pre-snap naive win probability two plays ahead, used where the immediately following row is a non-play.
wp_touchback_naiveFloat64Naive-model win probability for the kickoff-touchback substitute state, used as the pre-snap WP on kickoffs.
away_wp_before_naiveFloat64Pre-snap naive win probability mapped to the away team.
away_wp_after_naiveFloat64End-of-play naive win probability mapped to the away team.
cpStringNumeric value indicating the probability for a complete pass based on comparable game situations.
cpoeStringFor a single pass play this is 1 - cp when the pass was completed or 0 - cp when the pass was incomplete. Analyzed for a whole game or season an indicator for the passer how much over or under expectation his completion percentage was.
xpassFloat64Probability of dropback scaled from 0 to 1.
pass_oeFloat64Dropback percent over expected on a given play scaled from 0 to 100.
xyac_epaStringExpected value of EPA gained after the catch, starting from where the catch was made. Zero yards after the catch would be listed as zero EPA.
xyac_mean_yardageStringAverage expected yards after the catch based on where the ball was caught.
xyac_median_yardageStringMedian expected yards after the catch based on where the ball was caught.
xyac_successStringProbability play earns positive EPA (relative to where play started) based on where ball was caught.
xyac_fdStringProbability play earns a first down based on where the ball was caught.
drive_startFloat64Yard line at which the drive began.
drive_stoppedBooleanTrue when the play ended the drive.
drive_play_indexInt64Sequence number of the play within its drive.
drive_offense_playsInt64Offensive plays run on the drive.
prog_drive_EPAFloat64Cumulative EPA accrued by the drive up to and including this play.
prog_drive_WPAFloat64Cumulative win-probability added by the drive up to and including this play.
drive_offense_yardsInt64Offensive yards gained on the drive.
drive_total_yardsInt64Total yards gained on the drive.
fixed_driveInt64Manually created drive number in a game.
fixed_drive_resultStringManually created drive result.
seriesInt64Starts at 1, each new first down increments, numbers shared across both teams NA: kickoffs, extra point/two point conversion attempts, non-plays, no posteam
series_resultStringPossible values: First down, Touchdown, Opp touchdown, Field goal, Missed field goal, Safety, Turnover, Punt, Turnover on downs, QB kneel, End of half
series_successInt641: scored touchdown, gained enough yards for first down.
go_wpFloat64Win probability from going for it on fourth down: conversion-probability-weighted mean of the success and failure states (cfb4th port).
first_down_probFloat64Modeled probability of converting the fourth down when going for it.
wp_succeedFloat64Mean win probability across yardage outcomes given the fourth-down attempt converts.
wp_failFloat64Mean win probability given the fourth-down attempt fails.
fg_make_probFloat64
make_fg_wpFloat64Win probability given the field-goal attempt is made.
miss_fg_wpFloat64Win probability given the field-goal attempt misses.
fg_wpFloat64Make-probability-weighted win probability of attempting the field goal.
punt_wpFloat64Win probability of punting, from the bundled punt-outcome distribution.
go_boostFloat64cfb4th's headline number: 100 * (go_wp - max(fg_wp, punt_wp)), in percentage points.
go_wp_diffFloat64go_wp minus the recommended option's WP (0 when going for it is the recommendation, otherwise <= 0).
punt_wp_diffFloat64punt_wp minus the recommended option's WP (0 when punting is the recommendation, otherwise <= 0).
fg_wp_diffFloat64fg_wp minus the recommended option's WP (0 when the field goal is the recommendation, otherwise <= 0).
fourth_down_recommendationStringMax-WP fourth-down choice among "go", "punt", and "field_goal".
two_pt_wpFloat64Win probability of going for two: conversion-probability-weighted mean of the 2-point and 0-point outcomes (cfb4th port).
xp_wpFloat64
prob_2ptFloat64
two_pt_wp_diffFloat64two_pt_wp minus xp_wp; positive favors going for two.
two_pt_recommendationStringPoint-after recommendation: "go_for_2" when two_pt_wp exceeds xp_wp, otherwise "kick_xp".
qbr_epaFloat64EPA variant used as an input to the QBR calculation.
weightFloat64Official weight, in pounds
non_fumble_sackBooleanTrue when the play was a sack that did not produce a fumble.
sack_epaFloat64EPA credited to the play when it is a sack.
pass_epaFloat64EPA credited to the play when it is a pass.
rush_epaFloat64EPA credited to the play when it is a rush.
pen_epaFloat64EPA attributable to a penalty on the play.
sack_weightFloat64Weighting applied to the sack component of the play.
pass_weightFloat64Weighting applied to the pass component of the play.
rush_weightFloat64Weighting applied to the rush component of the play.
pen_weightFloat64Weighting applied to the penalty component of the play.
action_playBooleanTrue when the play advanced the game state -- excludes timeouts, end-of-period markers and other non-action rows.
athlete_nameString
sack_player_id2StringESPN athlete id of the second sacker on a split sack (regex fallback for an ESPN sidecar blind spot).
passer_player_idStringUnique identifier for the player that attempted the pass.
rusher_player_idStringUnique identifier for the player that attempted the run.
receiver_player_idStringUnique identifier for the receiver that was targeted on the pass.
punter_player_idStringUnique identifier for the punter.
fg_kicker_player_idStringESPN athlete id of the field-goal kicker.
sack_player_idStringUnique identifier of the player who recorded a solo sack.
punt_return_player_idStringESPN athlete id of the punt returner.
kickoff_return_player_idStringESPN athlete id of the kickoff returner.
interception_player_idStringUnique identifier for the player that intercepted the pass.
pass_breakup_player_idString
fumble_forced_player_idString
fumble_recovered_player_idString
fumble_player_idString
punt_block_player_idStringESPN athlete id of the player who blocked the punt.
punt_block_return_player_idStringESPN athlete id of the player who returned the blocked punt.
kickoff_player_idStringESPN athlete id of the player kicking off.
fg_block_player_idStringESPN athlete id of the player who blocked the field goal.
fg_return_player_idStringESPN athlete id of the player who returned the blocked or missed field goal.
xp_kicker_player_idString

Raises

ExceptionDescription
ValueErrorIf source is not one of "espn", "nflverse", "shield"; or if the wrong input parameter is supplied for the chosen source (e.g. passing seasons to source="espn", game_ids to source="nflverse", or raw_dir to a non-shield source); or if the required parameter is missing or empty.

Example

from sportsdataverse.nfl import build_nfl_season
df = build_nfl_season(game_ids=[401671801, 401671802])
print(df.shape)

# nflverse season compile (pass season years)

from sportsdataverse.nfl import build_nfl_season
df = build_nfl_season(seasons=[2023], source="nflverse")
print(df.shape)

# Shield season compile from a committed raw library (nfl-raw checkout)

from sportsdataverse.nfl import build_nfl_season
df = build_nfl_season(seasons=[2024], source="shield", raw_dir="nfl-raw/nfl/raw")
print(df.shape)

# With filesystem cache enabled (ESPN)

from sportsdataverse.nfl import build_nfl_season, update_config
update_config(cache_mode="filesystem")
df = build_nfl_season(game_ids=[401671801, 401671802]) # processes + caches
df2 = build_nfl_season(game_ids=[401671801, 401671802]) # served from cache

# Pandas output

from sportsdataverse.nfl import build_nfl_season
df_pd = build_nfl_season(game_ids=[401671801], return_as_pandas=True)
print(df_pd.shape)

build_nfl_team_stats​

build_nfl_team_stats(seasons: 'List[int]', *, summary_level: 'str' = 'week', season_type: 'str' = 'REG', source: 'str' = 'sdv', return_as_pandas: 'bool' = False) -> "pl.DataFrame | 'pd.DataFrame'"

Build nflverse team_stats by aggregating SDV-native play-by-play.

A faithful polars port of nflfastR's calculate_stats(stat_type = "team") (the aggregate_game_stats* family). Offense is keyed on posteam, defense on the tackler's team (per-play *_team slot tags -- NOT defteam, which double-counts on return plays), kicking on posteam, and returns / penalties / timeouts on the relevant play team tag. See the module docstring for the full grouping + SDV-PBP gap notes (passing_epa uses the exact qb_epa; gwfg_* derive from fixed_drive).

Parameters

ParameterTypeDefaultDescription
seasonsList[int]Four-digit NFL seasons to aggregate (e.g. [2023]).
summary_levelstr'week'"week" (group on season + week + team, with opponent_team) or "season" (group on season + team, with a games distinct-game count replacing week / season_type / opponent_team).
season_typestr'REG'"REG", "POST", or "REG+POST". Pre-filters the play-by-play before aggregation.
sourcestr'sdv'Play-by-play release passed to load_nfl_pbp. Defaults to "sdv" (the SDV-native enriched release).
return_as_pandasboolFalseIf True return a pandas DataFrame; else polars.

Returns

A polars (or pandas) DataFrame in the published load_nfl_team_stats schema (~102 columns). At summary_level="season" the week / season_type / opponent_team columns are replaced by a games column.

col_nametypedescription
seasonInt644 digit number indicating to which season(s) the specified timeframe belongs to.
weekInt64Season week.
teamStringNFL team. Uses official abbreviations as per NFL.com
season_typeStringREG or POST indicating if the timeframe belongs to regular or post season.
opponent_teamString
completionsInt64The number of completed passes.
attemptsInt64The number of pass attempts as defined by the NFL.
passing_yardsFloat64Numeric yards by the passer_player_name, including yards gained in pass plays with laterals. This should equal official passing statistics.
passing_tdsInt64The number of passing touchdowns.
passing_interceptionsInt64
sacks_sufferedInt64
sack_yards_lostFloat64
sack_fumblesInt64The number of sacks with a fumble.
sack_fumbles_lostInt64The number of sacks with a lost fumble.
passing_air_yardsFloat64Passing air yards (includes incomplete passes).
passing_yards_after_catchFloat64Yards after the catch gained on plays in which player was the passer (this is an unofficial stat and may differ slightly between different sources).
passing_first_downsInt64First downs on pass attempts.
passing_epaFloat64Total expected points added on pass attempts and sacks. NOTE: this uses the variable qb_epa, which gives QB credit for EPA for up to the point where a receiver lost a fumble after a completed catch and makes EPA work more like passing yards on plays with fumbles.
passing_cpoeFloat64
passing_2pt_conversionsInt64Two-point conversion passes.
carriesInt64The number of official rush attempts (incl. scrambles and kneel downs). Rushes after a lateral reception don't count as carry.
rushing_yardsFloat64Numeric yards by the rusher_player_name, excluding yards gained in rush plays with laterals. This should equal official rushing statistics but could miss yards gained in rush plays with laterals. Please see the description of lateral_rusher_player_name for further information.
rushing_tdsInt64The number of rushing touchdowns (incl. scrambles). Also includes touchdowns after obtaining a lateral on a play that started with a rushing attempt.
rushing_fumblesInt64The number of rushes with a fumble.
rushing_fumbles_lostInt64The number of rushes with a lost fumble.
rushing_first_downsInt64First downs on rush attempts (incl. scrambles).
rushing_epaFloat64Expected points added on rush attempts (incl. scrambles and kneel downs).
rushing_2pt_conversionsInt64Two-point conversion rushes
receptionsInt64The number of pass receptions. Lateral receptions officially don't count as reception.
targetsInt64The number of pass plays where the player was the targeted receiver.
receiving_yardsFloat64Numeric yards by the receiver_player_name, excluding yards gained in pass plays with laterals. This should equal official receiving statistics but could miss yards gained in pass plays with laterals. Please see the description of lateral_receiver_player_name for further information.
receiving_tdsInt64The number of touchdowns following a pass reception. Also includes touchdowns after receiving a lateral on a play that started as a pass play.
receiving_fumblesInt64The number of fumbles after a pass reception.
receiving_fumbles_lostInt64The number of fumbles lost after a pass reception.
receiving_air_yardsFloat64Receiving air yards (incl. incomplete passes).
receiving_yards_after_catchFloat64Yards after the catch gained on plays in which player was receiver (this is an unofficial stat and may differ slightly between different sources).
receiving_first_downsInt64Total number of first downs gained on receptions
receiving_epaFloat64Total EPA on plays where this receiver was targeted
receiving_2pt_conversionsInt64Two-point conversion receptions
special_teams_tdsInt64Total number of kick/punt return touchdowns
def_tackles_soloInt64Total number of solo tackles for this player
def_tackles_with_assistInt64Number of tackles this player had with an assisted tackle
def_tackle_assistsInt64Number of assisted tackles for this player
def_tackles_for_lossInt64Number of tackles for loss (TFL) for this player
def_tackles_for_loss_yardsInt64Yards lost from TFLs involving this player
def_fumbles_forcedInt64Number of times a fumble was forced from this player
def_sacksFloat64Number of sacks form this player
def_sack_yardsFloat64Yards lost from sacks forced by this player
def_qb_hitsInt64Number of QB hits from this player (should not include plays where the QB was sacked)
def_interceptionsInt64Number of interceptions forced by this player
def_interception_yardsFloat64yards gained/lost by interception returns from this player
def_pass_defendedInt64Number of passes defended/broken up by this player
def_tdsInt64Number of defensive touchdowns scored by this player
def_fumblesInt64Number of fumbles by this player
def_safetiesInt64
misc_yardsInt64
fumble_recovery_ownInt64
fumble_recovery_yards_ownInt64
fumble_recovery_oppInt64
fumble_recovery_yards_oppInt64
fumble_recovery_tdsInt64
penaltiesInt64
penalty_yardsInt64Yards gained (or lost) by the posteam from the penalty.
timeoutsInt64
punt_returnsInt64
punt_return_yardsInt64
kickoff_returnsInt64
kickoff_return_yardsInt64
fg_madeInt64
fg_attInt64
fg_missedInt64
fg_blockedInt64
fg_longFloat64
fg_pctFloat64
fg_made_0_19Int64
fg_made_20_29Int64
fg_made_30_39Int64
fg_made_40_49Int64
fg_made_50_59Int64
fg_made_60_Int64
fg_missed_0_19Int64
fg_missed_20_29Int64
fg_missed_30_39Int64
fg_missed_40_49Int64
fg_missed_50_59Int64
fg_missed_60_Int64
fg_made_listString
fg_missed_listString
fg_blocked_listString
fg_made_distanceInt64
fg_missed_distanceInt64
fg_blocked_distanceInt64
pat_madeInt64
pat_attInt64
pat_missedInt64
pat_blockedInt64
pat_pctFloat64
gwfg_madeInt64
gwfg_attInt64
gwfg_missedInt64
gwfg_blockedInt64
gwfg_distanceInt64

Raises

ExceptionDescription
ValueErrorIf summary_level is not "week"/"season" or season_type is not "REG"/"POST"/"REG+POST".

Example

from sportsdataverse.nfl import build_nfl_team_stats
wk = build_nfl_team_stats([2023], summary_level="week")
print(wk.shape)

# Season totals as pandas

df_pd = build_nfl_team_stats([2023], summary_level="season",
return_as_pandas=True)

# Pipeline next step (one line)

wk.sort("def_sacks", descending=True).head()

calculate_nfl_series_conversion_rates​

calculate_nfl_series_conversion_rates(pbp: 'pl.DataFrame', *, weekly: 'bool' = False, return_as_pandas: 'bool' = False) -> "pl.DataFrame | 'pd.DataFrame'"

Compute per-team offense + defense series conversion rates.

A faithful polars port of nflfastR's calculate_series_conversion_rates. Series where down is null (kickoffs, PAT/2pt attempts, non-plays, no posteam) and series ending in a "QB kneel" are excluded from the series count before rates are computed, matching the R source.

Parameters

ParameterTypeDefaultDescription
pbpDataFramePlay-by-play frame carrying season, week, posteam, defteam, down, series, series_success, and series_result (added by the add_series_data port). Rows must already be in play order within each series so the internal first()/last() series collapse is correct.
weeklyboolFalseIf True, group on (season, team, week); if False (default), group on (season, team) -- collapsing every week into one season-level rate.
return_as_pandasboolFalseIf True return a pandas DataFrame; else polars.

Returns

A polars (or pandas) DataFrame with one row per team (per week when weekly=True), off_n/def_n (series count) plus the off_*/def_* rate columns documented in reference Sec 11. A team with offensive series but zero defensive series in a group (or vice versa -- effectively never happens in real data) carries nulls in the missing side rather than being dropped (full outer join).

col_nametypedescription
seasonInt644 digit number indicating to which season(s) the specified timeframe belongs to.
teamStringNFL team. Uses official abbreviations as per NFL.com
off_nInt64
off_scrFloat64
off_scr_1stFloat64
off_scr_2ndFloat64
off_scr_3rdFloat64
off_scr_4thFloat64
off_1stFloat64
off_tdFloat64
off_fgFloat64
off_puntFloat64
off_toFloat64
def_nInt64
def_scrFloat64
def_scr_1stFloat64
def_scr_2ndFloat64
def_scr_3rdFloat64
def_scr_4thFloat64
def_1stFloat64
def_tdFloat64
def_fgFloat64
def_puntFloat64
def_toFloat64

Example

from sportsdataverse.nfl import calculate_nfl_series_conversion_rates
rates = calculate_nfl_series_conversion_rates(pbp)
rates.filter(pl.col("team") == "KC").select("off_scr", "def_scr")

# Weekly grain

weekly = calculate_nfl_series_conversion_rates(pbp, weekly=True)

# Pipeline next step (one line)

rates.sort("off_scr", descending=True).head()