Skip to main content
Version: 0.2.0

NBA — additional Python functions — Analytics: nba_game–nba_play

nba_game_stints​

nba_game_stints(seasons: 'int | list[int]', *, league_id: 'str' = '00', return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Game stints: per player and game, every stretch on the floor with its clock, points and possessions.

The definitions are in sportsdataverse._common.game_stints.

Parameters

ParameterTypeDefaultDescription
seasonsint | list[int]A season or list of seasons, named by the year it ends (2026 is 2025-26). The WNBA season is its calendar year.
league_idstr'00'"00" NBA or "10" WNBA.
return_as_pandasboolFalseReturn a pandas frame instead of polars.

Returns

One row per (season, game_id, team_id, player_id, stint_number): opp_team_id, stint_number (1 = his first in the game), period, clock_in / clock_out (the period clock, seconds left, when the stint began and ended), seconds / minutes on the floor, poss / opp_poss (offensive / defensive possessions started), pts / opp_pts (team points scored / allowed), plus_minus and the player's own box in the stint (nba_box_events): points, fgm / fga, fg3m / fg3a, ftm / fta, oreb / dreb / reb, ast, stl, blk, tov and pf. Ids are the stats.nba.com ids (Int64; game_id a String). Empty input returns that schema with zero rows.

col_nametypedescription
seasonInt64Season, named by the year it ends (the WNBA season is its calendar year).
game_idStringstats.nba.com game id (e.g. 0022500101).
team_idInt64stats.nba.com team id.
opp_team_idInt64The opponent's team id.
player_idInt64stats.nba.com player (person) id.
stint_numberInt64The stint's place among the player's stints in the game, from 1 in game order. A stint is a run of consecutive actions of one period with him on the floor.
periodInt64Period of the stint (a stint never spans a period end).
clock_inFloat64Period clock (seconds left) when the stint began: the clock at the action before his first.
clock_outFloat64Period clock (seconds left) when the stint ended: the clock at his last action.
secondsFloat64Game-clock seconds of the stint: the clock that ran into each of its actions.
minutesFloat64Game-clock minutes of the stint (seconds / 60).
possInt64Offensive possessions that started during the stint (each counted on the lineup at the action that starts it).
opp_possInt64Defensive possessions that started during the stint, counted as poss is.
ptsInt64The team's points during the stint, each scoring action credited to the lineup at that action (a free throw to the lineup at the last foul).
opp_ptsInt64The opponent's points during the stint, credited as pts is.
plus_minusInt64The stint's +/-: pts - opp_pts.
pointsInt64Points the player scored: 2 or 3 per made field goal and 1 per made free throw, his own, on the stint's actions.
fgmInt64Field goals made, his own, on the stint's actions.
fgaInt64Field goals attempted, his own, on the stint's actions.
fg3mInt64Three-pointers made, his own, on the stint's actions.
fg3aInt64Three-pointers attempted, his own, on the stint's actions.
ftmInt64Free throws made, his own, on the stint's actions.
ftaInt64Free throws attempted, his own, on the stint's actions.
orebInt64Offensive rebounds (a team rebound is no player's), his own, on the stint's actions.
drebInt64Defensive rebounds (a team rebound is no player's), his own, on the stint's actions.
rebInt64Total rebounds in the stint: oreb + dreb.
astInt64Assists: made field goals the play-by-play credits him as the passer on, his own, on the stint's actions.
stlInt64Steals, his own, on the stint's actions.
blkInt64Blocked shots, his own, on the stint's actions.
tovInt64Turnovers (a team turnover is no player's), his own, on the stint's actions.
pfInt64Personal fouls (technicals are not counted), his own, on the stint's actions.

Raises

ExceptionDescription
ValueErrorIf league_id is not "00" or "10".

Example

from sportsdataverse.nba.nba_game_stints import nba_game_stints
stints = nba_game_stints(2026)
stints.filter(game_id="0022500101")

nba_game_story​

nba_game_story(pbp: 'pl.DataFrame', team_box: 'pl.DataFrame', player_box: 'pl.DataFrame', *, league: 'str' = 'nba', regulation_periods: 'int | None' = None, return_as_pandas: 'bool' = False) -> 'dict[str, pl.DataFrame] | dict[str, pd.DataFrame]'

How the winner won it, for one or many basketball games: edges in points, the moment, periods, runs, performers.

Parameters

ParameterTypeDefaultDescription
pbpDataFramePlays in the hoopR / wehoop pbp schema (load_<lg>_pbp or game_page_frames(...)["pbp"]), one or many games. With wp_delta (the game page's scored plays) it is used as given; without, each game is scored with ~sportsdataverse.nba.nba_game_page.score_win_prob (a neutral_site column is honoured; otherwise home court counts).
team_boxDataFrameThe games' team box rows (load_<lg>_team_boxscore); a game needs both rows for edges.
player_boxDataFrameThe games' player box rows (load_<lg>_player_boxscore).
leaguestr'nba'"nba", "wnba", "mbb" or "wbb".
regulation_periodsint | NoneNoneThe games' regulation periods (2 or 4), e.g. game_page_frames(...)["regulation_periods"] for a live game; default the league's rule for each game's season (~sportsdataverse.nba.nba_game_page.game_regulation_periods). Unscored plays are scored on it too.
return_as_pandasboolFalseReturn pandas frames instead of polars.

Returns

{"summary", "edges", "moment", "periods", "runs", "performers"}, the frames of ~sportsdataverse._common.game_story.GAME_STORY_SCHEMAS. Edges are the four accounting parts (shooting, turnovers, rebounding, free_throws, which add up to the margin), the box's point splits and second_chance_points (counted from the plays), ranked by points_worth. Periods are quarters (Q1) or halves (H1), then OT, OT2. Rows of any frame without a game_id are dropped with a UserWarning.

summary:

col_nametypedescription
game_idInt64The game's ESPN game id.
home_team_idInt64Home team's ESPN team id.
away_team_idInt64Away team's ESPN team id.
home_scoreInt64Home team's official final score.
away_scoreInt64Away team's official final score.
winner_team_idInt64Winning team's id; null on a tie.
loser_team_idInt64Losing team's id; null on a tie.
marginInt64Winner's final score less the loser's; 0 on a tie.
decidedBooleanTrue when the game has a winner (false on a tie).
periods_agreeBooleanTrue when the period sums (from the play-by-play's running score) equal the official final; false flags a source whose plays end on another score.
n_periodsInt64Periods played, overtimes included.
overtimeBooleanTrue when the game went past regulation.

edges:

col_nametypedescription
game_idInt64The game's ESPN game id.
winner_team_idInt64Winning team's id (null on a tie, where the edges read from the home side's view).
loser_team_idInt64Losing team's id (null on a tie).
edgeStringEdge name. Accounting: shooting, turnovers, rebounding, free_throws (the four-factor parts priced at the game's own pooled rates, adding up to the margin exactly). Splits: three_pt_points, points_off_turnovers, fast_break_points, points_in_paint (box points), second_chance_points (counted from the plays: points after an offensive rebound on the same possession).
kindStringaccounting for edges that split the game between them (their points_worth add up to the margin, exactly or nearly; see the function's docstring), split for overlapping cuts.
unitStringAlways points: the scoring unit the edges are priced in.
winner_valueFloat64Winner's value for the edge in the edge's own unit: points for a points edge, a rate for a rate edge.
loser_valueFloat64Loser's value for the edge, in the same unit as winner_value.
points_worthFloat64The winner's edge in the sport's scoring unit: the winner's points from the edge less the loser's. Positive favours the winner.
rankInt64Rank of the edge within the game by points_worth, 1 = largest; equal worths keep the edge list's order.

moment:

col_nametypedescription
game_idInt64The game's ESPN game id.
play_idInt64ESPN play id of the deciding moment.
orderInt64The play's position in the game's play order.
periodInt64Period of the play.
clockStringGame clock of the play as the source shows it.
team_idInt64Team of the play (the offense in football, the event's team in basketball).
textStringPlay description as the source writes it.
wpaFloat64Home win probability after the play less before it.
winner_wpaFloat64The same change from the winner's side (null on a tie).
home_scoreInt64Home score after the play.
away_scoreInt64Away score after the play.
ruleStringmax_abs_wpa: the play with the largest absolute win-probability change (earliest on ties); deciding_score where no play has one: the winner's first score after it was last level or behind, so it leads from there to the end.

periods:

col_nametypedescription
game_idInt64The game's ESPN game id.
periodInt64Period number, from 1; overtimes follow regulation.
period_labelStringQ1-Q4 for quarters or H1-H2 for halves, then OT, OT2, ...
is_overtimeBooleanTrue for a period after regulation.
home_ptsInt64Home points in the period: its last running score less the previous period's.
away_ptsInt64Away points in the period.
home_cumInt64Home running score at the end of the period.
away_cumInt64Away running score at the end of the period.

runs:

col_nametypedescription
game_idInt64The game's ESPN game id.
team_idInt64Team that made the run.
pointsInt64The side's largest unanswered run: points it scored in a row with no score by the other side (a score correction stays in the run and counts against its side).
start_orderInt64Play order of the run's first score.
end_orderInt64Play order of the run's last score.
start_periodInt64Period of the run's first score.
end_periodInt64Period of the run's last score.
home_score_afterInt64Home score at the end of the run.
away_score_afterInt64Away score at the end of the run.

performers:

col_nametypedescription
game_idInt64The game's ESPN game id.
team_idInt64Team of the top performer.
player_idInt64ESPN athlete id of the side's top performer.
player_nameStringPlayer's display name.
metricStringAlways points: the box score points the performer is chosen by.
valueFloat64The player's points (ties go to assists plus rebounds).

Raises

ExceptionDescription
ValueErrorIf league is not one of the four.
polars.exceptions.ColumnNotFoundErrorIf a frame lacks a column named above (pbp's id, game_play_number, period_number, clock_display_value, team_id, text, home_score, away_score; the boxes' ids, counts and team_home_away). A pbp without wp_delta is scored by ~sportsdataverse.nba.nba_game_page.score_win_prob, so it also needs that function's columns (home_team_spread, game_spread_available, start_game_seconds_remaining, the period clock, home_team_id). Plays without type_text, shooting_play or scoring_play do not raise: they only drop second_chance_points, as does a pbp that carries wp_delta but no period clock (start_quarter_seconds_remaining).

Example

import polars as pl
from sportsdataverse.nba import load_nba_pbp, load_nba_player_boxscore, load_nba_team_boxscore
from sportsdataverse.nba.nba_game_story import nba_game_story
gid = 401705718
pbp = load_nba_pbp([2025]).filter(pl.col("game_id") == gid)
tb = load_nba_team_boxscore([2025]).filter(pl.col("game_id") == gid)
pb = load_nba_player_boxscore([2025]).filter(pl.col("game_id") == gid)
story = nba_game_story(pbp, tb, pb)
story["edges"].head(3)

# A men's college game

from sportsdataverse.mbb import load_mbb_pbp, load_mbb_player_boxscore, load_mbb_team_boxscore
gid = 401830342
frames = [f([2026]).filter(pl.col("game_id") == gid) for f in (load_mbb_pbp, load_mbb_team_boxscore, load_mbb_player_boxscore)]
nba_game_story(*frames, league="mbb")["periods"] # H1, H2 and the overtimes

# A live game, from the game page's frames

from sportsdataverse.nba.nba_game_page import game_page_frames
fr = game_page_frames(final, league="nba") # final: espn_nba_pbp(game_id, return_parsed=False)
nba_game_story(fr["pbp"], fr["team_box"], fr["player_box"], regulation_periods=fr["regulation_periods"])

nba_game_units​

nba_game_units(seasons: 'int | list[int]', *, league_id: 'str' = '00', return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

In-game units: per 1- to 5-man set of teammates and game, minutes, ratings, four factors and shot zones.

The definitions are in sportsdataverse._common.game_stints.

Parameters

ParameterTypeDefaultDescription
seasonsint | list[int]A season or list of seasons, named by the year it ends (2026 is 2025-26). The WNBA season is its calendar year.
league_idstr'00'"00" NBA or "10" WNBA.
return_as_pandasboolFalseReturn a pandas frame instead of polars.

Returns

One row per (season, game_id, team_id, n_players, lineup_id): opp_team_id, n_players (1 to 5), lineup_id (the player ids sorted and joined with -), player_1..5, minutes / seconds, poss / opp_poss, pts / opp_pts, plus_minus, off_rtg / def_rtg / net_rtg (per 100 possessions), the four factors for (efg_pct, tov_pct, orb_pct, ft_rate) and against (opp_*), the shot zones for and against (rim_rate, mid_rate, fg3_rate shares of field-goal attempts, rim_pct, mid_pct, fg3_pct make rates, opp_*) as fractions, and every rate's <m>_n. Empty input returns that schema with zero rows.

col_nametypedescription
seasonInt64Season, named by the year it ends (the WNBA season is its calendar year).
game_idStringstats.nba.com game id (e.g. 0022500101).
team_idInt64stats.nba.com team id.
opp_team_idInt64The opponent's team id.
n_playersInt64Unit size: 1 to 5 players.
lineup_idStringThe unit's player ids, sorted and joined with '-'.
player_1Int64Player 1 of the unit, in lineup_id order; null past n_players.
player_2Int64Player 2 of the unit, in lineup_id order; null past n_players.
player_3Int64Player 3 of the unit, in lineup_id order; null past n_players.
player_4Int64Player 4 of the unit, in lineup_id order; null past n_players.
player_5Int64Player 5 of the unit, in lineup_id order; null past n_players.
minutesFloat64Game-clock minutes the unit's players were all on the floor together (seconds / 60).
secondsFloat64Game-clock seconds the unit's players were all on the floor together.
possInt64Offensive possessions with the unit on the floor (a possession counts for the five on the floor when it starts).
opp_possInt64Defensive possessions with the unit on the floor, counted as poss is.
ptsInt64The team's points with the unit on the floor, each scoring action credited to the lineup at that action (a free throw to the lineup at the last foul).
opp_ptsInt64The opponent's points with the unit on the floor, credited as pts is.
plus_minusInt64The unit's +/- in the game: pts - opp_pts.
off_rtgFloat64Offensive rating: pts per 100 poss. Null with a zero denominator.
def_rtgFloat64Defensive rating: opp_pts per 100 opp_poss. Null with a zero denominator.
net_rtgFloat64Net rating: off_rtg - def_rtg; null when either is null.
efg_pctFloat64Effective field-goal percentage, (FGM + 0.5 * 3PM) / FGA, as a fraction. Null with a zero denominator.
tov_pctFloat64Turnovers per offensive possession, as a fraction. Null with a zero denominator.
orb_pctFloat64Offensive-rebound rate: own offensive rebounds over own offensive rebounds plus the opponent's defensive rebounds. Null with a zero denominator.
ft_rateFloat64Free-throw rate: FTA / FGA. Null with a zero denominator.
opp_efg_pctFloat64The opponent's effective field-goal percentage with the unit on the floor. Null with a zero denominator.
opp_tov_pctFloat64The opponent's turnovers per defensive possession, as a fraction. Null with a zero denominator.
opp_orb_pctFloat64The opponent's offensive-rebound rate with the unit on the floor. Null with a zero denominator.
opp_ft_rateFloat64The opponent's free-throw rate: FTA / FGA. Null with a zero denominator.
rim_rateFloat64Share of the unit's field-goal attempts at the rim (a two under 4 feet). Null with a zero denominator.
mid_rateFloat64Share of the unit's field-goal attempts that are other twos (mid-range). Null with a zero denominator.
fg3_rateFloat64Share of the unit's field-goal attempts that are threes. Null with a zero denominator.
rim_pctFloat64Field-goal percentage at the rim, as a fraction. Null with a zero denominator.
mid_pctFloat64Mid-range field-goal percentage, as a fraction. Null with a zero denominator.
fg3_pctFloat64Three-point percentage, as a fraction. Null with a zero denominator.
opp_rim_rateFloat64Share of the opponent's field-goal attempts at the rim with the unit on the floor. Null with a zero denominator.
opp_mid_rateFloat64Share of the opponent's field-goal attempts that are mid-range twos. Null with a zero denominator.
opp_fg3_rateFloat64Share of the opponent's field-goal attempts that are threes. Null with a zero denominator.
opp_rim_pctFloat64The opponent's field-goal percentage at the rim. Null with a zero denominator.
opp_mid_pctFloat64The opponent's mid-range field-goal percentage with the unit on the floor. Null with a zero denominator.
opp_fg3_pctFloat64The opponent's three-point percentage with the unit on the floor. Null with a zero denominator.
off_rtg_nInt64Sample size of off_rtg: poss.
def_rtg_nInt64Sample size of def_rtg: opp_poss.
net_rtg_nInt64Sample size of net_rtg: poss + opp_poss.
efg_pct_nInt64Sample size of efg_pct: the unit's field-goal attempts.
tov_pct_nInt64Sample size of tov_pct: poss.
orb_pct_nInt64Sample size of orb_pct: the unit's offensive-rebound chances.
ft_rate_nInt64Sample size of ft_rate: the unit's field-goal attempts.
opp_efg_pct_nInt64Sample size of opp_efg_pct: the opponent's field-goal attempts.
opp_tov_pct_nInt64Sample size of opp_tov_pct: opp_poss.
opp_orb_pct_nInt64Sample size of opp_orb_pct: the opponent's offensive-rebound chances.
opp_ft_rate_nInt64Sample size of opp_ft_rate: the opponent's field-goal attempts.
rim_rate_nInt64Sample size of rim_rate: the unit's field-goal attempts.
mid_rate_nInt64Sample size of mid_rate: the unit's field-goal attempts.
fg3_rate_nInt64Sample size of fg3_rate: the unit's field-goal attempts.
rim_pct_nInt64Sample size of rim_pct: the unit's rim attempts.
mid_pct_nInt64Sample size of mid_pct: the unit's mid-range attempts.
fg3_pct_nInt64Sample size of fg3_pct: the unit's three-point attempts.
opp_rim_rate_nInt64Sample size of opp_rim_rate: the opponent's field-goal attempts.
opp_mid_rate_nInt64Sample size of opp_mid_rate: the opponent's field-goal attempts.
opp_fg3_rate_nInt64Sample size of opp_fg3_rate: the opponent's field-goal attempts.
opp_rim_pct_nInt64Sample size of opp_rim_pct: the opponent's rim attempts.
opp_mid_pct_nInt64Sample size of opp_mid_pct: the opponent's mid-range attempts.
opp_fg3_pct_nInt64Sample size of opp_fg3_pct: the opponent's three-point attempts.

Raises

ExceptionDescription
ValueErrorIf league_id is not "00" or "10", or the possessions carry a null shot, free-throw, rebound or turnover count.

Example

from sportsdataverse.nba.nba_game_stints import nba_game_units
units = nba_game_units(2026)
units.filter(game_id="0022500101", n_players=2).head()

nba_impact_rows​

nba_impact_rows(pbp: 'pl.DataFrame', game_lineups: 'pl.DataFrame', possessions: 'pl.DataFrame', schedule: 'pl.DataFrame', *, league_id: 'str' = '00') -> 'pl.DataFrame'

Map the stats.nba.com releases onto the game-impact row frame.

One row per play-by-play action (its clock and points, on the lineup at that action; a free throw on the lineup at its own foul (the latest, or the one logged after it at the same clock reading; not an earlier period's once clock has run)) and one per possession (its lineup and which side had the ball). Games not in schedule are dropped, and so are the possessions of a game with no play-by-play actions and those whose offense is neither team.

Parameters

ParameterTypeDefaultDescription
pbpDataFrameload_nba_stats_pbp / load_wnba_stats_pbp rows (game_id, order_index, action_number, period, seconds_remaining, score_home, score_away, is_free_throw, is_foul, season).
game_lineupsDataFrameload_nba_stats_game_lineups / load_wnba_stats_game_lineups rows.
possessionsDataFrameload_nba_stats_possessions / load_wnba_stats_possessions rows.
scheduleDataFrameload_nba_stats_schedules / load_wnba_stats_schedules rows (game_id, home_team_id, away_team_id), every season type.
league_idstr'00'"00" NBA (12-minute quarters) or "10" WNBA (10-minute quarters).

Returns

Rows in sportsdataverse._common.game_impact.impact_row_schema with Int64 player ids.

col_nametypedescription
seasonInt64Season of the action or possession.
game_idStringstats.nba.com game id.
home_team_idInt64stats.nba.com team id of the home team, from the schedule.
away_team_idInt64stats.nba.com team id of the away team, from the schedule.
home_1Int64Home player 1 on the floor (on a free throw, the player on the floor at the last foul).
home_2Int64Home player 2 on the floor (on a free throw, the player on the floor at the last foul).
home_3Int64Home player 3 on the floor (on a free throw, the player on the floor at the last foul).
home_4Int64Home player 4 on the floor (on a free throw, the player on the floor at the last foul).
home_5Int64Home player 5 on the floor (on a free throw, the player on the floor at the last foul).
away_1Int64Away player 1 on the floor (on a free throw, the player on the floor at the last foul).
away_2Int64Away player 2 on the floor (on a free throw, the player on the floor at the last foul).
away_3Int64Away player 3 on the floor (on a free throw, the player on the floor at the last foul).
away_4Int64Away player 4 on the floor (on a free throw, the player on the floor at the last foul).
away_5Int64Away player 5 on the floor (on a free throw, the player on the floor at the last foul).
secondsFloat64Game clock that ran into this action (0 on a possession row).
home_ptsInt64Points the home team scored on this action (0 on a possession row).
away_ptsInt64Points the away team scored on this action (0 on a possession row).
home_possInt641 on a possession row where the home team has the ball, else 0.
away_possInt641 on a possession row where the away team has the ball, else 0.

Raises

ExceptionDescription
ValueErrorIf league_id is not "00" or "10".

Example

from sportsdataverse.nba import nba_loaders as L
from sportsdataverse.nba.nba_game_impact import nba_impact_rows
rows = nba_impact_rows(L.load_nba_stats_pbp(2025), L.load_nba_stats_game_lineups(2025),
L.load_nba_stats_possessions(2025), L.load_nba_stats_schedules(2025))

nba_l2m​

nba_l2m(game_id: 'str | int', *, raw: 'bool' = False, return_as_pandas: 'bool' = False, proxy: 'dict | None' = None) -> 'dict[str, Any]'

Fetch and parse an NBA Last Two Minute report from official.nba.com.

Retrieves the L2M report for a given game and returns parsed tables of calls, game metadata, and error statistics. The game_id is zero-padded to 10 digits (e.g., 42500405 becomes "0042500405"). A report is published for any game that is within 3 points (5 points before the 2017-18 season) at any point during the last two minutes of the fourth quarter or overtime -- not only playoff games.

Parameters

ParameterTypeDefaultDescription
game_idstr | intNBA game ID (can be int or str). Automatically zero-padded to 10 digits.
rawboolFalseIf True, return the raw JSON payload (dict) instead of parsed DataFrames.
return_as_pandasboolFalseIf True, return pandas DataFrames instead of polars.
proxydict | NoneNoneOptional proxy dict passed through to the HTTP layer.

Returns

If raw=True, the raw JSON dict. Otherwise, a dict with keys "calls", "game", "stats" mapping to DataFrames as documented in parse_nba_l2m.

col_nametypedescription
calls.game_idString10-digit NBA game id (zero-padded), the join key back to the L2M game and stats tables.
calls.periodInt64Period number extracted from period_name's digits: 4 for the fourth quarter, 5+ for overtime periods (Q5 = OT1 through Q8 = OT4).
calls.period_nameStringRaw NBA.com period label for the graded play, e.g. Q4 for the fourth quarter or Q5 for the first overtime.
calls.pc_timeStringRaw game clock string from the L2M report before normalization, in MM:SS or MM:SS.t tenths-of-a-second format.
calls.seconds_remainingFloat64Seconds remaining in the period at the graded play, parsed out of pc_time.
calls.call_typeStringRaw "Call: Type" label from the report, e.g. "Foul: Shooting" or "Turnover: 24 Second Violation"; whitespace (including doubled spaces) is NOT cleaned here -- the cleaned, upper-cased parts are call and type.
calls.callStringUpper-cased category before the colon in call_type, e.g. FOUL, TURNOVER, or STOPPAGE.
calls.typeStringUpper-cased detail after the colon in call_type, e.g. SHOOTING or 24 SECOND VIOLATION.
calls.committingStringPlayer, team nickname, or coach responsible for the graded action.
calls.disadvantagedStringPlayer or team nickname disadvantaged by the graded action, blank when not applicable.
calls.decisionStringNormalized grading decision: CC (correct call), CNC (correct non-call), IC (incorrect call), or INC (incorrect non-call); null when the report marks the play undetectable at game speed.
calls.decision_rawStringRaw grading code from the report before normalization, including the rare NCC/NCI aliases folded into decision.
calls.commentStringGrader's free-text explanation of the ruling, sometimes naming a player as "Last (TEAM)".
calls.difficultyStringGrader's difficulty rating for the play, e.g. Observable, Difficult, Blatant/Hard, or Undetectable.
calls.video_event_idStringL2M video event id from the report (source field VideolLink, sic); not a stats.nba.com play-by-play EVENTNUM, so it cannot be joined to pbp data.
calls.pos_idInt64Possession id assigned by the report, rising monotonically across the game; rows sharing pos_start/pos_end belong to the same possession.
calls.pos_startStringGame clock at the start of the possession containing this graded play.
calls.pos_endStringGame clock at the end of the possession containing this graded play.
calls.pos_team_idInt6410-digit NBA team id of the team in possession during the graded play.
game.game_idString10-digit NBA game id (zero-padded), the join key to the calls and stats tables.
game.game_dateDateGame date parsed from the report's local tip-off timestamp (no timezone offset is applied).
game.season_typeStringSeason type inferred from the third digit of game_id: preseason, regular, all-star, playoffs, play-in, or nba-cup-final.
game.home_team_idInt6410-digit NBA team id (1610612xxx) of the home team.
game.away_team_idInt6410-digit NBA team id (1610612xxx) of the away team.
game.home_team_abbrStringThree-letter abbreviation of the home team.
game.away_team_abbrStringThree-letter abbreviation of the away team.
game.home_team_nameStringHome team nickname as published in the report, e.g. Thunder rather than Oklahoma City Thunder.
game.away_team_nameStringAway team nickname as published in the report.
game.home_scoreInt64Home team's final score for the game.
game.away_scoreInt64Away team's final score for the game.
game.l2m_commentsStringReport-level note from the league, e.g. a technical-issue disclaimer about missing video; null for almost every game.
stats.game_idString10-digit NBA game id (zero-padded), the join key to the calls and game tables.
stats.stat_nameStringName of the report-level error-rate statistic: Calls, Errors in Favor, or Possessions in Favor.
stats.homeInt64Value of stat_name attributed to the home team.
stats.awayInt64Value of stat_name attributed to the away team.

Raises

ExceptionDescription
ValueErrorgame_id is not one non-negative integer id -- a bool, a negative or fractional number, a string that is not all digits, or more than 10 digits (checked before any request).
NoDataErrorThe game has no L2M report (a 404, or S3's AccessDenied 403). Only games within 3 points (5 before 2017-18) at some point in the last two minutes of the fourth quarter or overtime get one, so most games have none; a game that just ended may not be graded yet.
AssetFetchErrorThe fetch failed (a transport error, a rate limit, an Akamai WAF block, or a 5xx that outlived the retry budget), or the 200 body is not a JSON object whose game is exactly one row, or its l2m/stats table is not a list of records (empty is fine) -- an error envelope or a changed schema, checked with raw=True too.

Example

from sportsdataverse.nba.nba_officiating import nba_l2m
result = nba_l2m("0042500405")
calls = result["calls"]
print(f"Game had {calls.height} tracked plays in the L2M window")

# Parse as pandas instead

result = nba_l2m("0042500405", return_as_pandas=True)
calls_pd = result["calls"]

# Access raw JSON

payload = nba_l2m("0042500405", raw=True)
print(payload["game"])

nba_l2m_games​

nba_l2m_games(season: 'int | str', *, return_as_pandas: 'bool' = False, proxy: 'dict | None' = None) -> 'Union[pl.DataFrame, pd.DataFrame]'

Fetch the list of games with Last Two Minute reports for an NBA season.

Retrieves and parses the L2M season index page from official.nba.com, returning a table of all games for which L2M reports exist. JSON reports exist only from 2019-01-01 onward; earlier seasons' index pages list PDFs, which this function ignores. A release loader for historical (PDF-era) reports is planned but does not exist yet.

Parameters

ParameterTypeDefaultDescription
seasonint | strThe NBA season (end year) as a 4-digit int or string, e.g. 2026 for the 2025-26 season.
return_as_pandasboolFalseIf True, return a pandas DataFrame instead of polars.
proxydict | NoneNoneOptional proxy dict passed through to the HTTP layer.

Returns

A polars.DataFrame (or pandas.DataFrame when return_as_pandas=True) with schema {"game_id": Utf8, "season": Int32, "season_type": Utf8, "label": Utf8}, one row per unique game ID in page order.

col_nametypedescription
game_idString10-digit NBA game id (zero-padded), parsed from the season listing page's report link.
seasonInt64NBA season end year passed to the function (e.g. 2026 for the 2025-26 season), stamped onto every row.
season_typeStringSeason type inferred from the third digit of game_id: preseason, regular, all-star, playoffs, play-in, or nba-cup-final.
labelStringMatchup label text scraped from the listing page link, e.g. "Thunder 125, Rockets 124 (2OT)".

Raises

ExceptionDescription
ValueErrorseason is not a 4-digit year (an int or an all-digit string), checked before any request.
NoDataErrorOfficial.nba.com has no listing page for that season (a 404, or S3's AccessDenied 403) -- e.g. a future season, or one from before the L2M program began.
AssetFetchErrorThe fetch failed (network error, rate limit, or Akamai WAF block), or a 200 response that is missing the expected "Last Two Minute" page marker (an Akamai interstitial, a blank body, or a redesigned page), or that links reports in a shape the parser does not read (a redesigned page) -- checked here, not in parse_nba_l2m_games, so the parser itself never raises.

Example

from sportsdataverse.nba.nba_officiating import nba_l2m_games
df = nba_l2m_games(2026)
print(f"Season had {df.height} games with L2M reports")

# Get playoff games only

df = nba_l2m_games(2026)
playoffs = df.filter(df["season_type"] == "playoffs")

# Convert to pandas

df = nba_l2m_games(2026, return_as_pandas=True)

nba_lineup_count_rows​

nba_lineup_count_rows(possessions: 'pl.DataFrame', schedule: 'pl.DataFrame', *, pbp: 'pl.DataFrame | None' = None) -> 'pl.DataFrame'

Map nba_stats_possessions rows onto the lineup-seasons count frame.

Each possession's counts go to the side that had the ball, its dreb (the defense's defensive rebounds) to the other side, on the possession's lineup. A possession whose offense is neither team of its schedule game is dropped, as in the game impact box.

Parameters

ParameterTypeDefaultDescription
possessionsDataFrameload_nba_stats_possessions / load_wnba_stats_possessions rows (fg2a, fg2m, fg3a, fg3m, fta, oreb, dreb, tov; with pbp, also start_order_index).
scheduleDataFrameThe games to keep (game_id, home_team_id, away_team_id).
pbpDataFrame | NoneNoneload_nba_stats_pbp / load_wnba_stats_pbp rows (game_id, order_index, team_id, is_field_goal, is_made_shot, shot_value, shot_distance). When given, the rows also carry the shot-zone counts (rima, rimm, mida, midm): each two the offense took in the possession, at the rim when it was under 4 feet, mid-range otherwise.

Returns

One row per possession in sportsdataverse._common.lineup_seasons.lineup_count_schema (with the shot zones when pbp is given) with Int64 player ids.

col_nametypedescription
seasonInt64Season, named by the year it ends.
game_idStringstats.nba.com game id.
home_team_idInt64stats.nba.com team id of the home side.
away_team_idInt64stats.nba.com team id of the away side.
home_1Int64stats.nba.com id of home player 1 on the floor when the possession starts.
home_2Int64stats.nba.com id of home player 2 on the floor when the possession starts.
home_3Int64stats.nba.com id of home player 3 on the floor when the possession starts.
home_4Int64stats.nba.com id of home player 4 on the floor when the possession starts.
home_5Int64stats.nba.com id of home player 5 on the floor when the possession starts.
away_1Int64stats.nba.com id of away player 1 on the floor when the possession starts.
away_2Int64stats.nba.com id of away player 2 on the floor when the possession starts.
away_3Int64stats.nba.com id of away player 3 on the floor when the possession starts.
away_4Int64stats.nba.com id of away player 4 on the floor when the possession starts.
away_5Int64stats.nba.com id of away player 5 on the floor when the possession starts.
home_fgaInt64The home side's field-goal attempts in the possession.
home_fgmInt64The home side's field goals made in the possession.
home_fg3aInt64The home side's three-point attempts in the possession.
home_fg3mInt64The home side's threes made in the possession.
home_ftaInt64The home side's free-throw attempts in the possession.
home_orebInt64The home side's offensive rebounds in the possession.
home_drebInt64The home side's defensive rebounds in the possession.
home_tovInt64The home side's turnovers in the possession.
away_fgaInt64The away side's field-goal attempts in the possession.
away_fgmInt64The away side's field goals made in the possession.
away_fg3aInt64The away side's three-point attempts in the possession.
away_fg3mInt64The away side's threes made in the possession.
away_ftaInt64The away side's free-throw attempts in the possession.
away_orebInt64The away side's offensive rebounds in the possession.
away_drebInt64The away side's defensive rebounds in the possession.
away_tovInt64The away side's turnovers in the possession.

Raises

ExceptionDescription
ValueErrorIf a count column holds a null in a possession of a schedule game.

Example

from sportsdataverse.nba import nba_loaders as L
from sportsdataverse.nba.nba_lineup_seasons import nba_lineup_count_rows
rows = nba_lineup_count_rows(L.load_nba_stats_possessions(2024), L.load_nba_stats_schedules(2024))

nba_lineup_seasons​

nba_lineup_seasons(seasons: 'int | list[int]', *, league_id: 'str' = '00', season_type: 'str' = 'regular-season', min_poss: 'int | None' = None, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Lineup seasons: 2-, 3- and 5-man units with possessions, minutes, ratings and four factors.

The definitions are in sportsdataverse._common.lineup_seasons.

Parameters

ParameterTypeDefaultDescription
seasonsint | list[int]A season or list of seasons, named by the year it ends (2026 is 2025-26). The WNBA season is its calendar year.
league_idstr'00'"00" NBA or "10" WNBA.
season_typestr'regular-season'"regular-season" (default), "preseason", "playoffs" or "play-in", matched to the schedule's season_type.
min_possint | NoneNoneThe rank gate, offensive plus defensive possessions. Defaults to 400 (NBA) or 200 (WNBA).
return_as_pandasboolFalseReturn a pandas frame instead of polars.

Returns

One row per (season, team_id, n_players, lineup_id): n_players (2, 3 or 5), lineup_id (the player ids sorted and joined with -), player_1..5, minutes, poss / opp_poss, pts / opp_pts, plus_minus, off_rtg / def_rtg / net_rtg (per 100 possessions), the four factors for (efg_pct, tov_pct, orb_pct, ft_rate) and against (opp_*) as fractions, and for every rate <m>_rank / <m>_pct (within the season and unit size, among units with at least min_poss) and <m>_n. Ids are the stats.nba.com ids (Int64). Empty input returns that schema with zero rows.

col_nametypedescription
seasonInt64Season, named by the year it ends (the WNBA season is its calendar year).
team_idInt64stats.nba.com team id.
n_playersInt64Unit size: 2, 3 or 5 players.
lineup_idStringThe unit's stats.nba.com player ids, sorted numerically and joined with '-'.
player_1Int64Player 1 of the unit, in lineup_id order; null past n_players.
player_2Int64Player 2 of the unit, in lineup_id order; null past n_players.
player_3Int64Player 3 of the unit, in lineup_id order; null past n_players.
player_4Int64Player 4 of the unit, in lineup_id order; null past n_players.
player_5Int64Player 5 of the unit, in lineup_id order; null past n_players.
minutesFloat64Game-clock minutes the unit shared the floor over the season.
possInt64Offensive possessions with the unit on the floor (a possession counts for the five on the floor when it starts; a 2- or 3-man unit sums the fives that contain it).
opp_possInt64Defensive possessions with the unit on the floor, counted as poss is.
ptsInt64The team's points with the unit on the floor, each scoring action credited to the lineup at that action (a free throw to the lineup at the last foul).
opp_ptsInt64The opponent's points with the unit on the floor, credited as pts is.
plus_minusInt64The unit's +/- over the season: pts - opp_pts.
off_rtgFloat64Offensive rating: pts per 100 poss. Null with a zero denominator. On 2024-25 units it runs about 5 above stats.nba.com's lineup rating, which credits a possession to every lineup on the floor during it (its counts run ~4% higher).
def_rtgFloat64Defensive rating: opp_pts per 100 opp_poss. Null with a zero denominator. On 2024-25 units it runs about 5 above stats.nba.com's lineup rating, which credits a possession to every lineup on the floor during it (its counts run ~4% higher).
net_rtgFloat64Net rating: off_rtg - def_rtg; null when either is null.
efg_pctFloat64Effective field-goal percentage, (FGM + 0.5 * 3PM) / FGA, as a fraction. Null with a zero denominator. Each possession's shots, free throws, rebounds and turnovers count for the lineup that started it, even after a substitution inside it.
tov_pctFloat64Turnovers per offensive possession, as a fraction. Null with a zero denominator. Each possession's shots, free throws, rebounds and turnovers count for the lineup that started it, even after a substitution inside it.
orb_pctFloat64Offensive-rebound rate: OREB / (OREB + the opponent's DREB), as a fraction. Null with a zero denominator. Each possession's shots, free throws, rebounds and turnovers count for the lineup that started it, even after a substitution inside it.
ft_rateFloat64Free-throw rate: FTA / FGA. Null with a zero denominator. Each possession's shots, free throws, rebounds and turnovers count for the lineup that started it, even after a substitution inside it.
opp_efg_pctFloat64The opponent's effective field-goal percentage with the unit on the floor. Null with a zero denominator. Each possession's shots, free throws, rebounds and turnovers count for the lineup that started it, even after a substitution inside it.
opp_tov_pctFloat64The opponent's turnovers per defensive possession. Null with a zero denominator. Each possession's shots, free throws, rebounds and turnovers count for the lineup that started it, even after a substitution inside it.
opp_orb_pctFloat64The opponent's offensive-rebound rate: its OREB / (its OREB + the unit's DREB). Null with a zero denominator. Each possession's shots, free throws, rebounds and turnovers count for the lineup that started it, even after a substitution inside it.
opp_ft_rateFloat64The opponent's free-throw rate: FTA / FGA. Null with a zero denominator. Each possession's shots, free throws, rebounds and turnovers count for the lineup that started it, even after a substitution inside it.
off_rtg_rankFloat64Rank of off_rtg within the season and unit size, league-wide (the highest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose off_rtg_n is at least 1,300 offensive possessions (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
def_rtg_rankFloat64Rank of def_rtg within the season and unit size, league-wide (the lowest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose def_rtg_n is at least 2,000 defensive possessions (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
net_rtg_rankFloat64Rank of net_rtg within the season and unit size, league-wide (the highest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose net_rtg_n is at least 2,000 possessions (offense plus defense) (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
efg_pct_rankFloat64Rank of efg_pct within the season and unit size, league-wide (the highest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose efg_pct_n is at least 1,200 field-goal attempts (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
tov_pct_rankFloat64Rank of tov_pct within the season and unit size, league-wide (the lowest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose tov_pct_n is at least 1,400 offensive possessions (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
orb_pct_rankFloat64Rank of orb_pct within the season and unit size, league-wide (the highest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose orb_pct_n is at least 410 offensive-rebound chances (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
ft_rate_rankFloat64Rank of ft_rate within the season and unit size, league-wide (the highest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose ft_rate_n is at least 1,300 field-goal attempts (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
opp_efg_pct_rankFloat64Rank of opp_efg_pct within the season and unit size, league-wide (the lowest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose opp_efg_pct_n is at least 1,900 opponent field-goal attempts (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
opp_tov_pct_rankFloat64Rank of opp_tov_pct within the season and unit size, league-wide (the highest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose opp_tov_pct_n is at least 960 defensive possessions (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
opp_orb_pct_rankFloat64Rank of opp_orb_pct within the season and unit size, league-wide (the lowest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose opp_orb_pct_n is at least 1,200 opponent offensive-rebound chances (the sample at which the rate is half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
opp_ft_rate_rankFloat64Rank of opp_ft_rate within the season and unit size, league-wide (the lowest value ranks 1; ties average), among units with at least min_poss possessions (poss + opp_poss; default 400 with league_id '00' (NBA), 200 with league_id '10' (WNBA)), whose opp_ft_rate_n is at least 1,500 opponent field-goal attempts (the sample at which the rate was, on the fit seasons, half signal, rate_gates); null for a non-qualifier, a sample under that gate or a null rate, and for every unit of the group when fewer than ten qualifying units have a finite value of this rate or they all share one value.
off_rtg_pctFloat64Percentile of off_rtg among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
def_rtg_pctFloat64Percentile of def_rtg among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
net_rtg_pctFloat64Percentile of net_rtg among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
efg_pct_pctFloat64Percentile of efg_pct among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
tov_pct_pctFloat64Percentile of tov_pct among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
orb_pct_pctFloat64Percentile of orb_pct among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
ft_rate_pctFloat64Percentile of ft_rate among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
opp_efg_pct_pctFloat64Percentile of opp_efg_pct among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
opp_tov_pct_pctFloat64Percentile of opp_tov_pct among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
opp_orb_pct_pctFloat64Percentile of opp_orb_pct among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
opp_ft_rate_pctFloat64Percentile of opp_ft_rate among the same qualified units: 100 * (n + 1 - rank) / (n + 1), n the number ranked; null when the rank is null.
off_rtg_nInt64Sample size of off_rtg: poss.
def_rtg_nInt64Sample size of def_rtg: opp_poss.
net_rtg_nInt64Sample size of net_rtg: poss + opp_poss.
efg_pct_nInt64Sample size of efg_pct: the unit's field-goal attempts.
tov_pct_nInt64Sample size of tov_pct: poss.
orb_pct_nInt64Sample size of orb_pct: the unit's offensive-rebound chances.
ft_rate_nInt64Sample size of ft_rate: the unit's field-goal attempts.
opp_efg_pct_nInt64Sample size of opp_efg_pct: the opponent's field-goal attempts.
opp_tov_pct_nInt64Sample size of opp_tov_pct: opp_poss.
opp_orb_pct_nInt64Sample size of opp_orb_pct: the opponent's offensive-rebound chances.
opp_ft_rate_nInt64Sample size of opp_ft_rate: the opponent's field-goal attempts.
pts_per75Float64Per 75 possessions: 0.75 * off_rtg (BB-G8's per-75 basis). A unit has no per-game basis: it plays stretches of many games, never a game of its own.
opp_pts_per75Float64Per 75 possessions: 0.75 * def_rtg (BB-G8's per-75 basis). A unit has no per-game basis: it plays stretches of many games, never a game of its own.
plus_minus_per75Float64Per 75 possessions: 0.75 * net_rtg (BB-G8's per-75 basis). A unit has no per-game basis: it plays stretches of many games, never a game of its own.
pts_per75_rankFloat64Rank of pts_per75: off_rtg_rank, copied (scaling by 0.75 keeps the order: same gate, same ties).
opp_pts_per75_rankFloat64Rank of opp_pts_per75: def_rtg_rank, copied (scaling by 0.75 keeps the order: same gate, same ties).
plus_minus_per75_rankFloat64Rank of plus_minus_per75: net_rtg_rank, copied (scaling by 0.75 keeps the order: same gate, same ties).
pts_per75_pctFloat64Percentile of pts_per75: off_rtg_pct, copied (scaling by 0.75 keeps the order).
opp_pts_per75_pctFloat64Percentile of opp_pts_per75: def_rtg_pct, copied (scaling by 0.75 keeps the order).
plus_minus_per75_pctFloat64Percentile of plus_minus_per75: net_rtg_pct, copied (scaling by 0.75 keeps the order).
pts_per75_nInt64Sample size of pts_per75: off_rtg_n, copied.
opp_pts_per75_nInt64Sample size of opp_pts_per75: def_rtg_n, copied.
plus_minus_per75_nInt64Sample size of plus_minus_per75: net_rtg_n, copied.
lg_rtgFloat64Points per 100 possessions of the season's league-average offense (pooled over every five-man unit), the zero the factor points are measured from.
off_efg_ptsFloat64Offensive shooting (eFG%) points per 100 possessions against the league average: the part of off_rtg - lg_rtg the shooting (eFG%) factor explains, at fixed linear prices from the season's league counts (factor_points). The four off_pts add up to off_rtg - lg_rtg and, with the four def_pts, to net_rtg exactly. Null when the unit started no possession (poss = 0).
off_tov_ptsFloat64Offensive turnovers points per 100 possessions against the league average: the part of off_rtg - lg_rtg the turnovers factor explains, at fixed linear prices from the season's league counts (factor_points). The four off_pts add up to off_rtg - lg_rtg and, with the four def_pts, to net_rtg exactly. Null when the unit started no possession (poss = 0).
off_orb_ptsFloat64Offensive rebounding points per 100 possessions against the league average: the part of off_rtg - lg_rtg the offensive rebounding factor explains, at fixed linear prices from the season's league counts (factor_points). The four off_pts add up to off_rtg - lg_rtg and, with the four def_pts, to net_rtg exactly. Null when the unit started no possession (poss = 0).
off_ft_ptsFloat64Offensive free throws points per 100 possessions against the league average: the part of off_rtg - lg_rtg the free throws factor explains, at fixed linear prices from the season's league counts (factor_points). The four off_pts add up to off_rtg - lg_rtg and, with the four def_pts, to net_rtg exactly. The free-throw part is the remainder of the other three: the free throws' price plus the possessions and points the box estimate does not explain (on the pros, the possession count's distance from the box estimate, which weights a free-throw attempt 0.44, less the league's average gap per FGA), so its sign can differ from the free-throw factor's.
def_efg_ptsFloat64Defensive shooting (eFG%) points per 100 defensive possessions against the league average, positive is better for the team: the part of lg_rtg - def_rtg it explains (factor_points). The four def_pts add up to lg_rtg - def_rtg and, with the four off_pts, to net_rtg exactly. Null when the unit faced no possession (opp_poss = 0).
def_tov_ptsFloat64Defensive turnovers points per 100 defensive possessions against the league average, positive is better for the team: the part of lg_rtg - def_rtg it explains (factor_points). The four def_pts add up to lg_rtg - def_rtg and, with the four off_pts, to net_rtg exactly. Null when the unit faced no possession (opp_poss = 0).
def_orb_ptsFloat64Defensive rebounding points (the opponents' offensive rebounding) per 100 defensive possessions against the league average, positive is better for the team: the part of lg_rtg - def_rtg it explains (factor_points). The four def_pts add up to lg_rtg - def_rtg and, with the four off_pts, to net_rtg exactly. Null when the unit faced no possession (opp_poss = 0).
def_ft_ptsFloat64Defensive free throws points per 100 defensive possessions against the league average, positive is better for the team: the part of lg_rtg - def_rtg it explains (factor_points). The four def_pts add up to lg_rtg - def_rtg and, with the four off_pts, to net_rtg exactly. The free-throw part is the remainder of the other three: the free throws' price plus the possessions and points the box estimate does not explain (on the pros, the possession count's distance from the box estimate, which weights a free-throw attempt 0.44, less the league's average gap per FGA), so its sign can differ from the free-throw factor's.
efg_ptsFloat64Net shooting (eFG%) points per 100: off_efg_pts + def_efg_pts. The four (efg_pts, tov_pts, orb_pts, ft_pts) add up to net_rtg exactly. Null when either side has no possessions.
tov_ptsFloat64Net turnovers points per 100: off_tov_pts + def_tov_pts. The four (efg_pts, tov_pts, orb_pts, ft_pts) add up to net_rtg exactly. Null when either side has no possessions.
orb_ptsFloat64Net offensive rebounding points per 100: off_orb_pts + def_orb_pts. The four (efg_pts, tov_pts, orb_pts, ft_pts) add up to net_rtg exactly. Null when either side has no possessions.
ft_ptsFloat64Net free throws points per 100: off_ft_pts + def_ft_pts, the remainder parts, so more than the free throws (see off_ft_pts). The four (efg_pts, tov_pts, orb_pts, ft_pts) add up to net_rtg exactly. Null when either side has no possessions.

Raises

ExceptionDescription
ValueErrorIf league_id is not "00" or "10", season_type is not one of the four above, or the possessions carry a null shot, free-throw, rebound or turnover count.

Example

from sportsdataverse.nba.nba_lineup_seasons import nba_lineup_seasons
units = nba_lineup_seasons(2025)
units.filter(n_players=5).sort("net_rtg_rank").head()

nba_neutral_site_games​

nba_neutral_site_games(seasons: 'list[int] | None' = None, *, league_id: 'str' = '00', return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

The curated NBA / WNBA neutral-site games: played abroad, or NBA Cup knockout games in Las Vegas.

The 2020 bubbles are a date rule (BUBBLES), not rows. The team ratings, the season sim, the rated priors and game flow drop the home-court term for every game in either.

Parameters

ParameterTypeDefaultDescription
seasonslist[int] | NoneNoneSeasons to keep, named by the year they end (2026 is 2025-26; the WNBA season is its calendar year). None keeps all.
league_idstr'00'"00" NBA or "10" WNBA.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

One row per game: league, season, game_id (the stats.nba.com id, Utf8), game_date, season_type (regular-season, or nba-cup for a Cup final), home_team / away_team (stats abbreviations, the designated home team first), arena, city, country, reason (international or cup_knockout) and source_url.

col_nametypedescription
leagueStringLeague the game belongs to: nba or wnba.
seasonInt64Season, named by the year it ends (the WNBA season is its calendar year).
game_idStringstats.nba.com game id (Utf8).
game_dateDateGame date (US Eastern), as in the stats schedule release.
season_typeStringSchedule season type: regular-season, or nba-cup for an NBA Cup final (which does not count in the standings).
home_teamStringDesignated home team (stats.nba.com abbreviation).
away_teamStringAway team (stats.nba.com abbreviation).
arenaStringArena the game was played in.
cityStringCity of the arena.
countryStringCountry of the arena.
reasonStringWhy the game is neutral: international (played abroad) or cup_knockout (an NBA Cup knockout game in Las Vegas).
source_urlStringThe source that documents the game.

Raises

ExceptionDescription
ValueErrorIf league_id is not "00" or "10".

Example

from sportsdataverse.nba import nba_neutral_site_games
games = nba_neutral_site_games([2026])

# WNBA

nba_neutral_site_games(league_id="10")

nba_official_seasons​

nba_official_seasons(seasons: 'int | list[int]', *, season_type: 'int | None' = 2, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

NBA official season profiles: games, fouls and FTA per game, pace and home splits.

One row per official and season over the completed games of season_type the official worked. fouls_per_game and fta_per_game are both teams' totals from ESPN's team box; pace is possessions (FGA - ORB + TOV + 0.44 FTA, averaged over the two teams) per 48 minutes, over the games' minutes including overtime; home_win_pct and home_minus_away_fouls (home fouls less away fouls, per game) leave out neutral-site games. Every rate has <m>_n, the games it is computed over. The release keys officials by names only, so official_id is null.

Parameters

ParameterTypeDefaultDescription
seasonsint | list[int]A season or list of seasons, named by the year it ends (2025 is 2024-25).
season_typeint | None2ESPN's season type: 2 regular season (default), 3 postseason; None keeps every type.
return_as_pandasboolFalseReturn a pandas frame instead of polars.

Returns

One row per (season, official): season, official_id (Int64), official_name, games, fouls_per_game, fta_per_game, pace, home_win_pct and home_minus_away_fouls, each rate with its _n. A season without an officials release returns that schema with zero rows.

col_nametypedescription
seasonInt64Season, named by the year it ends (the WNBA season is its calendar year).
official_idInt64ESPN official id where the officials release carries one (WNBA, WBB); null where it has names only (NBA, MBB).
official_nameStringOfficial's name, whitespace-normalised; the key when official_id is null.
gamesInt64Completed games of the season type the officials table lists the official on.
fouls_per_gameFloat64Both teams' fouls per game (ESPN team box fouls), over fouls_per_game_n games.
fouls_per_game_nInt64Games with a two-team box behind fouls_per_game.
fta_per_gameFloat64Both teams' free-throw attempts per game, over fta_per_game_n games.
fta_per_game_nInt64Games with a two-team box behind fta_per_game.
paceFloat64Possessions (FGA - ORB + TOV + 0.44 FTA, averaged over the two teams) per regulation length (48 minutes NBA, 40 otherwise), over the games' minutes including overtime.
pace_nInt64Games with a box possession estimate and a known last period behind pace.
home_win_pctFloat64Share of the official's non-neutral-site games with a recorded winner that the home team won.
home_win_pct_nInt64Non-neutral-site games with a recorded home winner behind home_win_pct.
home_minus_away_foulsFloat64Home team's fouls minus the away team's, per non-neutral-site game.
home_minus_away_fouls_nInt64Non-neutral-site games with a two-team box behind home_minus_away_fouls.

Example

from sportsdataverse.nba.nba_official_seasons import nba_official_seasons
refs = nba_official_seasons(2025)
refs.sort("fouls_per_game", descending=True).select("official_name", "games", "fouls_per_game").head()

nba_play_context​

nba_play_context(game_id: 'str', league_id: 'str' = '00', *, transition_seconds: 'float' = 6.0, transition_variant: 'str' = 'hoop_math', return_as_pandas: 'bool' = False) -> 'Union[pl.DataFrame, pd.DataFrame]'

Fetch one game and return its possessions with the full CTG play-context surface.

Single live call to nba_stats_playbyplayv3, then add_play_context. Works for NBA (league_id="00"), WNBA and the G-League — stats.wnba.com ships the same play-by-play shapes, and every threshold here is league-agnostic.

Parameters

ParameterTypeDefaultDescription
game_idstrTen-character game identifier (e.g. "0022200001").
league_idstr'00'League identifier ("00" NBA, "10" WNBA, "20" G-League).
transition_secondsfloat6.0Transition initial-play cutoff (default 6.0).
transition_variantstr'hoop_math'See add_transition.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

Possession frame with the play-context columns. Empty/malformed payloads return a zero-row frame — never raises.

No returns table is published for this function: no capture: it reads stats.nba.com, which answers HTTP 403 to the datacenter IP the docs are built on; the function works from a residential IP.

Example

from sportsdataverse.nba.nba_play_context import nba_play_context
poss = nba_play_context("0022200001")
print(poss["possession_start_type_ctg"].value_counts())

# Transition rate for the game

import polars as pl
clean = poss.filter(
(pl.col("is_garbage_time_ctg") == False) & (pl.col("is_heave_possession") == False)
)
print(clean["is_transition_ctg"].mean())