Skip to main content
Version: 0.2.0

NFL — additional Python functions — Analytics

calculate_nfl_standings​

calculate_nfl_standings(games: 'pl.DataFrame', *, teams: 'pl.DataFrame | None' = None, tiebreaker_depth: 'int' = 3, playoff_seeds: 'int | None' = None, return_as_pandas: 'bool' = False) -> "pl.DataFrame | 'pd.DataFrame'"

Compute NFL division standings + conference playoff seeds.

A reduced port of the tiebreaker ladder nflfastR delegates to the external nflseedR package (see the module docstring for the exact scope). Games are doubled into one row per team per game, regular-season win/loss/tie records are computed per team, and ties are broken win_pct -> head-to-head -> division record -> conference record, to the depth configured by tiebreaker_depth.

Parameters

ParameterTypeDefaultDescription
gamesDataFrameA load_nfl_schedule-shaped frame: game_id, season, game_type, week, home_team, away_team, home_score, away_score. Only game_type == "REG" rows with both scores present are used.
teamsDataFrame | NoneNoneA load_nfl_teams-shaped frame (team_abbr, team_conf, team_division). When None (default), calls sportsdataverse.nfl.load_nfl_teams. Must cover every team abbreviation appearing in games -- a team absent from teams gets null conf/division and is silently pooled into the (season, None) division/conference group rather than raising.
tiebreaker_depthint31 (win_pct only), 2 (adds head-to-head + division record), or 3 (default; adds conference record too).
playoff_seedsint | NoneNoneNumber of teams per conference that receive a non-null seed. When None (default), uses the 2020 playoff -format cutover: 6 for seasons <= 2019, 7 for 2020+.
return_as_pandasboolFalseIf True return a pandas DataFrame; else polars.

Returns

A polars (or pandas) DataFrame with one row per (season, team): conf, division, div_rank, seed (null past playoff_seeds), team, games, wins, losses, ties, win_pct (ties count as 0.5 win), div_pct, conf_pct. Sorted by (season, division, div_rank, seed).

col_nametypedescription
seasonInt644 digit number indicating to which season(s) the specified timeframe belongs to.
confString
divisionString
div_rankInt64
seedInt64
teamStringNFL team. Uses official abbreviations as per NFL.com
gamesInt64Games played in career
winsInt64
lossesInt64
tiesInt64
win_pctFloat64
div_pctFloat64
conf_pctFloat64

Raises

ExceptionDescription
ValueErrorIf tiebreaker_depth is not 1, 2, or 3.

Example

from sportsdataverse.nfl import calculate_nfl_standings, load_nfl_schedule
games = load_nfl_schedule(seasons=[2023])
standings = calculate_nfl_standings(games)
standings.filter(standings["div_rank"] == 1)

# Injected teams frame (offline)

standings = calculate_nfl_standings(games, teams=my_teams_df)

# Pipeline next step (one line)

standings.sort(["conf", "seed"]).select("team", "seed", "win_pct")

compose_counting_projection​

compose_counting_projection(rate_proj: 'pl.DataFrame', avail_proj: 'pl.DataFrame', *, rate_col: 'str' = 'proj_rate', volume_col: 'str' = 'proj_volume') -> 'pl.DataFrame'

Compose skill and availability into a counting projection.

The only place skill (rate x volume) and availability meet: proj_counting = rate * volume * proj_availability, joined on player_id (dtype-asserted).

Parameters

ParameterTypeDefaultDescription
rate_projpl.DataFrameSkill projection carrying player_id + rate_col + volume_col.
avail_projpl.DataFrameAvailability projection carrying player_id + proj_availability.
rate_colstr'proj_rate'Rate column name in rate_proj.
volume_colstr'proj_volume'Volume column name in rate_proj.

Returns

rate_proj columns plus proj_availability and proj_counting:Float64.

col_nametypedescription
player_idStringnflverse gsis player id (character join key; asserted Utf8 on both sides of the join).
proj_rateFloat64Projected per-opportunity rate carried through from the skill projection (rate_col).
proj_volumeFloat64Projected opportunity volume carried through from the skill projection (volume_col).
proj_availabilityFloat64Projected availability rate in [0, 1] from nfl_availability_projection.
proj_countingFloat64Composed counting projection - proj_rate x proj_volume x proj_availability (the only place skill and availability meet).

Example

import polars as pl
from sportsdataverse.nfl.nfl_availability import compose_counting_projection
out = compose_counting_projection(rate_frame, avail_frame)

nfl_availability_projection​

nfl_availability_projection(seasons: 'list[int]', target_season: 'int', *, team_games: 'int' = 17, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Empirical-Bayes availability projection: expected fraction of team games.

Shrinks each player's historical availability toward the fitted position

Parameters

ParameterTypeDefaultDescription
seasonsList[int]History seasons to load snap counts/rosters for.
target_seasonintThe season being projected.
team_gamesint17Regular-season team games.
return_as_pandasboolFalseIf True, returns a pandas dataframe.

Returns

player_id:Utf8, target_season:Int64, position:Utf8, proj_availability:Float64, proj_games:Float64, proj_games_missed:Float64. Empty history returns a zero-row frame.

col_nametypedescription
player_idStringnflverse gsis player id (character join key).
target_seasonInt64The season being projected (features use strictly earlier seasons only).
positionStringRoster position from the most recent visible season.
proj_availabilityFloat64Projected availability rate in [0, 1] - empirical-Bayes shrinkage of historical snap-based availability toward the fitted position base rate, then the fold-fit linear recalibration.
proj_gamesFloat64Expected games available - proj_availability x team_games (17).
proj_games_missedFloat64Expected games missed - team_games minus proj_games.

Example

from sportsdataverse.nfl.nfl_availability import nfl_availability_projection
avail = nfl_availability_projection([2021, 2022, 2023], 2024)
avail.sort("proj_games").head()

nfl_expected_starters​

nfl_expected_starters(schedule: 'pl.DataFrame', *, depth_charts: 'pl.DataFrame | None' = None, injuries: 'pl.DataFrame | None' = None, config: 'QBLayerConfig | None' = None, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Pregame expected starting QB, backup, report status and start probability per team-game.

  1. A timestamped depth chart (nflverse's dt format, 2025 on): QB1 and QB2 of the team's last snapshot strictly before kickoff (gameday + gametime, US Eastern).
  2. Otherwise the team's realized starter in its previous game of the season, with no known backup. A team's first game with no snapshot has no expected starter.

status is the expected starter's report_status on that week's injury report (Out / Doubtful / Questionable; null, Probable or absent is none), and p_start the fitted chance he starts at that status. The realized starter columns of the schedule (home_qb_id / away_qb_id) are read only for rule 2's previous game.

Parameters

ParameterTypeDefaultDescription
scheduleDataFramesportsdataverse.nfl.load_nfl_schedule rows (game_id, season, week, gameday, gametime, home_team, away_team, home_qb_id, away_qb_id).
depth_chartsDataFrame | NoneNonesportsdataverse.nfl.load_nfl_depth_charts rows in the timestamped (dt) format. None uses rule 2 only.
injuriesDataFrame | NoneNonesportsdataverse.nfl.load_nfl_injuries rows (season, week, team, gsis_id, report_status). None gives every starter status none.
configQBLayerConfig | NoneNoneLayer constants; defaults to QB_LAYER_CONSTANTS["modern"].
return_as_pandasboolFalseIf True, returns a pandas DataFrame.

Returns

One row per team-game: game_id / team / expected_qb_id / backup_qb_id / starter_source (depth_chart / previous_start / null) / status (Utf8), kickoff / chart_dt (UTC Datetime; chart_dt is the snapshot used, null under rule 2), p_start (Float64). Zero-row on an empty schedule. team is the franchise's current code (OAK -> LV, SD -> LAC, STL -> LA), as in the play-by-play.

col_nametypedescription
game_idStringnflverse game id from the schedule.
teamStringFranchise code of the side, relocated to the current one as in the play-by-play.
kickoffDatetimeKickoff in UTC (schedule gameday + gametime, US Eastern).
chart_dtDatetimeTimestamp of the depth-chart snapshot used, strictly before kickoff; null when the previous start was used or there is no source.
expected_qb_idStringGSIS id of the pregame expected starter: depth-chart QB1, else the previous game's starter.
backup_qb_idStringGSIS id of depth-chart QB2 from the same snapshot; null without a snapshot or when it lists one QB.
starter_sourceStringWhere the expected starter came from: depth_chart, previous_start, or null (no source).
statusStringExpected starter's final injury-report status that week: Out, Doubtful, Questionable, or the string none.
p_startFloat64Fitted chance the expected starter starts at that status (1.0 when there is no expected starter).

Raises

ExceptionDescription
ValueErrorOn a game with no gametime, depth charts without dt, an injury or depth-chart team code the schedule does not have, or a p_start missing a status.

Example

from sportsdataverse.nfl import load_nfl_depth_charts, load_nfl_injuries, load_nfl_schedule
from sportsdataverse.nfl.nfl_qb_layer import nfl_expected_starters
starters = nfl_expected_starters(
load_nfl_schedule([2025]),
depth_charts=load_nfl_depth_charts([2025]),
injuries=load_nfl_injuries([2025]),
)

nfl_game_script​

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

Team-season pace / PROE / expected-plays engine.

Loads pbp + schedules for seasons, aggregates per-game pace to the team-season level, and computes expected plays per game from the fitted sportsdataverse.nfl.nfl_scheme_constants.PACE_CONSTANTS.

Parameters

ParameterTypeDefaultDescription
seasonsUnion[int, List[int]]Season or list of seasons (nflverse pbp coverage).
return_as_pandasboolFalseWhen True, return a pandas.DataFrame.

Returns

Per (season, team): games, off_plays_pg, sec_per_play, neutral_sec_per_play, proe, exp_plays_pg, plays_oe, pace_rank (1 = fastest neutral pace). Empty seasons yield a zero-row frame with this schema.

col_nametypedescription
seasonInt64Season of the aggregate.
teamStringTeam abbreviation.
gamesInt64Games included in the aggregate.
off_plays_pgFloat64Realized offensive plays per game.
sec_per_playFloat64Season mean of the per-game sec_per_play.
neutral_sec_per_playFloat64Season mean neutral-situation seconds per play (lower = faster).
proeFloat64Season pass-rate over expected, dropback-weighted so it reconciles exactly with the pbp pass_oe aggregate.
exp_plays_pgFloat64Expected plays per game from the fitted PACE_CONSTANTS OLS (own pace, opponent pace, market total).
plays_oeFloat64Realized minus expected plays per game.
pace_rankInt64Rank of neutral pace within the season (1 = fastest).

Example

from sportsdataverse.nfl.nfl_gamescript import nfl_game_script
gs = nfl_game_script([2023])
print(gs.sort("proe", descending=True).head())

# Pipeline next step

gs.filter(pl.col("plays_oe") > 0).sort("plays_oe", descending=True).head()

nfl_game_story​

nfl_game_story(pbp: 'pl.DataFrame', *, return_as_pandas: 'bool' = False) -> 'dict[str, pl.DataFrame] | dict[str, pd.DataFrame]'

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

Parameters

ParameterTypeDefaultDescription
pbpDataFrameThe ESPN-processed plays of one or many games: the espn_nfl_pbp release or a live game's NFLPlayProcess.plays_frame (set by run_processing_pipeline()), with the columns ~sportsdataverse.cfb.cfb_game_story.cfb_game_story lists. The NFL frame has no homeFinalScore / awayFinalScore, so the final is the last running score and periods_agree is always true; add those two columns (the schedule's score) to check it.
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: the accounting phases (passing, rushing, special_teams, other) and splits (turnovers, explosive_plays, success_rate, red_zone, late_downs) in expected points, ranked; the largest-|wpa| play; quarters and OT. A tie (decided false) has null winner ids. Plays 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: passing, rushing, special_teams, other (every play with an EPA once; their sum is the net EPA). Splits: turnovers, explosive_plays, success_rate, red_zone, late_downs.
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: expected points added, the 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, 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 epa: the expected points added the performer is chosen by.
valueFloat64The player's EPA as passer, rusher and receiver combined (a target credits both the passer and the receiver; ties go to touchdowns).

Raises

ExceptionDescription
polars.exceptions.ColumnNotFoundErrorIf pbp lacks a column the football adapter reads.

Example

import polars as pl
from sportsdataverse.nfl.nfl_game_story import nfl_game_story
url = (
"https://github.com/sportsdataverse/sportsdataverse-data/releases/download/"
"espn_nfl_pbp/play_by_play_2025.parquet"
)
pbp = pl.read_parquet(url, use_pyarrow=True)
story = nfl_game_story(pbp.filter(pl.col("game_id") == pbp["game_id"].max()))
story["edges"].head(3)

# Every game's moment

nfl_game_story(pbp)["moment"].select("game_id", "text", "winner_wpa")

nfl_play_call_probabilities​

nfl_play_call_probabilities(pbp: 'pl.DataFrame', participation: 'Optional[pl.DataFrame]' = None, *, models_dir: 'Optional[str]' = None, return_as_pandas: 'bool' = False) -> "Union[pl.DataFrame, 'pd.DataFrame']"

Score the bundled play-call classifier over offensive plays.

Parameters

ParameterTypeDefaultDescription
pbpDataFramenflverse-format pbp (must carry xpass; run sportsdataverse.nfl.ep_wp.calculate_xpass first if not).
participationOptional[DataFrame]NoneOptional participation frame for personnel features.
models_dirOptional[str]NoneOptional directory holding nfl_playcall.ubj (defaults to the bundled package artifact; no first-use download).
return_as_pandasboolFalseWhen True, return a pandas.DataFrame.

Returns

Keys + per-family probabilities p_inside_run / p_outside_run / p_short_pass / p_deep_pass / p_scramble, p_pass (pass-family sum), pred_family (argmax) and pass_oe_model (100 * (is_pass - p_pass)). Empty input yields a zero-row frame with this schema.

col_nametypedescription
game_idStringnflverse game identifier (Utf8 join key).
play_idInt64nflverse play identifier within the game (Int64 join key).
seasonInt64Season of the play.
weekInt64Week of the play.
posteamStringOffense (possession) team abbreviation.
p_inside_runFloat64Predicted probability of an inside run (guard/center gap or middle).
p_outside_runFloat64Predicted probability of an outside run (end/tackle or off-middle).
p_short_passFloat64Predicted probability of a short pass.
p_deep_passFloat64Predicted probability of a deep pass.
p_scrambleFloat64Predicted probability of a QB scramble.
p_passFloat64Predicted pass probability (short + deep + scramble family sum).
pred_familyStringArgmax family among the five class probabilities.
pass_oe_modelFloat64Pass-rate over model expectation for the play, 100 * (is_pass - p_pass).

Example

from sportsdataverse.nfl import load_nfl_pbp
from sportsdataverse.nfl.ep_wp import calculate_xpass
from sportsdataverse.nfl.nfl_playcall import nfl_play_call_probabilities
out = nfl_play_call_probabilities(calculate_xpass(load_nfl_pbp([2023])))
print(out.select("p_pass", "pred_family").head())

# Pipeline next step

out.group_by("posteam").agg(pl.col("p_pass").mean()).sort("p_pass")

nfl_play_call_tendencies​

nfl_play_call_tendencies(pbp: 'pl.DataFrame', participation: 'Optional[pl.DataFrame]' = None, *, models_dir: 'Optional[str]' = None, return_as_pandas: 'bool' = False) -> "Union[pl.DataFrame, 'pd.DataFrame']"

Aggregate scored play-call probabilities to team-season tendencies.

Parameters

ParameterTypeDefaultDescription
pbpDataFramenflverse-format pbp (with xpass).
participationOptional[DataFrame]NoneOptional participation frame.
models_dirOptional[str]NoneOptional directory holding nfl_playcall.ubj.
return_as_pandasboolFalseWhen True, return a pandas.DataFrame.

Returns

Per (season, posteam): plays, mean_p_pass, pass_rate, proe (100 * (pass_rate - mean_p_pass)) and the family mix shares share_<family>. Empty input yields a zero-row frame.

col_nametypedescription
seasonInt64Season of the aggregate.
posteamStringOffense team abbreviation.
playsInt64Offensive run/pass plays scored.
mean_p_passFloat64Mean model pass probability across the team's plays.
pass_rateFloat64Actual pass rate (scrambles count as passes).
proeFloat64Pass rate over expected, 100 * (pass_rate - mean_p_pass).
share_inside_runFloat64Share of plays labeled inside_run.
share_outside_runFloat64Share of plays labeled outside_run.
share_short_passFloat64Share of plays labeled short_pass.
share_deep_passFloat64Share of plays labeled deep_pass.
share_scrambleFloat64Share of plays labeled scramble.

Example

from sportsdataverse.nfl import load_nfl_pbp
from sportsdataverse.nfl.ep_wp import calculate_xpass
from sportsdataverse.nfl.nfl_playcall import nfl_play_call_tendencies
t = nfl_play_call_tendencies(calculate_xpass(load_nfl_pbp([2023])))
print(t.sort("proe", descending=True).head())

nfl_player_props​

nfl_player_props(seasons: 'int | list[int]', *, as_of_date: 'datetime.date | None' = None, era: 'str' = 'modern', lines: 'pl.DataFrame | None' = None, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Empirical-Bayes player-prop projections, leakage-safe per week.

For every game in the requested season(s) (or, with as_of_date, every game on/after that date), projects each rostered QB/RB/WR/TE's stat-family mean as usage x efficiency x matchup x game-script:

  • usage + efficiency from player_usage_efficiency built as-of that game's week (weeks strictly before it),
  • the matchup multiplier from the opponent's adj_def_epa in sportsdataverse.nfl.nfl_ratings.nfl_ratings (as-of the week's first game date),
  • game script from the native expected margin (sportsdataverse.nfl.nfl_market.nfl_predict_games) -- the market line is never read (binding non-market boundary).

Parameters

ParameterTypeDefaultDescription
seasonsint | list[int]Season (e.g. 2023) or list of seasons.
as_of_datedate | NoneNoneWhen given, only games with gameday >= as_of_date are projected (history before each game's week still feeds the projections). None projects every week of the season(s).
erastr'modern'Constants era key.
linesDataFrame | NoneNoneOptional market lines to score p_over against -- columns game_id / player_id / stat (Utf8) + line (Float64), e.g. built from espn_nfl_game_propbets (ESPN only serves propbets for upcoming games). None leaves line / p_over null.
return_as_pandasboolFalseIf True, returns a pandas DataFrame.

Returns

One row per (player-game, stat): season / week (Int64), game_id / player_id / position / team_id / opp_team_id / stat (Utf8), proj_mean / proj_sd / line / p_over (Float64; p_over = 1 - Phi((line - proj_mean) / proj_sd) when a line is joined, else null). Stats are passing_yards (QB), rushing_yards (RB), receiving_yards (WR/TE). Zero-row, correctly-typed when there is nothing to project.

col_nametypedescription
seasonInt64Season the projection belongs to.
weekInt64Week of the projected game; only weeks strictly before it feed the projection.
game_idStringGame identifier from the schedule (nflverse id, e.g. "2023_06_DET_TB").
player_idStringnflverse GSIS player identifier (character join key).
positionStringPlayer position (QB, RB, WR, TE) selecting the projected stat family.
team_idStringPlayer's team nflverse abbreviation as of the projection week.
opp_team_idStringOpponent team nflverse abbreviation (drives the matchup multiplier).
statStringProjected stat name (passing_yards for QB, rushing_yards for RB, receiving_yards for WR/TE).
proj_meanFloat64Projected stat mean - EB-shrunk usage x efficiency x opponent matchup x game-script.
proj_sdFloat64Residual standard deviation for the stat family (fitted on the 2023 as-of backtest).
lineFloat64Market prop line joined from the caller-supplied lines frame (e.g. espn_nfl_game_propbets); null when no line is available.
p_overFloat64Probability the player exceeds line, 1 - Phi((line - proj_mean) / proj_sd); null without a line.

Example

from sportsdataverse.nfl import nfl_player_props
props = nfl_player_props(2023)
props.filter(props["stat"] == "passing_yards").head()

# Upcoming-only, as-of a date

import datetime as dt
props = nfl_player_props(2024, as_of_date=dt.date(2024, 11, 1))

nfl_predict_games​

nfl_predict_games(games: 'pl.DataFrame', ratings: 'pl.DataFrame', *, era: 'str' = 'modern', odds: 'pl.DataFrame | None' = None, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Vectorized pregame predictions (+ display-only market edge) per game.

Joins ratings twice (home/away) onto the schedule and computes the three closed-form predictions. odds is display-only: it feeds market_edge = exp_margin - close_spread_home and never the predictions themselves (the binding non-market boundary).

Parameters

ParameterTypeDefaultDescription
gamesDataFrameOne row per game: game_id (Utf8), home_team_id / away_team_id (Utf8 team abbreviations), neutral_site (Boolean).
ratingsDataFrameThe sportsdataverse.nfl.nfl_ratings.nfl_ratings output (needs team_id, adj_off_epa, adj_def_epa, adj_net).
erastr'modern'Constants era key.
oddsDataFrame | NoneNoneOptional market frame (game_id, close_spread_home -- the market's expected home margin, positive = home favored). A sportsbook quotes the home favourite as -7: negate the quoted line (close_spread_home = 7) before passing it. Nothing in the package builds this column. Games absent from odds get a null market_edge.
return_as_pandasboolFalseIf True, returns a pandas DataFrame.

Returns

One row per input game: game_id / home_team_id / away_team_id (Utf8), neutral_site (Boolean), exp_margin / home_win_prob / exp_total / market_edge (Float64; market_edge null without odds). Zero-row, correctly-typed on empty input.

col_nametypedescription
game_idStringGame identifier carried through from the input schedule.
home_team_idStringHome team nflverse abbreviation (character; the ratings team_id join key).
away_team_idStringAway team nflverse abbreviation (character; the ratings team_id join key).
neutral_siteBooleanWhether the game is at a neutral site (home-field advantage is dropped when true).
exp_marginFloat64Expected home scoring margin in points (points_per_net * net rating differential + the fitted home-field advantage on non-neutral fields).
home_win_probFloat64Home win probability, Phi(exp_margin / margin_sd) under a Gaussian margin model.
exp_totalFloat64Expected combined point total (avg_total + total_scale * the four-way efficiency matchup sum).
market_edgeFloat64Display-only native-minus-market spread edge (exp_margin - close_spread_home); null when no odds frame is supplied.

Raises

ExceptionDescription
AssertionErrorIf a join-key dtype disagrees (home_team_id / away_team_id vs ratings.team_id, or game_id vs odds.game_id).

Example

from sportsdataverse.nfl import nfl_ratings
from sportsdataverse.nfl.nfl_market import nfl_predict_games
ratings = nfl_ratings(2023)
preds = nfl_predict_games(games, ratings)
preds.sort("home_win_prob", descending=True).head()

# With a market edge (display only)

preds = nfl_predict_games(games, ratings, odds=odds)

nfl_punter_value​

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

Punter net-field-position value over expected.

Expected net comes from the shipped punt landing distribution (nfl_fourth_down._load_punt_data) evaluated at each punt's line of scrimmage; realized net is kick_distance - return_yards - 20*touchback.

Parameters

ParameterTypeDefaultDescription
seasonsUnion[int, List[int]]Season or list of seasons.
return_as_pandasboolFalseWhen True, return a pandas.DataFrame.

Returns

Per (season, punter_player_id): punts, gross_avg, net_avg, exp_net_avg, net_over_expected, epa. Empty seasons yield a zero-row frame with this schema.

col_nametypedescription
seasonInt64Season of the aggregate.
punter_player_idStringnflverse punter GSIS id (Utf8 join key).
puntsInt64Punts with a recorded kick distance.
gross_avgFloat64Mean gross punt distance (yards).
net_avgFloat64Mean net distance, kick_distance - return_yards - 20 * touchback.
exp_net_avgFloat64Mean expected net from the shipped punt landing distribution at each punt's line of scrimmage.
net_over_expectedFloat64net_avg minus exp_net_avg (yards of field position per punt over expectation).
epaFloat64Total EPA on the punter's punt plays (kicking-team perspective).

Example

from sportsdataverse.nfl.nfl_special_teams import nfl_punter_value
pv = nfl_punter_value([2023])
print(pv.head())

nfl_qb_dropbacks​

nfl_qb_dropbacks(pbp: 'pl.DataFrame') -> 'pl.DataFrame'

One row per offensive pass or run play, with the QB on dropbacks.

The shared input of the layer: QB values read the dropback rows, and each team's dropback share reads all of them.

Parameters

ParameterTypeDefaultDescription
pbpDataFramenflverse-schema play-by-play (sportsdataverse.nfl.load_nfl_pbp) with game_id, season, game_date, posteam, play_type, qb_dropback, qb_epa, passer_player_id and rusher_player_id.

Returns

game_id / team / qb_id (Utf8; qb_id null off dropbacks), season (Int64), game_date (Date), qb_epa (Float64), is_dropback (Boolean). Plays with play_type other than pass / run are dropped; a dropback with no QB id or no qb_epa is kept as a play but not as a dropback.

col_nametypedescription
game_idStringnflverse game id of the play (2025_05_DET_CIN).
seasonInt64Season of the play (the year the season starts).
game_dateDateDate of the game, the as-of key every QB-layer window is cut on.
teamStringOffense's franchise code, relocated to the current one (OAK -> LV, SD -> LAC, STL -> LA).
qb_idStringGSIS id of the QB on a dropback (passer, else scrambling rusher); null off dropbacks.
qb_epaFloat64nflverse qb_epa of the play (EPA credited to the QB).
is_dropbackBooleanTrue on a QB dropback with a QB id and a non-null qb_epa; False on a designed run (a scramble is a dropback), an unattributed play or a null qb_epa.

Example

from sportsdataverse.nfl import load_nfl_pbp
from sportsdataverse.nfl.nfl_qb_layer import nfl_qb_dropbacks
db = nfl_qb_dropbacks(load_nfl_pbp([2024]))

nfl_qb_margin_mixture​

nfl_qb_margin_mixture(margins: 'Sequence[float]', weights: 'Sequence[float]', *, sigma: 'float') -> 'dict[str, float]'

Mean, win probability and 80% interval of a Normal mixture of home margins.

Parameters

ParameterTypeDefaultDescription
marginsSequence[float]Component means (points, home minus away).
weightsSequence[float]Component weights (non-negative; renormalised to sum to 1).
sigmafloatCommon component standard deviation (the spine's margin_sd).

Returns

{"mean", "win_prob", "lo80", "hi80"}: the mixture mean, P(margin > 0), and its 0.10 / 0.90 quantiles (bisection to 1e-6 points). One component reduces to m +/- 1.2816 * sigma.

Raises

ExceptionDescription
ValueErrorOn empty or mismatched inputs, or weights that do not sum to a positive number.

Example

from sportsdataverse.nfl.nfl_qb_layer import nfl_qb_margin_mixture
nfl_qb_margin_mixture([3.0, -2.0], [0.7, 0.3], sigma=13.02)

nfl_qb_predict_games​

nfl_qb_predict_games(schedule: 'pl.DataFrame', pbp: 'pl.DataFrame', *, starters: 'pl.DataFrame | None' = None, starter: "Literal['expected', 'realized']" = 'expected', era: 'str' = 'modern', config: 'QBLayerConfig | None' = None, ratings_config: 'RatingsConfig | None' = None) -> 'pl.DataFrame'

Base spine and QB-layer pregame margin, win probability and 80% interval per game.

For each game date the spine's efficiency ratings are fitted on that season's plays from games strictly before the date (as sportsdataverse.nfl.nfl_ratings with as_of_date), QB values on career dropbacks before the date, and each team's dropback exposure on the same window. base_* is the shipped spine; qb_* adds the starter shift and the start-probability mixture.

Parameters

ParameterTypeDefaultDescription
scheduleDataFrameThe games to price (sportsdataverse.nfl.load_nfl_schedule rows; location == "Neutral" marks a neutral site).
pbpDataFramenflverse play-by-play covering the priced seasons and the QB history (from config.history_start_season).
startersDataFrame | NoneNonenfl_expected_starters output, required for starter="expected".
starterLiteral['expected', 'realized']'expected'"expected" (the pregame arm) or "realized" (the schedule's home_qb_id / away_qb_id with p = 1: an upper bound, never a pregame input).
erastr'modern'Spine constants era (hfa, points_per_net, margin_sd).
configQBLayerConfig | NoneNoneLayer constants; defaults to QB_LAYER_CONSTANTS["modern"].
ratings_configRatingsConfig | NoneNoneRidge constants; defaults to RatingsConfig.

Returns

One row per priced game with a rating for both teams (games before either team has a rated play are dropped): game_id / home_team / away_team (Utf8, team codes relocated as in nfl_expected_starters), season / week (Int64), neutral_site (Boolean); base_margin / base_win_prob / base_lo80 / base_hi80 (the shipped spine) and qb_margin / qb_win_prob / qb_lo80 / qb_hi80 (the layer's mixture mean, P(home wins) and 80% interval), all Float64; per side *_qb_id / *_status (Utf8), *_p_start and *_shift (Float64, the starter's shift to adj_net in EPA per play) and *_layer_applied (Boolean, False when the side had no starter or no rated dropbacks and the layer left it unchanged).

col_nametypedescription
game_idStringnflverse game id from the schedule.
seasonInt64Season of the game.
weekInt64Week of the game.
home_teamStringHome franchise code, relocated to the current one.
away_teamStringAway franchise code, relocated to the current one.
neutral_siteBooleanTrue when the schedule's location is Neutral (no home-field advantage).
base_marginFloat64Shipped spine's expected home margin in points, ratings as of the game date.
base_win_probFloat64Shipped spine's home win probability, Phi(base_margin / margin_sd).
base_lo80Float64Lower end of the spine's 80% home-margin interval (base_margin - 1.2816 margin_sd).
base_hi80Float64Upper end of the spine's 80% home-margin interval (base_margin + 1.2816 margin_sd).
qb_marginFloat64QB layer's expected home margin: mean of the start-probability mixture.
qb_win_probFloat64QB layer's home win probability: P(margin > 0) under the mixture.
qb_lo80Float640.10 quantile of the QB layer's home-margin mixture.
qb_hi80Float640.90 quantile of the QB layer's home-margin mixture.
home_qb_idStringGSIS id of the home starter priced (expected, or realized in the realized arm).
away_qb_idStringGSIS id of the away starter priced (expected, or realized in the realized arm).
home_statusStringHome expected starter's report status (Out, Doubtful, Questionable, or the string none; none in the realized arm).
away_statusStringAway expected starter's report status (Out, Doubtful, Questionable, or the string none; none in the realized arm).
home_p_startFloat64Chance the home expected starter starts (1.0 in the realized arm or when unpriced).
away_p_startFloat64Chance the away expected starter starts (1.0 in the realized arm or when unpriced).
home_shiftFloat64Home starter's shift to adj_net in EPA per play: gamma * dropback share * (value - rated value).
away_shiftFloat64Away starter's shift to adj_net in EPA per play: gamma * dropback share * (value - rated value).
home_layer_appliedBooleanFalse when the home side had no starter or no rated dropbacks and was left unchanged.
away_layer_appliedBooleanFalse when the away side had no starter or no rated dropbacks and was left unchanged.

Raises

ExceptionDescription
ValueErrorIf starter="expected" and starters is None.

Example

from sportsdataverse.nfl import load_nfl_pbp, load_nfl_schedule
from sportsdataverse.nfl.nfl_qb_layer import nfl_expected_starters, nfl_qb_predict_games
sched = load_nfl_schedule([2025]).filter(pl.col("game_type") == "REG")
pbp = load_nfl_pbp(list(range(2006, 2026)))
preds = nfl_qb_predict_games(sched, pbp, starters=nfl_expected_starters(sched))

nfl_qb_values​

nfl_qb_values(dropbacks: 'pl.DataFrame', *, as_of_date: 'datetime.date', config: 'QBLayerConfig | None' = None, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Shrunk career EPA per dropback for every QB, as of a date.

qb_value = (n * e + k * prior) / (n + k) over the QB's dropbacks in games strictly before as_of_date (seasons from config.history_start_season), with prior the replacement level below new_qb_dropbacks career dropbacks and the league mean from there on.

Parameters

ParameterTypeDefaultDescription
dropbacksDataFramenfl_qb_dropbacks output.
as_of_datedateExclusive cutoff (the game's date).
configQBLayerConfig | NoneNoneLayer constants; defaults to QB_LAYER_CONSTANTS["modern"].
return_as_pandasboolFalseIf True, returns a pandas DataFrame.

Returns

One row per QB: qb_id (Utf8), dropbacks (Int64), epa_per_dropback (Float64, raw), qb_value (Float64, shrunk). A QB absent from the frame has no row; callers value him at the replacement level.

col_nametypedescription
qb_idStringGSIS id of the quarterback.
dropbacksInt64Career dropbacks before the as-of date, from the config's history start season.
epa_per_dropbackFloat64Raw mean qb_epa per dropback over those career dropbacks (unshrunk).
qb_valueFloat64Shrunk value (n * e + k * prior) / (n + k), prior = replacement under new_qb_dropbacks (default 100) else league mean.

Example

import datetime as dt
from sportsdataverse.nfl import load_nfl_pbp
from sportsdataverse.nfl.nfl_qb_layer import nfl_qb_values, nfl_qb_dropbacks
db = nfl_qb_dropbacks(load_nfl_pbp(list(range(2006, 2025))))
values = nfl_qb_values(db, as_of_date=dt.date(2024, 10, 1))

nfl_season_standings​

nfl_season_standings(games: 'pl.DataFrame', *, ranks: 'str' = 'CONF', tiebreaker_depth: 'str' = 'SOS', playoff_seeds: 'Optional[int]' = None, return_as_pandas: 'bool' = False) -> "Union[pl.DataFrame, 'pd.DataFrame']"

Compute NFL standings with the real NFL tiebreaking procedures.

Faithful polars port of nflseedR::nfl_standings() (v2 engine, R/standings.R L82-155): initializes records, points, win percentages, SOV and SOS from a games frame, then resolves division ranks, conference ranks (playoff seeds) and draft order through the full NFL tiebreaker cascades.

Parameters

ParameterTypeDefaultDescription
gamesDataFrameGames frame with one row per game. Required columns: sim or season (identifier), game_type ('REG', 'WC', 'DIV', 'CON', 'SB'), week, away_team, home_team, and result (home score minus away score; no missing values allowed). away_score / home_score are additionally required for tiebreaker_depth='POINTS' and enable the pf/pa/pd output columns.
ranksstr'CONF'One of 'DIV', 'CONF' (default), 'DRAFT', or 'NONE' — which rank columns (and thus tiebreakers) to compute. 'DRAFT' implies 'CONF' implies 'DIV'.
tiebreaker_depthstr'SOS'One of 'SOS' (default), 'PRE-SOV', 'POINTS', or 'RANDOM'. Controls how deep the tiebreaker cascade goes before falling back to a coin toss.
playoff_seedsOptional[int]NoneIf not None, only conference ranks up to this value are resolved with tiebreakers; deeper ranks are returned as null. Must be in 1-16.
return_as_pandasboolFalseIf True, return a pandas DataFrame.

Returns

A standings frame with one row per (sim/season, team) including records, win_pct/div_pct/conf_pct, sov, sos, and the requested div_rank/conf_rank/draft_rank columns plus *_tie_broken_by bookkeeping. conf_rank is the playoff seed.

col_nametypedescription
seasonInt64Season identifier from the input games frame (named sim instead when the input used a sim column).
confStringConference of the team (AFC or NFC).
divisionStringDivision of the team (e.g. "AFC East").
teamStringTeam abbreviation.
gamesInt64Number of regular season games played.
winsFloat64Regular season wins with ties counted as half a win.
true_winsInt64Regular season wins excluding ties (outright wins only).
lossesInt64Regular season losses.
tiesInt64Regular season ties.
pfInt64Points scored across regular season games (points for); present only when the input carries home_score and away_score.
paInt64Points allowed across regular season games (points against); present only when the input carries scores.
pdInt64Regular season point differential (pf minus pa); present only when the input carries scores.
win_pctFloat64Regular season win percentage with ties counted as half a win.
div_pctFloat64Win percentage in games against division opponents (0 when the team played no division games).
conf_pctFloat64Win percentage in games against conference opponents (0 when the team played no conference games).
sovFloat64Strength of victory - combined win percentage of all opponents the team defeated (0 for winless teams).
sosFloat64Strength of schedule - combined win percentage of all opponents the team faced.
div_rankInt64Rank within the division (1-4) after applying the NFL division tiebreaking procedures.
div_tie_broken_byStringTiebreaker step that resolved the team's division rank (e.g. "Head-To-Head Win PCT (2)" or "Coin Toss"); null when the rank needed no tiebreaker.
conf_rankInt64Conference rank, i.e. the playoff seed, after applying the NFL conference tiebreaking procedures; null beyond playoff_seeds when that argument is set.
conf_tie_broken_byStringTiebreaker step that resolved the team's conference rank; null when the rank needed no tiebreaker.
exitStringRound of the team's final game - REG, WC, DIV, CON, SB, or SB_WIN for the Super Bowl winner (returned with ranks="DRAFT").
draft_rankInt64Draft pick position (1 = first overall pick) derived from postseason exit, win percentage, SOS and the draft tiebreaking procedures (returned with ranks="DRAFT").
draft_tie_broken_byStringTiebreaker step that resolved the team's draft rank; null when the rank needed no tiebreaker.

Raises

ExceptionDescription
ValueErrorIf required columns are missing, results contain missing values, an argument is out of range, or a team abbreviation is unknown.

Example

import sportsdataverse.nfl as nfl
games = nfl.load_schedules([2024])
standings = nfl.nfl_season_standings(games, ranks="DRAFT")
print(standings.shape)

# Playoff seeds only, pandas output

df = nfl.nfl_season_standings(
games, ranks="CONF", playoff_seeds=7, return_as_pandas=True
)

# Pipeline next step (one line)

standings.filter(pl.col("conf_rank") <= 7).sort("conf", "conf_rank")

nfl_special_teams_epa​

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

Special-teams EPA by team-unit.

Units: punt / punt_return / kickoff / kickoff_return / field_goal / extra_point. On each punt/kickoff the kicking team's unit carries the play EPA signed to the kicking team and the return team's unit its negation, so a team's units sum to its total ST-play EPA.

Parameters

ParameterTypeDefaultDescription
seasonsUnion[int, List[int]]Season or list of seasons.
return_as_pandasboolFalseWhen True, return a pandas.DataFrame.

Returns

Per (season, team, unit): plays, epa, epa_per_play. Empty seasons yield a zero-row frame with this schema.

col_nametypedescription
seasonInt64Season of the aggregate.
teamStringTeam abbreviation.
unitStringSpecial-teams unit (punt, punt_return, kickoff, kickoff_return, field_goal, extra_point).
playsInt64Plays credited to the unit.
epaFloat64Total EPA credited to the unit (kicking team carries the play EPA signed to it; the return team carries its negation).
epa_per_playFloat64EPA per play for the unit.

Example

from sportsdataverse.nfl.nfl_special_teams import nfl_special_teams_epa
st = nfl_special_teams_epa([2023])
print(st.filter(pl.col("unit") == "punt").sort("epa", descending=True).head())

playcall_features​

playcall_features(pbp: 'pl.DataFrame', participation: 'Optional[pl.DataFrame]' = None) -> 'pl.DataFrame'

Build the play-call feature frame (one row per offensive run/pass play).

Filters to plays with pass == 1 or rush == 1, derives the 5-class family label (scramble > deep/short pass > inside/outside run), and left-joins the optional participation frame for personnel counts.

Parameters

ParameterTypeDefaultDescription
pbpDataFramenflverse-format pbp with the pre-snap feature columns + pass / rush / qb_scramble / pass_length / run_location / run_gap and xpass.
participationOptional[DataFrame]NoneOptional nflverse participation frame with game_id / play_id / offense_personnel.

Returns

Keys + PLAYCALL_FEATURE_ORDER columns + family + is_pass. Personnel columns are null (has_participation=0) when no participation row matches.

col_nametypedescription
game_idStringnflverse game identifier (Utf8 join key).
play_idInt64nflverse play identifier within the game (Int64 join key).
seasonInt64Season of the play.
weekInt64Week of the play.
posteamStringOffense (possession) team abbreviation.
downFloat64Down (1-4) at the snap.
ydstogoFloat64Yards to go for a first down.
yardline_100Float64Yards from the opponent end zone at the snap.
score_differentialFloat64Offense score minus defense score at the snap.
half_seconds_remainingFloat64Seconds remaining in the half.
game_seconds_remainingFloat64Seconds remaining in the game.
wpFloat64Start-of-play win probability for the offense.
shotgunFloat641 when the offense lined up in shotgun.
no_huddleFloat641 when the play was run without a huddle.
xpassFloat64Shipped nflfastR-parity expected-dropback probability for the play.
n_rbFloat64Running backs in the offensive personnel grouping (null without participation data).
n_teFloat64Tight ends in the offensive personnel grouping (null without participation data).
n_wrFloat64Wide receivers in the offensive personnel grouping (null without participation data).
has_participationInt641 when a participation row matched the play, else 0.
familyString5-class play-call label (inside_run, outside_run, short_pass, deep_pass, scramble).
is_passInt641 when the play was a pass (including scrambles), else 0.

Example

from sportsdataverse.nfl import load_nfl_pbp
from sportsdataverse.nfl.ep_wp import calculate_xpass
from sportsdataverse.nfl.nfl_playcall import playcall_features
feat = playcall_features(calculate_xpass(load_nfl_pbp([2023])))
print(feat["family"].value_counts())

player_usage_efficiency​

player_usage_efficiency(player_stats: 'pl.DataFrame', *, as_of_week: 'int', era: 'str' = 'modern') -> 'pl.DataFrame'

Per-player as-of usage + efficiency with empirical-Bayes shrinkage.

Aggregates one season of week-level player stats over weeks strictly before as_of_week (the leakage boundary), then shrinks every usage (per-game attempts / carries / targets) and efficiency (yards + TDs per opportunity) stat toward its position prior: (n * player_value + kappa * prior) / (n + kappa) with n = games played and kappa the stat family's fitted shrinkage.

Parameters

ParameterTypeDefaultDescription
player_statsDataFrameOne season of load_nfl_player_stats() rows (columns player_id, position, recent_team, week, attempts, passing_yards, passing_tds, carries, rushing_yards, rushing_tds, targets, receiving_yards, receiving_tds).
as_of_weekintOnly weeks < as_of_week are used.
erastr'modern'Constants era key (supplies kappas + position priors).

Returns

One row per player_id (Utf8) whose position has a prior table: position / team_id (Utf8, latest team), games (Int64), exp_attempts / exp_carries / exp_targets (Float64, shrunk per-game usage), ypa / ypc / ypt / pass_td_rate / rush_td_rate / rec_td_rate (Float64, shrunk per-opportunity efficiency). Zero-row, correctly-typed on empty input.

col_nametypedescription
player_idStringPlayer ID (aka GSIS ID) as defined by nflreadr::load_rosters
positionStringPrimary position as reported by NFL.com
team_idString
gamesInt64Games played in career
exp_attemptsFloat64
exp_carriesFloat64
exp_targetsFloat64
ypaFloat64
ypcFloat64
yptFloat64
pass_td_rateFloat64
rush_td_rateFloat64
rec_td_rateFloat64

Example

import polars as pl
import sportsdataverse.nfl as nfl
stats = nfl.load_nfl_player_stats().filter(pl.col("season") == 2023)
usage = nfl.player_usage_efficiency(stats, as_of_week=10)
usage.sort("exp_attempts", descending=True).head()

predict_margin​

predict_margin(home_adj_net: 'float', away_adj_net: 'float', neutral: 'bool', *, era: 'str' = 'modern') -> 'float'

Expected home scoring margin from two net ratings.

points_per_net * (home_adj_net - away_adj_net) plus the era HFA on non-neutral fields.

Parameters

ParameterTypeDefaultDescription
home_adj_netfloatHome team's adj_net (EPA/play units).
away_adj_netfloatAway team's adj_net.
neutralboolTrue drops the home-field advantage.
erastr'modern'Constants era key (default "modern").

Returns

Expected home margin in points (positive = home favored).

Example

from sportsdataverse.nfl.nfl_market import predict_margin
predict_margin(0.10, -0.05, False)

predict_total​

predict_total(home_adj_off: 'float', home_adj_def: 'float', away_adj_off: 'float', away_adj_def: 'float', *, era: 'str' = 'modern') -> 'float'

Expected combined point total from the four efficiency components.

avg_total + total_scale * (home_adj_off + away_adj_def + away_adj_off + home_adj_def). The four ratings are summed because each side's scoring rises with its own offense and with the opponent's EPA-allowed (adj_def is lower = better defense) -- same semantics as the shipped CFB analog. (The plan text wrote this with a minus; that sign flips a good defense into raising the total, so the analog's sum is used.)

Parameters

ParameterTypeDefaultDescription
home_adj_offfloatHome adj_off_epa.
home_adj_deffloatHome adj_def_epa (lower = better defense).
away_adj_offfloatAway adj_off_epa.
away_adj_deffloatAway adj_def_epa.
erastr'modern'Constants era key.

Returns

Expected combined total in points.

Example

from sportsdataverse.nfl.nfl_market import predict_total
predict_total(0.10, -0.02, 0.05, 0.01)

team_game_pace​

team_game_pace(pbp: 'pl.DataFrame') -> 'pl.DataFrame'

Per team-game pace + pass-rate-over-expected.

sec_per_play is the per-drive elapsed game_seconds_remaining divided by drive plays, averaged over the team's offensive drives (kneels / spikes / no_plays excluded). Neutral = wp in [0.2, 0.8] and half_seconds_remaining > 120. proe is the mean pass_oe over dropbacks.

Parameters

ParameterTypeDefaultDescription
pbpDataFramenflverse-format pbp with game_id / season / week / posteam / drive / play_type / qb_dropback / pass_oe / game_seconds_remaining / wp / half_seconds_remaining.

Returns

One row per (game_id, season, week, posteam) with off_plays, sec_per_play, neutral_plays, neutral_sec_per_play, proe. Empty input yields a zero-row frame with this schema.

col_nametypedescription
game_idStringnflverse game identifier (Utf8 join key).
seasonInt64Season of the game.
weekInt64Week of the game.
posteamStringOffense team abbreviation.
off_playsInt64Offensive plays in the game (kneels, spikes and no_plays excluded).
sec_per_playFloat64Mean over the team's drives of elapsed game clock divided by drive plays.
neutral_playsInt64Offensive plays in neutral situations (wp in [0.2, 0.8], over 2 minutes left in the half).
neutral_sec_per_playFloat64sec_per_play computed on neutral-situation plays only.
proeFloat64Mean pass_oe over the team's dropbacks in the game (percentage points).
dropbacksInt64Dropbacks with a non-null pass_oe (the proe denominator).

Example

from sportsdataverse.nfl import load_nfl_pbp
from sportsdataverse.nfl.nfl_gamescript import team_game_pace
pace = team_game_pace(load_nfl_pbp([2023]))
print(pace.sort("sec_per_play").head())

win_prob_from_margin​

win_prob_from_margin(exp_margin: 'float', *, era: 'str' = 'modern') -> 'float'

Home win probability from an expected margin (Gaussian margin model).

Parameters

ParameterTypeDefaultDescription
exp_marginfloatExpected home margin in points.
erastr'modern'Constants era key (supplies margin_sd).

Returns

Phi(exp_margin / margin_sd) in [0, 1].

Example

from sportsdataverse.nfl.nfl_market import win_prob_from_margin
win_prob_from_margin(3.0)