Skip to main content
Version: 0.1.5

NFL — additional Python functions — nflverse data releases: team_stats–trades

load_team_stats​

load_team_stats(seasons: 'List[int]', summary_level: 'str' = 'week', return_as_pandas=False, *, source: 'str' = 'nflverse') -> 'pl.DataFrame'

Load NFL team stats data going back to 1999

Parameters

ParameterTypeDefaultDescription
seasonslistUsed to define different seasons. 1999 is the earliest available season.
summary_levelstr'week'Aggregation level. One of "week", "reg", "post", "reg+post". Defaults to "week". Ignored when source is the SDV-native release (a single week-level parquet covering all seasons; filter post-load).
return_as_pandasboolFalseIf True, returns a pandas dataframe. If False, returns a polars dataframe.
sourcestr'nflverse'Which team-stats release to read. "nflverse" (the default) reads the per-season nflverse stats_team releases. "sportsdataverse" / "sdv" reads the SDV-native nfl_team_stats release (a single combined week-level parquet, built by sportsdataverse.nfl.build_nfl_team_stats from the SDV play-by-play and filtered to the requested seasons post-load).

Returns

Polars dataframe containing team stats available for the requested seasons.

col_nametypedescription
seasoninteger4 digit number indicating to which season(s) the specified timeframe belongs to.
weekintegerSeason week.
teamcharacterNFL team. Uses official abbreviations as per NFL.com
season_typecharacterREG or POST indicating if the timeframe belongs to regular or post season.
game_idcharacterTen digit identifier for NFL game.
opponent_teamcharacterAbbreviation of the opposing team the team faced in the game or week represented by this row.
completionsintegerThe number of completed passes.
attemptsintegerThe number of pass attempts as defined by the NFL.
passing_yardsintegerNumeric yards by the passer_player_name, including yards gained in pass plays with laterals. This should equal official passing statistics.
passing_tdsintegerThe number of passing touchdowns.
passing_interceptionsintegerTotal number of interceptions thrown by the team's quarterbacks during the period covered.
sacks_sufferedintegerTotal number of times the team's quarterback was sacked during the period covered.
sack_yards_lostintegerTotal yards lost by the team's offense as a result of being sacked.
sack_fumblesintegerThe number of sacks with a fumble.
sack_fumbles_lostintegerThe number of sacks with a lost fumble.
passing_air_yardsintegerPassing air yards (includes incomplete passes).
passing_yards_after_catchintegerYards 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_downsintegerFirst downs on pass attempts.
passing_epadoubleTotal 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_cpoedoubleCompletion percentage over expectation for the team's passing game — how much better or worse actual completion rate was versus the model-predicted rate. Percentage points (100 * the completion-rate gap), not a 0-1 rate.
passing_2pt_conversionsintegerTwo-point conversion passes.
passing_10integerNumber of the team's completed passes that gained 10 or more yards (one of nflfastR's 'explosive' play thresholds).
passing_16integerNumber of the team's completed passes that gained 16 or more yards (one of nflfastR's 'explosive' play thresholds).
passing_20integerNumber of the team's completed passes that gained 20 or more yards (one of nflfastR's 'explosive' play thresholds).
passing_40integerNumber of the team's completed passes that gained 40 or more yards (one of nflfastR's 'explosive' play thresholds).
carriesintegerThe number of official rush attempts (incl. scrambles and kneel downs). Rushes after a lateral reception don't count as carry.
rushing_yardsintegerNumeric 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_tdsintegerThe number of rushing touchdowns (incl. scrambles). Also includes touchdowns after obtaining a lateral on a play that started with a rushing attempt.
rushing_fumblesintegerThe number of rushes with a fumble.
rushing_fumbles_lostintegerThe number of rushes with a lost fumble.
rushing_first_downsintegerFirst downs on rush attempts (incl. scrambles).
rushing_epadoubleExpected points added on rush attempts (incl. scrambles and kneel downs).
rushing_2pt_conversionsintegerTwo-point conversion rushes
rushing_10integerNumber of the team's runs that gained 10 or more yards (one of nflfastR's 'explosive' play thresholds).
rushing_12integerNumber of the team's runs that gained 12 or more yards (one of nflfastR's 'explosive' play thresholds).
rushing_20integerNumber of the team's runs that gained 20 or more yards (one of nflfastR's 'explosive' play thresholds).
rushing_40integerNumber of the team's runs that gained 40 or more yards (one of nflfastR's 'explosive' play thresholds).
receptionsintegerThe number of pass receptions. Lateral receptions officially don't count as reception.
targetsintegerThe number of pass plays where the player was the targeted receiver.
receiving_yardsintegerNumeric 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_tdsintegerThe number of touchdowns following a pass reception. Also includes touchdowns after receiving a lateral on a play that started as a pass play.
receiving_fumblesintegerThe number of fumbles after a pass reception.
receiving_fumbles_lostintegerThe number of fumbles lost after a pass reception.
receiving_air_yardsintegerReceiving air yards (incl. incomplete passes).
receiving_yards_after_catchintegerYards 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_downsintegerTotal number of first downs gained on receptions
receiving_epadoubleTotal EPA on plays where this receiver was targeted
receiving_2pt_conversionsintegerTwo-point conversion receptions
receiving_10integerNumber of the team's receptions that gained 10 or more yards (one of nflfastR's 'explosive' play thresholds).
receiving_16integerNumber of the team's receptions that gained 16 or more yards (one of nflfastR's 'explosive' play thresholds).
receiving_20integerNumber of the team's receptions that gained 20 or more yards (one of nflfastR's 'explosive' play thresholds).
receiving_40integerNumber of the team's receptions that gained 40 or more yards (one of nflfastR's 'explosive' play thresholds).
special_teams_tdsintegerTotal number of kick/punt return touchdowns
def_tackles_solointegerTotal number of solo tackles for this player
def_tackles_with_assistintegerNumber of tackles this player had with an assisted tackle
def_tackle_assistsintegerNumber of assisted tackles for this player
def_tackles_for_lossintegerNumber of tackles for loss (TFL) for this player
def_tackles_for_loss_yardsintegerYards lost from TFLs involving this player
def_fumbles_forcedintegerNumber of times a fumble was forced from this player
def_sacksdoubleNumber of sacks form this player
def_sack_yardsdoubleYards lost from sacks forced by this player
def_qb_hitsintegerNumber of QB hits from this player (should not include plays where the QB was sacked)
def_interceptionsintegerNumber of interceptions forced by this player
def_interception_yardsintegeryards gained/lost by interception returns from this player
def_pass_defendedintegerNumber of passes defended/broken up by this player
def_tdsintegerNumber of defensive touchdowns scored by this player
def_fumblesintegerNumber of fumbles by this player
def_safetiesintegerNumber of safeties recorded by the team's defense (tackling an opponent in their own end zone).
def_punt_blocksintegerNumber of opponent punts blocked by the team's defense.
def_pat_blocksintegerNumber of opponent extra point attempts blocked by the team's defense.
def_fg_blocksintegerNumber of opponent field goal attempts blocked by the team's defense.
def_2pt_attsintegerNumber of defensive two-point conversion returns attempted by the team (nflfastR stat id 403).
def_2pt_madeintegerNumber of successful defensive two-point conversion returns by the team (nflfastR stat id 404).
misc_yardsintegerYards gained by the team through miscellaneous means not captured in standard rushing, passing, or return categories.
fumble_recovery_ownintegerNumber of the team's own fumbles that were recovered by the team itself.
fumble_recovery_yards_ownintegerTotal yards gained after recovering their own fumbles.
fumble_recovery_oppintegerNumber of fumbles recovered by the team from the opposing offense (defensive fumble recoveries).
fumble_recovery_yards_oppintegerTotal yards gained by the team on returns of opponent fumble recoveries.
fumble_recovery_tdsintegerNumber of touchdowns scored by the team on fumble recoveries (own or opponent).
penaltiesinteger
penalty_yardsintegerYards gained (or lost) by the posteam from the penalty.
timeoutsintegerNumber of timeouts remaining or used by the team during the game or period covered.
fumbles_forced_by_oppintegerFumbles by the team's players that were forced by the opponent, counted across all units (offense, defense and special teams).
fumbles_not_forcedintegerFumbles by the team's players that were not forced by the opponent, counted across all units.
fumbles_out_of_boundsintegerFumbles by the team's players where the ball went out of bounds, forced or not; each is also counted in fumbles_forced_by_opp or fumbles_not_forced.
fumbles_totalintegerTotal fumbles by the team's players across all units; equals fumbles_forced_by_opp + fumbles_not_forced.
fumbles_lost_totalintegerTotal fumbles lost by the team's players, counted across all units.
punt_returnsinteger
punt_return_yardsinteger
kickoff_returnsintegerTotal number of kickoff return attempts by the team.
kickoff_return_yardsintegerTotal yards gained by the team on kickoff returns during the period covered.
fg_madeinteger
fg_attintegerTotal field goal attempts by the team's kicker during the period covered.
fg_missedintegerTotal number of field goal attempts that were missed (not blocked, not made) by the team's kicker.
fg_blockedintegerTotal number of field goal attempts that were blocked by the opposing defense.
fg_longintegerDistance in yards of the team's longest successful field goal during the period covered.
fg_pctdouble
fg_made_0_19integerNumber of field goals made by the team from 0–19 yards.
fg_made_20_29integerNumber of field goals made by the team from 20–29 yards.
fg_made_30_39integerNumber of field goals made by the team from 30–39 yards.
fg_made_40_49integerNumber of field goals made by the team from 40–49 yards.
fg_made_50_59integerNumber of field goals made by the team from 50–59 yards.
fg_made_60_integerNumber of field goals made by the team from 60 yards or longer.
fg_missed_0_19integerNumber of field goal attempts missed from 0–19 yards.
fg_missed_20_29integerNumber of field goal attempts missed from 20–29 yards.
fg_missed_30_39integerNumber of field goal attempts missed from 30–39 yards.
fg_missed_40_49integerNumber of field goal attempts missed from 40–49 yards.
fg_missed_50_59integerNumber of field goal attempts missed from 50–59 yards.
fg_missed_60_integerNumber of field goal attempts missed from 60 yards or longer.
fg_made_listcharacterComma-separated list of distances (in yards) for each successful field goal made by the team.
fg_missed_listcharacterComma-separated list of distances (in yards) for each missed field goal attempt by the team.
fg_blocked_listcharacterComma-separated list of distances (in yards) for field goal attempts blocked by or against the team.
fg_made_distanceintegerTotal cumulative distance in yards of all successful field goals made by the team.
fg_missed_distanceintegerTotal cumulative distance in yards of all missed field goal attempts by the team.
fg_blocked_distanceintegerDistance in yards of the most recent or representative blocked field goal attempt.
pat_madeintegerTotal number of extra points successfully kicked by the team.
pat_attintegerTotal number of extra point (PAT) kick attempts by the team.
pat_missedintegerNumber of extra point kick attempts that were missed (neither made nor blocked).
pat_blockedintegerNumber of extra point attempts that were blocked by the opposing defense.
pat_pctdoubleExtra point conversion percentage (pat_made divided by pat_att) for the team's kicker.
gwfg_madeintegerNumber of game-winning field goals successfully converted by the team's kicker.
gwfg_attintegerNumber of game-winning field goal attempts (potential go-ahead kicks in the final moments).
gwfg_missedintegerNumber of game-winning field goal attempts that were missed by the team's kicker.
gwfg_blockedintegerNumber of game-winning field goal attempts that were blocked by the opposing defense.
gwfg_distanceintegerDistance in yards of the game-winning field goal attempt(s) during the period covered.
pt_attintegerNumber of punts kicked by the team; blocked punts are counted separately in pt_blocked.
pt_blockedintegerNumber of the team's punts that were blocked.
pt_longintegerLength in yards of the team's longest punt; null when the team had no kicked punt (never 0 in the 2024 sample).
pt_yardsintegerTotal gross yards of the team's punts.
pt_inside_20integerNumber of the team's punts credited as ending inside the opponent's 20-yard line (nflfastR defines the spot as where the return ended).
pt_out_of_boundsintegerNumber of the team's punts that went out of bounds without a return.
pt_downedintegerNumber of the team's punts that were downed without a return.
pt_touchbackintegerNumber of the team's punts that resulted in a touchback.
pt_fair_caughtintegerNumber of the team's punts that were fair caught by the opponent.
pt_returnedintegerNumber of the team's punts that were returned by the opponent.
pt_return_yardsintegerPunt return yards gained by the opponent on the team's punts; can be negative (minimum -4 in the 2024 sample).
pt_return_tdsintegerNumber of the team's punts that the opponent returned for a touchdown.
pt_net_yardsintegerNet punting yards: pt_yards minus pt_return_yards minus 20 yards per touchback.

Example

from sportsdataverse.nfl import load_nfl_team_stats
weekly = load_nfl_team_stats(seasons=[2024])

# Regular-season-only team stats

reg = load_nfl_team_stats(seasons=[2024], summary_level="reg")

# SDV-native team stats (built from SDV play-by-play)

sdv = load_nfl_team_stats(seasons=[2024], source="sdv")

load_teams​

load_teams(return_as_pandas=False) -> 'pl.DataFrame'

Load NFL team ID information and logos

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseIf True, returns a pandas dataframe. If False, returns a polars dataframe.

Returns

Polars dataframe containing teams available.

col_nametypedescription
team_abbrcharacterOfficial team abbreveation
team_namecharacter
team_idinteger
team_nickcharacterTeam nickname or mascot name (e.g., 'Chiefs', 'Patriots').
team_confcharacterConference the team belongs to (e.g., 'AFC', 'NFC').
team_divisioncharacterDivision within the conference the team belongs to (e.g., 'AFC East').
team_colorcharacter
team_color2characterSecondary brand color for the team, expressed as a hex color code.
team_color3characterTertiary brand color for the team, expressed as a hex color code.
team_color4characterQuaternary brand color for the team, expressed as a hex color code.
team_logo_wikipediacharacterURL of the team's logo image as hosted on Wikipedia.
team_logo_espncharacterURL of the team's primary logo as hosted on ESPN.
team_wordmarkcharacterURL of the team's wordmark (text-based logo) image.
team_conference_logocharacterURL of the conference logo image associated with the team.
team_league_logocharacterURL of the NFL league logo image.
team_logo_squaredcharacterURL of a square-format version of the team's logo.

Example

from sportsdataverse.nfl import load_nfl_teams
teams = load_nfl_teams()
teams.shape

# Pandas round-trip

teams_pd = load_nfl_teams(return_as_pandas=True)
teams_pd[["team_abbr", "team_name", "team_conf", "team_division"]].head()

load_trades​

load_trades(return_as_pandas=False) -> 'pl.DataFrame'

Load NFL trades data

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseIf True, returns a pandas dataframe. If False, returns a polars dataframe.

Returns

Polars dataframe containing NFL trade information.

col_nametypedescription
trade_idintegerID of Trade
seasoninteger4 digit number indicating to which season(s) the specified timeframe belongs to.
trade_datecharacterExact date that trade occurred
gavecharacterTeam that gave pick/player in row
receivedcharacterTeam that received pick/player in row
pick_seasonintegerDraft in which traded pick was in
pick_roundintegerRound in which traded pick was in
pick_numberintegerPick number of traded pick
conditionalintegerBinary indicator of whether or not traded pick was conditional
pfr_idcharacterPro-Football-Reference ID for player
pfr_namecharacterFull name of traded player

Example

from sportsdataverse.nfl import load_nfl_trades
trades = load_nfl_trades()
trades.shape

# Filter to a single season

import polars as pl
trades_2024 = load_nfl_trades().filter(pl.col("season") == 2024)