Skip to main content

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

NFLPlayProcess​

NFLPlayProcess(gameId=0, raw=False, path_to_json='/', return_keys=None, **kwargs)

Process ESPN NFL play-by-play feeds into a tidy game-level dictionary.

Wraps the ESPN summary endpoint (or a local JSON dump) and pipes the result through a chain of feature-engineering steps -- down/distance, play-type flags, EPA, WPA, QBR, drive aggregation, and an advanced box score. Use run_processing_pipeline() for the full feature set or run_cleaning_pipeline() for a lighter clean.

Parameters

ParameterTypeDefaultDescription
gameIdint0ESPN event id (e.g. 401671801).
rawboolFalseIf True, espn_nfl_pbp() returns the ESPN payload untouched. If False (default), it normalizes keys.
path_to_jsonstr'/'Directory containing {gameId}.json for the nfl_pbp_disk() flow (offline replay).
return_keyslist[str] | NoneNoneIf supplied, run_processing_pipeline returns only the listed keys from the result dict.

Example

from sportsdataverse.nfl import NFLPlayProcess
proc = NFLPlayProcess(gameId=401671801)
proc.espn_nfl_pbp()
result = proc.run_processing_pipeline()
len(result["plays"])

# Offline replay from a JSON dump

proc = NFLPlayProcess(gameId=401671801, path_to_json="./pbp_dump")
proc.nfl_pbp_disk()
cleaned = proc.run_cleaning_pipeline()

# Subset the return payload

proc = NFLPlayProcess(gameId=401671801, return_keys=["plays", "boxscore"])
proc.espn_nfl_pbp()
slim = proc.run_processing_pipeline()
sorted(slim.keys()) # ['boxscore', 'plays']

Methods

NFLPlayProcess.corrupt_pbp_check​

NFLPlayProcess.corrupt_pbp_check()

Detect ESPN payloads that look corrupt or partial.

Returns True when one of three guard conditions trips:

  • No plays at all.
  • Fewer than 50 plays for a game ESPN reports as completed.
  • More than 500 plays for a game ESPN reports as completed.

run_processing_pipeline() and run_cleaning_pipeline() use this to skip feature engineering on obviously broken payloads.

Returns

True if the payload looks corrupt; False otherwise.

Example

from sportsdataverse.nfl import NFLPlayProcess
proc = NFLPlayProcess(gameId=401671801)
proc.espn_nfl_pbp()
if not proc.corrupt_pbp_check():
result = proc.run_processing_pipeline()

NFLPlayProcess.create_box_score​

NFLPlayProcess.create_box_score(play_df)

Build the advanced box score (passer / rusher / receiver / team / situational / defensive / turnover / drives)

from a feature-engineered plays DataFrame.

This is normally called by run_processing_pipeline() -- it auto-runs the pipeline first if it hasn't been triggered yet, so callers can also invoke it directly on a freshly-instantiated processor.

Parameters

ParameterTypeDefaultDescription
play_dfpl.DataFrameThe plays frame produced after the full feature-engineering chain (downs, play-type flags, EPA, WPA, drive aggregation).

Returns

Box score keyed by "pass", "rush", "receiver", "team", "situational", "defensive", "turnover", "drives" -- each value a list of dicts ready to be serialized.

Example

from sportsdataverse.nfl import NFLPlayProcess
proc = NFLPlayProcess(gameId=401671801)
proc.espn_nfl_pbp()
result = proc.run_processing_pipeline()
box = result["advBoxScore"]
sorted(box.keys())

NFLPlayProcess.espn_nfl_pbp​

NFLPlayProcess.espn_nfl_pbp(summary=None, **kwargs)

espn_nfl_pbp() - Pull the game by id. Data from API endpoints: nfl/playbyplay, nfl/summary

Parameters

ParameterTypeDefaultDescription
summarydictNoneA previously fetched ESPN summary payload. When given, no request is made -- the offline path for committed raw libraries -- and the pipeline joins participants only if participants= was passed at construction (it never fetches them, nor a roster, for a supplied summary).

Returns

Dictionary of game data with keys - "gameId", "plays", "boxscore", "header", "broadcasts", "videos", "playByPlaySource", "standings", "leaders", "timeouts", "homeTeamSpread", "overUnder", "pickcenter", "againstTheSpread", "odds", "predictor", "winprobability", "espnWP", "gameInfo", "season"

Example

from sportsdataverse.nfl import NFLPlayProcess
proc = NFLPlayProcess(gameId=401220403)
payload = proc.espn_nfl_pbp()
sorted(payload.keys())[:5]

# Raw ESPN passthrough (no key normalization)

proc_raw = NFLPlayProcess(gameId=401220403, raw=True)
espn_dump = proc_raw.espn_nfl_pbp()

# Chain into the full processing pipeline

proc = NFLPlayProcess(gameId=401220403)
proc.espn_nfl_pbp()
result = proc.run_processing_pipeline()

NFLPlayProcess.nfl_pbp_disk​

NFLPlayProcess.nfl_pbp_disk()

Load a previously-saved ESPN payload from {path_to_json}/{gameId}.json.

Use this to replay an old game offline without hitting the ESPN endpoint -- handy for snapshot-driven tests and reproducible feature engineering.

Returns

The parsed JSON content; also stored on self.json.

Example

from sportsdataverse.nfl import NFLPlayProcess
proc = NFLPlayProcess(gameId=401220403, path_to_json="./pbp_dump")
proc.nfl_pbp_disk()
result = proc.run_processing_pipeline()

NFLPlayProcess.nfl_pbp_json​

NFLPlayProcess.nfl_pbp_json(**kwargs)

Return the JSON payload currently attached to this NFLPlayProcess instance.

espn_nfl_pbp() (live, or summary= offline) and nfl_pbp_disk() attach the payload; this returns it unchanged.

Returns

dict | None: The attached payload (self.json); None before one is attached.

Example

from sportsdataverse.nfl import NFLPlayProcess
proc = NFLPlayProcess(gameId=401220403)
proc.espn_nfl_pbp()
payload = proc.nfl_pbp_json()

NFLPlayProcess.run_cleaning_pipeline​

NFLPlayProcess.run_cleaning_pipeline()

Run the lighter cleaning pipeline against self.json.

Identical to run_processing_pipeline() up through the __add_spread_time step but stops short of EPA / WPA / QBR / drive aggregation and the advanced box score. Use this when you want clean play structure without the modeled features.

Returns

The cleaned game dict (or the subset specified by return_keys at construction).

Example

from sportsdataverse.nfl import NFLPlayProcess
proc = NFLPlayProcess(gameId=401671801)
proc.espn_nfl_pbp()
cleaned = proc.run_cleaning_pipeline()
"plays" in cleaned and "advBoxScore" not in cleaned

NFLPlayProcess.run_processing_pipeline​

NFLPlayProcess.run_processing_pipeline(validate: 'bool' = False)

Run the full feature-engineering pipeline against self.json.

Pipes the plays frame through the chain of helpers: downs, play-type flags, rush/pass flags, team-score variables, new play types, penalties, play-category flags, yardage cols, player cols, post-play cols, spread time, EPA, WPA, drive data, and QBR -- followed by the advanced box score build.

Parameters

ParameterTypeDefaultDescription
validateboolFalsewhen True, score the processed frame with the packaged per-game gate (sportsdataverse.validation) and attach its report dict under the "validation" key of the processed game ({} when the pipeline produced no plays). Name "validation" in return_keys to get it back when a subset was requested. Off by default -- the gate costs a few milliseconds and most callers do not read it.

Returns

Dict | None: The full processed game dict (or the subset specified by return_keys at construction). Returns the partial result when corrupt_pbp_check() short-circuits.

Example

from sportsdataverse.nfl import NFLPlayProcess
proc = NFLPlayProcess(gameId=401671801)
proc.espn_nfl_pbp()
result = proc.run_processing_pipeline()
len(result["plays"]), len(result["drives"])

# Subset returned keys for downstream serialization

proc = NFLPlayProcess(
gameId=401671801,
return_keys=["plays", "advBoxScore", "winprobability"],
)
proc.espn_nfl_pbp()
slim = proc.run_processing_pipeline()
sorted(slim.keys())

build_nfl_player_stats​

build_nfl_player_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 player_stats by aggregating SDV-native play-by-play.

A faithful polars port of nflfastR's calculate_player_stats (aggregate_game_stats.R): per-player passing / rushing / receiving frames are full-outer-joined on the group keys, special-teams touchdowns and fantasy points are added, and player metadata is joined from sportsdataverse.nfl.load_nfl_players. See the module docstring for the SDV-PBP column-gap handling (passing_epa uses the exact qb_epa; rushing_epa / receiving_epa use plain epa per nflfastR).

Parameters

ParameterTypeDefaultDescription
seasonsList[int]Four-digit NFL seasons to aggregate (e.g. [2023]).
summary_levelstr'week'"week" (group on season + week + player_id, with opponent_team) or "season" (group on season + player_id, with recent_team = last team and games = distinct game count).
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_player_stats schema. At summary_level="season" the week / season_type / opponent_team columns are replaced by a games column.

col_nametypedescription
player_idStringPlayer ID (aka GSIS ID) as defined by nflreadr::load_rosters
player_nameStringFull name of player
player_display_nameStringFull name of the player
positionStringPrimary position as reported by NFL.com
position_groupStringPostion group of player as listed by NFL
headshot_urlStringA URL string that points to player photos used by NFL.com (or sometimes ESPN)
recent_teamStringMost recent team player appears in pbp with.
seasonInt644 digit number indicating to which season(s) the specified timeframe belongs to.
weekInt64Season week.
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.
interceptionsInt64The number of interceptions thrown.
sacksInt64The Number of times sacked.
sack_yardsFloat64Yards lost on sack plays.
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_2pt_conversionsInt64Two-point conversion passes.
pacrFloat64Passing (yards) Air (yards) Conversion Ratio - the number of passing yards per air yards thrown per game
dakotaFloat64Adjusted EPA + CPOE composite based on coefficients which best predict adjusted EPA/play in the following year.
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
racrFloat64Receiving (yards) Air (yards) Conversion Ratio - the number of receiving yards per air yards targeted per game
target_shareFloat64"Player's share of team receiving targets in this game"
air_yards_shareFloat64Player's share of the team's air yards in this game
woprFloat64Weighted OPportunity Rating - 1.5 x target_share + 0.7 x air_yards_share - a weighted average that contextualizes total fantasy usage.
special_teams_tdsInt64Total number of kick/punt return touchdowns
fantasy_pointsFloat64Standard fantasy points.
fantasy_points_pprFloat64PPR fantasy points.

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_player_stats
wk = build_nfl_player_stats([2023], summary_level="week")
print(wk.shape)

# Season totals as pandas

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

# Pipeline next step (one line)

wk.filter(pl.col("attempts") >= 5).sort("passing_epa", descending=True).head()

build_nfl_player_stats_def​

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

Build player-level defensive stats from play-by-play (nflfastR parity).

A faithful polars port of nflfastR's deprecated calculate_player_stats_def() (aggregate_game_stats_def.R). Tackle, sack (half-sack = 0.5 weighting), pass-defense, interception, safety, fumble (own/opponent recovery), penalty, and touchdown sub-frames are each aggregated on (season, week, team=defteam, player_id) and full-outer joined together, then player metadata is joined from sportsdataverse.nfl.load_nfl_players.

Unlike build_nfl_player_stats, this function takes a caller-supplied pbp frame directly rather than loading one -- matching the R function's own signature.

Parameters

ParameterTypeDefaultDescription
pbpDataFramePlay-by-play frame carrying the wide nflverse defensive columns (solo_tackle_1_player_id, sack_player_id, half_sack_{1,2}_player_id, interception_player_id, pass_defense_{1,2}_player_id, fumbled_{1,2}_team / fumble_recovery_{1,2}_team, etc. -- the same columns sportsdataverse.nfl.load_nfl_pbp serves).
weeklyboolFalseIf True return one row per (season, week, player); if False collapse to one row per (player_id, team) -- note this does NOT retain a season column even if pbp spans multiple seasons (see the module-level note above), matching the R source's own group_by(player_id, team) (no season).
return_as_pandasboolFalseIf True return a pandas DataFrame; else polars.

Returns

A polars (or pandas) DataFrame with the def_* column set documented in the nflfastR-parity reference (weekly grain carries season/week/season_type; the season collapse replaces those with games).

col_nametypedescription
player_idStringPlayer ID (aka GSIS ID) as defined by nflreadr::load_rosters
player_nameStringFull name of player
player_display_nameStringFull name of the player
gamesInt64Games played in career
positionStringPrimary position as reported by NFL.com
position_groupStringPostion group of player as listed by NFL
headshot_urlStringA URL string that points to player photos used by NFL.com (or sometimes ESPN)
teamStringNFL team. Uses official abbreviations as per NFL.com
def_tacklesFloat64Total number of tackles for this player
def_tackles_soloFloat64Total number of solo tackles for this player
def_tackles_with_assistFloat64Number of tackles this player had with an assisted tackle
def_tackle_assistsFloat64Number of assisted tackles for this player
def_tackles_for_lossFloat64Number of tackles for loss (TFL) for this player
def_tackles_for_loss_yardsFloat64Yards lost from TFLs involving this player
def_fumbles_forcedFloat64Number 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_hitsFloat64Number of QB hits from this player (should not include plays where the QB was sacked)
def_interceptionsFloat64Number of interceptions forced by this player
def_interception_yardsFloat64yards gained/lost by interception returns from this player
def_pass_defendedFloat64Number of passes defended/broken up by this player
def_tdsFloat64Number of defensive touchdowns scored by this player
def_fumblesFloat64Number of fumbles by this player
def_fumble_recovery_ownFloat64Number of times a player's team fumbled the ball and this player recovered
def_fumble_recovery_yards_ownFloat64Number of yards gained/lost from fumble recoveries that happened because the player's team fumbled the ball and this player recovered the fumble on that same play
def_fumble_recovery_oppFloat64Number of times a player's opponent fumbled the ball and this player recovered
def_fumble_recovery_yards_oppFloat64Number of yards gained/lost from fumble recoveries that happened because the player's opponent fumbled the ball and this player recovered the fumble on that same play
def_safetyFloat64Number of times this player forced a defensive safety
def_penaltyFloat64Number of times this player was penalized defensively
def_penalty_yardsFloat64Number of penalty yards for this player defensively

Example

from sportsdataverse.nfl import build_nfl_player_stats_def, load_nfl_pbp
pbp = load_nfl_pbp([2023])
wk = build_nfl_player_stats_def(pbp, weekly=True)
print(wk.shape)

# Season totals (one season's worth of ``pbp`` at a time)

season = build_nfl_player_stats_def(pbp, weekly=False)

# Pipeline next step (one line)

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

build_nfl_player_stats_kicking​

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

Build player-level kicking stats from play-by-play (nflfastR parity).

A faithful polars port of nflfastR's deprecated calculate_player_stats_kicking() (aggregate_game_stats_kicking.R). Field goals (made-distance buckets, fg_long, fg_pct, ;-joined distance lists), extra points, and game-winning-FG attempts (last drive of the game, trailing by 2 or fewer points) are each aggregated on the kicker and full-outer joined together, then player metadata is joined from sportsdataverse.nfl.load_nfl_players.

Unlike build_nfl_team_stats, this function takes a caller-supplied pbp frame directly rather than loading one -- matching the R function's own signature.

Parameters

ParameterTypeDefaultDescription
pbpDataFramePlay-by-play frame carrying kicker_player_id / kicker_player_name, field_goal_attempt / field_goal_result / kick_distance, extra_point_attempt / extra_point_result, fixed_drive, and score_differential (the same columns sportsdataverse.nfl.load_nfl_pbp serves).
weeklyboolFalseIf True return one row per (season, week, player) with a gwfg_distance list column; if False collapse to one row per (player_id, team) with a games column and a ;-joined gwfg_distance_list string column in place of gwfg_distance (the R source's own deliberate column-name change based on the weekly flag). Note this does NOT retain a season column even if pbp spans multiple seasons (see the module-level note above build_nfl_player_stats_def).
return_as_pandasboolFalseIf True return a pandas DataFrame; else polars.

Returns

A polars (or pandas) DataFrame with the fg_*/pat_*/gwfg_* column set documented in the nflfastR-parity reference.

col_nametypedescription
player_idStringPlayer ID (aka GSIS ID) as defined by nflreadr::load_rosters
teamStringNFL team. Uses official abbreviations as per NFL.com
player_nameStringFull name of player
player_display_nameStringFull name of the player
gamesInt64Games played in career
positionStringPrimary position as reported by NFL.com
position_groupStringPostion group of player as listed by NFL
headshot_urlStringA URL string that points to player photos used by NFL.com (or sometimes ESPN)
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_attInt64
gwfg_distance_listString
gwfg_madeInt64
gwfg_missedInt64
gwfg_blockedInt64

Example

from sportsdataverse.nfl import build_nfl_player_stats_kicking, load_nfl_pbp
pbp = load_nfl_pbp([2023])
wk = build_nfl_player_stats_kicking(pbp, weekly=True)
print(wk.shape)

# Season totals (one season's worth of ``pbp`` at a time)

season = build_nfl_player_stats_kicking(pbp, weekly=False)

# Pipeline next step (one line)

wk.filter(pl.col("fg_att") >= 1).sort("fg_pct", descending=True).head()

build_nfl_rosters​

build_nfl_rosters(seasons: 'List[int]', *, return_as_pandas: 'bool' = False) -> "Union[pl.DataFrame, 'pd.DataFrame']"

Build SDV-native NFL season rosters from the public Shield API.

For each (season, team) the public NFL Shield endpoint /football/v2/rosters returns (reached through sportsdataverse.nfl.nfl_rosters), every player in the persons[] array is flattened onto the SDV-native season-roster schema, team abbreviations are folded to the nflverse standard (season-aware relocations), and cross-system IDs + college are enriched by a best-effort left join against sportsdataverse.nfl.load_nfl_players on gsis_id.

This is the public Shield tier only — a partial mirror of nflverse's full three-tier roster product. Shield supplies gsis_id densely across all seasons, but the cross-system IDs (espn_id, sportradar_id, yahoo_id, rotowire_id, pff_id, pfr_id, fantasy_data_id, sleeper_id) and college are only as dense as the players-table cross-walk, which is sparse for pre-2016 seasons. For the richest roster data prefer sportsdataverse.nfl.load_nfl_rosters (reads nflverse's published parquet); use build_nfl_rosters when you need an SDV-native frame that depends only on the live NFL Shield API.

Parameters

ParameterTypeDefaultDescription
seasonsList[int]Seasons to build (e.g. [2023] or range(2020, 2025)). A single int is accepted and wrapped. A season Shield returns no data for contributes no rows rather than raising.
return_as_pandasboolFalseIf True, return a pandas.DataFrame; otherwise a polars.DataFrame (default).

Returns

A one-row-per-player season-roster DataFrame with the documented schema. An empty / missing season yields a zero-row frame carrying the same column set (never a raise).

col_nametypedescription
seasonInt644 digit number indicating to which season(s) the specified timeframe belongs to.
teamStringNFL team. Uses official abbreviations as per NFL.com
positionStringPrimary position as reported by NFL.com
depth_chart_positionStringPosition assigned on depth chart. Not always accurate!
jersey_numberInt64Jersey number. Often useful for joins by name/team/jersey.
statusString
full_nameStringFull name as per NFL.com
first_nameStringFirst name of player
last_nameStringLast name of player
birth_dateStringPlayer birth date (sourced from NFL. Other sources may differ)
heightFloat64Official height, in inches
weightInt64Official weight, in pounds
collegeStringOfficial college (usually the last one attended)
gsis_idStringGame Stats and Info Service ID: the primary ID for play-by-play data.
espn_idStringESPN ID - usual format is an integer with ~5 digits
sportradar_idStringSportRadar ID - often also called sportsdata_id by other services. A UUID.
yahoo_idStringYahoo ID - usual format is an integer with ~5 digits
rotowire_idStringRotowire ID - usual format is an integer with ~four digits. Not to be confused with rotowire_id.
pff_idStringPro Football Focus ID - usually an integer with between 3 and 6 digits.
pfr_idStringPro-Football-Reference ID for player
fantasy_data_idStringFantasyData ID - usual format five digit integer
sleeper_idStringSleeper ID - usually an integer with ~4 digits.
years_expInt64Years played in league
headshot_urlStringA URL string that points to player photos used by NFL.com (or sometimes ESPN)
esb_idStringPlayer ID for Elias Sports Bureau
smart_idStringSMART ID for player (that's in raw pbp. It includes a hashed ESB_ID)
football_nameStringCommon player name (i.e. in most cases common_first_name last_name)
ngs_positionStringPrimary position as reported by the NextGen stats API.
entry_yearInt64The year a player first became eligible to play in the NFL.
rookie_yearInt64The year a player lost their rookie eligibility.

Raises

ExceptionDescription
TypeErrorIf seasons is not an int or an iterable of int.

Example

from sportsdataverse.nfl import build_nfl_rosters
rosters = build_nfl_rosters([2023])
print(rosters.shape)

# Multi-season build, pandas output

df = build_nfl_rosters(range(2021, 2024), return_as_pandas=True)

# Pipeline next step (one line)

import polars as pl
build_nfl_rosters([2023]).filter(pl.col("team") == "KC").head()