Skip to main content
Version: 0.1.5

CFB — additional Python functions — Models and calculators: add_era–cfb_adjusted

add_era_columns​

add_era_columns(df: 'pl.DataFrame', model: 'str', season: 'int | None' = None) -> 'pl.DataFrame'

Add the era column(s) model consumes, using ITS card's cuts.

The cuts are read from the published contract, never restated here. That is the fix for cfbfastR-cfb-data#70, where both consumers kept a private copy of the era boundary, both drifted to a 2017 cut the trainer never used, and 2018-2020 scored an era off the models trained with them.

Parameters

ParameterTypeDefaultDescription
dfDataFrameFrame carrying a season column, or any frame when season is given explicitly.
modelstrBundle stem, used to look up the era contract.
seasonint | NoneNoneSeason to use when df has no season column -- the hand-built-row case.

Returns

df with the contract's columns added. Returned unchanged when the model declares no era contract, or when the columns are already present.

col_nametypedescription
seasonintegerSeason (4-digit year).
game_idintegerESPN game identifier.
game_play_numberintegerSequential play number within the game (excludes timeouts/end markers).
pos_team_idintegerTeam id of the offense (possession team) on the play.
pos_teamcharacterTeam name in possession at the start of the play (offense, kickoff-aware).
def_pos_team_idintegerTeam id of the defense on the play.
def_pos_teamcharacterTeam name on defense at the start of the play.
pos_team_scoreintegerScore for the team in possession at the start of the play.
def_pos_team_scoreintegerScore for the defensive team at the start of the play.
halfintegerHalf indicator (1 or 2).
periodintegerPeriod (quarter) number.
downintegerDown of the play (1-4).
distanceintegerYards to gain for a first down (or to the goal line in goal-to-go situations).
EPAdoubleExpected Points Added on the play (cfbfastR EPA model output).
wpadoubleWin Probability Added on the play (cfbfastR WP model output).
wp_beforedoubleWin probability for the possession team before the play (0-1).
wp_afterdoubleWin probability for the possession team after the play (0-1).
def_wp_beforedoubleWin probability for the defensive team before the play (0-1).
def_wp_afterdoubleWin probability for the defensive team after the play (0-1).
penalty_detailcharacterParsed penalty description extracted from play text.
yds_penaltycharacterYardage assessed on the penalty.
penalty_1st_convlogicalTRUE when the penalty resulted in a first down conversion.
new_serieslogicalBinary flag for the start of a new series of downs.
firstD_by_kickofflogicalBinary flag for a new first down arising from a kickoff.
firstD_by_posslogicalBinary flag for a new first down via change of possession.
firstD_by_penaltylogicalBinary flag for a new first down via penalty.
firstD_by_yardslogicalBinary flag for a new first down via yards gained.
def_EPAdoubleEPA for the defensive team on the play (sign-flipped offense EPA).
rz_playlogicalBinary flag for a red-zone play (yards_to_goal <= 20).
scoring_opplogicalBinary flag for a scoring opportunity (yards_to_goal <= 40).
middle_8logicalTRUE for plays in the middle-8 window (final 4 min of 1H, first 4 min of 2H).
stuffed_runlogicalBinary flag for a stuffed run (zero or negative yards gained).
change_of_pos_teamlogicalBinary flag for change of possession-team on the play.
downs_turnoverlogicalBinary flag for a turnover on downs.
pos_score_diff_startintegerScore differential for the possession team at the start of the play.
pos_score_ptsintegerPoints scored on the play attributed to the possession team.
home_wp_beforedoubleHome team win probability before the play (0-1).
away_wp_beforedoubleAway team win probability before the play (0-1).
home_wp_afterdoubleHome team win probability after the play (0-1).
away_wp_afterdoubleAway team win probability after the play (0-1).
end_of_halflogicalBinary flag for the last play of a half.
orig_play_typecharacterOriginal CFBD play type label before cfbfastR cleaning.
offense_score_playlogicalBinary flag for an offensive scoring play.
defense_score_playlogicalBinary flag for a defensive scoring play.
pos_score_diffintegerScore differential from the possession team's perspective.
change_of_posslogicalBinary flag for change of possession on the play (CFBD offense field).
rusher_player_namecharacterName of the rusher on a rushing play.
yds_rushedintegerRushing yards gained on the play.
passer_player_namecharacterName of the passer on a passing play.
receiver_player_namecharacterName of the receiver on a passing play.
yds_receivingintegerReceiving yards gained on the play.
yds_sackedintegerYards lost on the sack.
sack_playerscharacterCombined names of all sack participants.
sack_player_namecharacterPrimary sack player name.
sack_player_name2characterSecondary sack player name (when split between two defenders).
pass_breakup_player_namecharacterName of the defender credited with the pass breakup.
interception_player_namecharacterName of the defender credited with the interception.
yds_int_returnintegerYards gained on an interception return.
fumble_player_namecharacterName of the player who fumbled.
fumble_forced_player_namecharacterName of the player who forced the fumble.
fumble_recovered_player_namecharacterName of the player who recovered the fumble.
yds_fumble_returnintegerYards gained on a fumble return.
punter_player_namecharacterName of the punter.
yds_puntedintegerYards the ball traveled on the punt.
yds_punt_returnintegerYards gained on the punt return.
yds_punt_gainedintegerNet yards gained on the punt (punt distance minus return).
punt_block_player_namecharacterName of the player credited with blocking the punt.
punt_block_return_player_namecharacterName of the player returning a blocked punt.
fg_kicker_player_namecharacterName of the field goal kicker.
yds_fgintegerDistance of the field goal attempt in yards.
fg_block_player_namecharacterName of the player credited with blocking the field goal.
fg_return_player_namecharacterName of the player returning the blocked/missed field goal.
kickoff_player_namecharacterName of the kickoff specialist.
yds_kickoffintegerYards the ball traveled on the kickoff.
yds_kickoff_returnintegerYards gained on the kickoff return.
rushlogicalBinary flag for a rushing play.
rush_tdlogicalBinary flag for a rushing touchdown.
passlogicalBinary flag for a passing play (includes sacks).
pass_tdlogicalBinary flag for a passing touchdown.
completionlogicalBinary flag for a completed pass.
pass_attemptlogicalBinary flag for a pass attempt.
targetlogicalBinary flag for a targeted receiver on the play.
sacklogicalBinary flag for a sack (duplicate of sack_vec for downstream use).
intlogicalBinary flag for an interception.
int_tdlogicalBinary flag for an interception returned for a touchdown.
turnover_veclogicalBinary flag for any play classified as a turnover.
kickoff_playlogicalBinary flag for a kickoff play.
scoring_playlogicalTRUE if the play resulted in a score.
td_playlogicalBinary flag for a touchdown play.
touchdownlogicalBinary flag for a touchdown (duplicate of td_play for downstream use).
safetylogicalBinary flag for a safety.
fumble_veclogicalBinary flag for a play involving a fumble.
kickoff_tblogicalBinary flag for a kickoff touchback.
kickoff_onsidelogicalBinary flag for an onside kickoff attempt.
kickoff_ooblogicalBinary flag for a kickoff out of bounds.
kickoff_fair_catchlogicalBinary flag for a kickoff fair catch.
kickoff_downedlogicalBinary flag for a kickoff downed in the field of play.
kickoff_safetylogicalBinary flag for a kickoff safety.
puntlogicalBinary flag for a punt play.
punt_playlogicalBinary flag for any punt-related play (includes blocks/returns).
punt_tblogicalBinary flag for a punt touchback.
punt_ooblogicalBinary flag for a punt out of bounds.
punt_fair_catchlogicalBinary flag for a punt fair catch.
punt_downedlogicalBinary flag for a punt downed in the field of play.
punt_safetylogicalBinary flag for a punt safety.
punt_blockedlogicalBinary flag for a blocked punt.
penalty_safetylogicalBinary flag for a safety scored on a penalty.
fg_madelogicalTRUE when the field goal attempt was successful.
fg_make_probdoublePredicted probability of making the field goal (cfbfastR FG model, 0-1).
penalty_flaglogicalTRUE when a penalty was flagged on the play.
penalty_declinedlogicalTRUE when the penalty was declined.
penalty_no_playlogicalTRUE when the penalty nullified the play (no play counted).
penalty_offsetlogicalTRUE when offsetting penalties were called.
penalty_textcharacterTRUE when penalty information is detectable in the play text.
lead_wp_before2doubleValue of wp_before 2 plays ahead, used for sequence-aware derivations.
lead_wp_beforedoubleValue of wp_before on the next play, used for sequence-aware derivations.
lead_pos_team2integerValue of pos_team 2 plays ahead, used for sequence-aware derivations.
idinteger247Sports referencing id for the recruit.
sequenceNumberinteger
textcharacterFull play description.
awayScoreinteger
homeScoreinteger
scoringPlaylogicalESPN flag marking the play as a scoring play.
prioritylogicalTRUE if ESPN flags the play as a priority highlight.
modifiedcharacterISO timestamp the play record was last modified.
wallclockcharacterReal-world ISO timestamp of the play.
teamParticipantscharacterRaw ESPN team-level participants payload carried through from the plays feed (stringified).
isPenaltylogicalESPN's per-play flag that a penalty occurred on the play.
statYardageintegerYardage ESPN credits to the play for statistical purposes.
isTurnoverlogicalESPN's per-play turnover flag as shipped in the plays feed (broader than the giveaway-based is_turnover derivation).
type.idcharacterESPN's numeric identifier for the play type.
type.textcharacterESPN's text label for the play type.
type.abbreviationcharacterESPN's abbreviation for the play type.
period.numberintegerPeriod (quarter) number in which the play occurred.
clock.displayValuecharacterGame clock at the play, as the displayed mm:ss string.
start.downintegerESPN's down value for the play state at the start of the play.
start.distanceintegerESPN's distance value for the play state at the start of the play.
start.yardLineintegerESPN's yardLine value for the play state at the start of the play.
start.yardsToEndzoneintegerESPN's yardsToEndzone value for the play state at the start of the play.
start.team.idintegerESPN's team.id value for the play state at the start of the play.
end.downintegerESPN's down value for the play state at the end of the play.
end.distanceintegerESPN's distance value for the play state at the end of the play.
end.yardLineintegerESPN's yardLine value for the play state at the end of the play.
end.yardsToEndzoneintegerESPN's yardsToEndzone value for the play state at the end of the play.
end.downDistanceTextcharacterESPN's downDistanceText value for the play state at the end of the play.
end.shortDownDistanceTextcharacterESPN's shortDownDistanceText value for the play state at the end of the play.
end.possessionTextcharacterESPN's possessionText value for the play state at the end of the play.
end.team.idintegerESPN's team.id value for the play state at the end of the play.
start.downDistanceTextcharacterESPN's downDistanceText value for the play state at the start of the play.
start.shortDownDistanceTextcharacterESPN's shortDownDistanceText value for the play state at the start of the play.
start.possessionTextcharacterESPN's possessionText value for the play state at the start of the play.
scoringType.namecharacterESPN's name for the scoring type (e.g. touchdown, field goal).
scoringType.displayNamecharacterESPN's display label for the scoring type.
scoringType.abbreviationcharacterESPN's abbreviation for the scoring type.
pointAfterAttempt.iddoubleESPN identifier for the point-after attempt type on the scoring play.
pointAfterAttempt.textcharacterESPN description of the point-after attempt and its result.
pointAfterAttempt.abbreviationcharacterESPN abbreviation of the point-after attempt type; drives the extra-point / two-point result derivation.
pointAfterAttempt.valuedoublePoints ESPN credits for the point-after attempt (1.0 made extra point, 2.0 made two-point try).
drive.idcharacterESPN's id field for the drive containing this play.
drive.displayResultcharacterESPN's displayResult field for the drive containing this play.
drive.isScorelogicalESPN's isScore field for the drive containing this play.
drive.team.shortDisplayNamecharacterESPN's team.shortDisplayName field for the drive containing this play.
drive.team.displayNamecharacterESPN's team.displayName field for the drive containing this play.
drive.team.namecharacterESPN's team.name field for the drive containing this play.
drive.team.abbreviationcharacterESPN's team.abbreviation field for the drive containing this play.
drive.yardsintegerESPN's yards field for the drive containing this play.
drive.offensivePlaysintegerESPN's offensivePlays field for the drive containing this play.
drive.resultcharacterESPN's result field for the drive containing this play.
drive.descriptioncharacterESPN's description field for the drive containing this play.
drive.shortDisplayResultcharacterESPN's shortDisplayResult field for the drive containing this play.
drive.timeElapsed.displayValuecharacterESPN's timeElapsed.displayValue field for the drive containing this play.
drive.start.period.numberintegerESPN's start.period.number field for the drive containing this play.
drive.start.period.typecharacterESPN's start.period.type field for the drive containing this play.
drive.start.yardLineintegerESPN's start.yardLine field for the drive containing this play.
drive.start.clock.displayValuecharacterESPN's start.clock.displayValue field for the drive containing this play.
drive.start.textcharacterESPN's start.text field for the drive containing this play.
drive.end.period.numberintegerESPN's end.period.number field for the drive containing this play.
drive.end.period.typecharacterESPN's end.period.type field for the drive containing this play.
drive.end.yardLineintegerESPN's end.yardLine field for the drive containing this play.
drive.end.clock.displayValuecharacterESPN's end.clock.displayValue field for the drive containing this play.
seasonTypeintegerESPN season type for the game (2 = regular season, 3 = postseason).
weekintegerGame week of the season.
status_type_completedlogical
homeTeamIdintegerESPN's home-team Id for the game, stamped on every play.
awayTeamIdintegerESPN's away-team Id for the game, stamped on every play.
homeFinalScoreintegerFinal score of the home team from the ESPN game header, repeated on every play of the game; the processing step checks the running score at the last play against it.
awayFinalScoreintegerFinal score of the away team from the ESPN game header, repeated on every play of the game; the processing step checks the running score at the last play against it.
homeTeamNamecharacterESPN's home-team Name for the game, stamped on every play.
awayTeamNamecharacterESPN's away-team Name for the game, stamped on every play.
homeTeamMascotcharacterESPN's home-team Mascot for the game, stamped on every play.
awayTeamMascotcharacterESPN's away-team Mascot for the game, stamped on every play.
homeTeamAbbrevcharacterESPN's home-team Abbrev for the game, stamped on every play.
awayTeamAbbrevcharacterESPN's away-team Abbrev for the game, stamped on every play.
homeTeamNameAltcharacterESPN's home-team NameAlt for the game, stamped on every play.
awayTeamNameAltcharacterESPN's away-team NameAlt for the game, stamped on every play.
gameSpreaddoublePoint spread used as an input to the win-probability model.
homeFavoritelogicalTrue when the home team was favoured by the spread.
gameSpreadAvailablelogicalTrue when a spread was available for the game.
overUnderdoubleOver/under total used as a model input.
homeTeamSpreaddoubleESPN's home-team Spread for the game, stamped on every play.
clock.minutesintegerMinutes remaining on the game clock at the play.
clock.secondsintegerSeconds component of the game clock at the play.
lag_halfintegerValue of half on the previous play, used for sequence-aware derivations.
lead_halfintegerValue of half on the next play, used for sequence-aware derivations.
start.TimeSecsRemintegerSeconds remaining in the half from ESPN's clock stamp for this play, which is the end-of-play time in 2005 and 2007+ (the snap time in 2004 and most of 2006); tops out at 1800.
start.adj_TimeSecsRemintegerESPN's adj_TimeSecsRem value for the play state at the start of the play.
lead_textcharacterValue of text on the next play, used for sequence-aware derivations.
lead_start_teamcharacterValue of start_team on the next play, used for sequence-aware derivations.
lead_start_yardsToEndzoneintegerValue of start_yardsToEndzone on the next play, used for sequence-aware derivations.
lead_start_downintegerValue of start_down on the next play, used for sequence-aware derivations.
lead_start_distanceintegerValue of start_distance on the next play, used for sequence-aware derivations.
lead_scoringPlaylogicalValue of scoringPlay on the next play, used for sequence-aware derivations.
text_dupelogicalAlways False in the emitted frame -- the duplicate-row filter it gates runs before the column is returned, so it marks nothing and is retained only for schema stability.
end_state_missinglogicalFlag that ESPN's end-of-play state (end.team.id) was absent and the end state was imputed.
start.pos_team.idintegerESPN's pos_team.id value for the play state at the start of the play.
start.def_pos_team.idintegerESPN's def_pos_team.id value for the play state at the start of the play.
end.def_pos_team.idintegerESPN's def_pos_team.id value for the play state at the end of the play.
end.pos_team.idintegerESPN's pos_team.id value for the play state at the end of the play.
start.pos_team.namecharacterESPN's pos_team.name value for the play state at the start of the play.
start.def_pos_team.namecharacterESPN's def_pos_team.name value for the play state at the start of the play.
end.pos_team.namecharacterESPN's pos_team.name value for the play state at the end of the play.
end.def_pos_team.namecharacterESPN's def_pos_team.name value for the play state at the end of the play.
start.is_homelogicalESPN's is_home value for the play state at the start of the play.
end.is_homelogicalESPN's is_home value for the play state at the end of the play.
homeTimeoutCalledlogicalTrue when the home team called a timeout on the play.
awayTimeoutCalledlogicalTrue when the away team called a timeout on the play.
end.homeTeamTimeoutsintegerESPN's homeTeamTimeouts value for the play state at the end of the play.
end.awayTeamTimeoutsintegerESPN's awayTeamTimeouts value for the play state at the end of the play.
start.homeTeamTimeoutsintegerESPN's homeTeamTimeouts value for the play state at the start of the play.
start.awayTeamTimeoutsintegerESPN's awayTeamTimeouts value for the play state at the start of the play.
end.TimeSecsRemintegerSeconds remaining in the half carried as this play's end state; currently the preceding row's clock stamp.
end.adj_TimeSecsRemintegerESPN's adj_TimeSecsRem value for the play state at the end of the play.
start.posTeamTimeoutsintegerESPN's posTeamTimeouts value for the play state at the start of the play.
start.defPosTeamTimeoutsintegerESPN's defPosTeamTimeouts value for the play state at the start of the play.
end.posTeamTimeoutsintegerESPN's posTeamTimeouts value for the play state at the end of the play.
end.defPosTeamTimeoutsintegerESPN's defPosTeamTimeouts value for the play state at the end of the play.
firstHalfKickoffTeamIdintegerESPN id of the team that received the opening kickoff.
start.yardintegerESPN's yard value for the play state at the start of the play.
end.yardintegerESPN's yard value for the play state at the end of the play.
lag_scoringPlaylogicalValue of scoringPlay on the previous play, used for sequence-aware derivations.
down_1logicalTrue when it is 1st down at the start of the play.
down_2logicalTrue when it is 2nd down at the start of the play.
down_3logicalTrue when it is 3rd down at the start of the play.
down_4logicalTrue when it is 4th down at the start of the play.
down_1_endlogicalTrue when it is 1st down at the end of the play.
down_2_endlogicalTrue when it is 2nd down at the end of the play.
down_3_endlogicalTrue when it is 3rd down at the end of the play.
down_4_endlogicalTrue when it is 4th down at the end of the play.
td_checklogicalInternal flag used while reconciling whether the play produced a touchdown.
forced_fumblelogicalTrue when the defense forced a fumble on the play.
is_homelogical
lag_HA_score_diffintegerValue of HA_score_diff on the previous play, used for sequence-aware derivations.
HA_score_diffintegerHome score minus away score for the play.
net_HA_score_ptsintegerNet points the play added to the home-minus-away score margin.
H_score_diffintegerHome team's score minus the away team's, from the home perspective.
A_score_diffintegerAway team's score minus the home team's, from the away perspective.
lag_homeScoreintegerValue of homeScore on the previous play, used for sequence-aware derivations.
lag_awayScoreintegerValue of awayScore on the previous play, used for sequence-aware derivations.
start.homeScoreintegerESPN's homeScore value for the play state at the start of the play.
start.awayScoreintegerESPN's awayScore value for the play state at the start of the play.
end.homeScoreintegerESPN's homeScore value for the play state at the end of the play.
end.awayScoreintegerESPN's awayScore value for the play state at the end of the play.
start.pos_team_scoreintegerESPN's pos_team_score value for the play state at the start of the play.
start.def_pos_team_scoreintegerESPN's def_pos_team_score value for the play state at the start of the play.
start.pos_score_diffintegerESPN's pos_score_diff value for the play state at the start of the play.
end.pos_team_scoreintegerESPN's pos_team_score value for the play state at the end of the play.
end.def_pos_team_scoreintegerESPN's def_pos_team_score value for the play state at the end of the play.
end.pos_score_diffintegerESPN's pos_score_diff value for the play state at the end of the play.
start.pos_team_receives_2H_kickofflogicalESPN's pos_team_receives_2H_kickoff value for the play state at the start of the play.
end.pos_team_receives_2H_kickofflogicalESPN's pos_team_receives_2H_kickoff value for the play state at the end of the play.
penalty_in_textlogicalTrue when the play description mentions a penalty.
penalty_countintegerNumber of penalties flagged on the play (0-4 observed).
penalty_declined_countintegerNumber of the flagged penalties that were declined.
penalty_all_declinedlogicalWhether every penalty flagged on the play was declined.
penalty_enforcementcharacterHow the penalty was resolved: one of no_play, declined, offsetting, negating_foul, play_stands, unknown.
penalty_negated_playlogicalWhether the penalty negated the play's result.
pass_breakuplogicalTrue when a defender broke up the pass.
pass_depthcharacterThrown-pass depth parsed from ESPN play text ("short" or "deep"); null when the text omits it (sacks, screens, pre-2025 text).
pass_directioncharacterPass direction parsed from ESPN play text ("left", "middle", or "right"); null when the text omits it.
rush_directioncharacterRush direction parsed from ESPN play text ("left", "middle", or "right"); null when the text omits it.
qb_hurrylogicalWhether ESPN's play text says the quarterback was hurried into the throw ("hurried by ...").
fg_attemptlogicalTrue when the play was a field-goal attempt.
pos_unitcharacterPossession-team unit label (offense or special teams).
def_pos_unitcharacterDefensive possession-team unit label (defense or special teams).
splogical
playlogicalBinary flag indicating the row is a counted play (excludes end markers/timeouts/penalties).
cleaned_textcharacterPlay description with overturned-call prefixes stripped; the text the name and team extractors run against.
kneel_downlogicalWhether the play is an offensive kneel, from explicit kneel text plus an end-of-half TEAM-rush heuristic.
scrimmage_playlogicalTrue when the play is a play from scrimmage rather than a special-teams or administrative row.
pos_score_diff_endintegerScore differential from the possessing team's perspective at the end of the play.
fumble_lostlogical
fumble_recoveredlogicalTrue when a fumble on the play was recovered.
field_goal_resultcharacter
extra_point_resultcharacter
two_point_conv_resultcharacterString result of the two-point conversion attempt: success, failure, or safety (touchback in the defensive end zone).
defensive_two_point_attemptlogical
defensive_two_point_convlogical
yds_punted_sourcecharacterProvenance of yds_punted: "text" when the value was present before the special-teams derivation step (parsed from the play text, or set by a flag convention such as a blocked punt's 0), "derived" when that step filled it from field position, null when there is no value.
yds_kickoff_sourcecharacterProvenance of yds_kickoff: "text" when the value was present before the special-teams derivation step (parsed from the play text, or set by a flag convention such as a blocked punt's 0), "derived" when that step filled it from field position, null when there is no value.
yds_punt_return_sourcecharacterProvenance of yds_punt_return: "text" when the value was present before the special-teams derivation step (parsed from the play text, or set by a flag convention such as a blocked punt's 0), "derived" when that step filled it from field position, null when there is no value.
air_yardsToEndzoneintegerYards to the endzone at the catch spot, parsed from the 2025+ vendor catch-spot text; null before 2025 or when unresolvable.
air_yardsinteger
yards_after_catchinteger
kickoff_return_player_namecharacterName of the player returning the kickoff, when the play was returned.
punt_return_player_namecharacterName of the player returning the punt, when the punt was returned.
xp_attemptlogicalWhether an extra-point kick was attempted on the play.
xp_madelogicalWhether the extra-point kick was successful.
xp_kicker_player_namecharacterName of the kicker attempting the extra point.
kicking_teamintegerTeam id of the kicking team on kickoff, punt, and field-goal plays.
return_teamintegerTeam id of the returning side; set on interception, fumble, kickoff, punt, and blocked-kick returns.
fumble_or_mufflogicalWhether the play includes a fumble or a muffed kick or punt (widened beyond ESPN's fumble play types).
recovery_teamintegerTeam id parsed from the play text as recovering the fumble or muff.
recovery_team_2integerTeam id of the second recovery in a multi-recovery scramble, parsed from the play text.
penalty_spot_yardlineintegerYard line (0-50) at which the penalty was spotted.
penalty_spot_sidecharacterSide of the field the penalty was spotted on: 'home', 'away' or 'mid' (midfield).
penalty_spot_yardsToEndzoneintegerYards from the penalty spot to the end zone (0-100).
fumbling_teamintegerTeam id of the side that fumbled or muffed the ball, parsed from the play text.
int_turnoverlogicalWhether the play is an interception giveaway.
pos_fumble_lostlogicalWhether the possession team fumbled and lost the ball.
def_fumble_lostlogicalWhether the defending team (e.g. a returner after a takeaway) fumbled and lost the ball back.
is_pos_team_turnoverlogicalWhether the possession team committed a giveaway (interception or fumble lost).
is_def_pos_team_turnoverlogicalWhether the defending team gave the ball back via a lost fumble.
is_turnoverlogicalTrue when the play is a giveaway-based turnover (interception thrown or fumble lost); blocked kicks recovered by the defense are carried by the blocked-kick fields instead.
turnover_teamintegerTeam id charged with the giveaway on the play.
is_st_turnoverlogicalWhether the giveaway happened on a special-teams play (kick or punt snap, or a return).
is_blocked_punt_turnoverlogicalBlocked-punt possession loss (blocked-punt TD, or the defense recovered); kept out of is_turnover to match ESPN's giveaway-only box.
is_blocked_fg_turnoverlogicalBlocked-field-goal possession loss (blocked-FG TD, or the defense recovered); kept out of is_turnover to match ESPN's giveaway-only box.
sack_teamintegerTeam id credited with the sack (the defense).
interception_teamintegerTeam id credited with the interception (the defense).
pass_breakup_teamintegerTeam id credited with the pass breakup (the defense).
forced_fumble_teamintegerTeam id credited with forcing the fumble -- the side opposite the fumbling player (the covering team on returns).
fumble_recovery_teamintegerTeam id that recovered the fumble or muff, from parsed text with a giveaway / own-recovery fallback.
punt_return_teamintegerTeam id of the punt-returning side.
kick_return_teamintegerTeam id of the kick-returning side.
fg_teamintegerTeam id attempting the field goal (the kicking team).
punt_teamintegerTeam id punting the ball (the kicking team).
penalized_teamintegerTeam id the penalty was assessed against, from the home/away text resolver with a foul-direction fallback.
penalty_yards_signedintegerPenalty yardage parsed from the play text with era-aware bounds; the printed sign is retained but is not a reliable enforcement direction.
penalty_sidecharacterWhich side committed the penalty -- 'off' (offense) or 'def' (defense).
penalty_yards_netintegerNet yardage assessed for the penalty, signed relative to the possession team (observed -25 to 25).
penalty_team_idintegerTeam id of the side that committed the penalty.
new_downintegerDown after the play, including any penalty enforcement.
new_distanceintegerDistance to go after the play, including any penalty enforcement.
under_2logicalWhether the play began with two minutes or less remaining in the half.
goal_to_gological
stopped_runlogicalTrue when the rush was stopped at or behind the line of scrimmage.
opportunity_runlogicalTrue when a rush reached 4 yards -- the carries on which the blocking did its job. Matches cfbfastR's espn_cfb_15 definition. Assets published before the 2026-08 fix carry the inverted (4 yards or fewer) flag.
highlight_runlogicalTrue when the rush gained 8 or more yards.
adj_rush_yardageintegerRushing yards capped at 8, the input to the line-yards decomposition.
line_yardsdoubleYards credited to the offensive line on a rush, using the standard sliding scale: 1.2x the capped yardage on a loss, all of it through 3 yards, half of each yard from 4 to 8, and a 5.5-yard ceiling beyond that.
second_level_yardsdoubleRushing yards earned from 4 to 8, split evenly between line and carrier under the line-yards decomposition.
open_field_yardsintegerRushing yards gained beyond 8, credited to the ball carrier rather than the line.
highlight_yardsdoubleSecond-level plus open-field yards -- the yardage credited to the carrier.
opp_highlight_yardsdoubleHighlight yards earned on opportunity runs, isolating carrier production on carries where the blocking succeeded. Assets published before the 2026-08 fix are identically 0 here, because the inverted opportunity_run gate could never co-occur with non-zero highlight yards.
short_rush_successlogicalTrue when a short-yardage rush gained the yardage needed.
short_rush_attemptlogicalTrue when the play is a rush in a short-yardage situation.
early_downlogicalTrue when the play is a scrimmage play on first or second down.
late_downlogicalTrue when the play is a scrimmage play on third or fourth down.
power_rush_attemptlogicalTrue when the play is a short-yardage power rushing attempt.
power_rush_successlogicalTrue when a power rushing attempt gained the yardage needed.
early_down_passlogicalTrue when the play is a pass on an early down.
early_down_rushlogicalTrue when the play is a rush on an early down.
late_down_passlogicalTrue when the play is a pass on a late down.
late_down_rushlogicalTrue when the play is a rush on a late down.
standard_downlogicalTrue when the offense is on schedule for the series -- first down, second down needing fewer than 8, or third/fourth down needing fewer than 5.
passing_downlogicalTrue when the offense is behind schedule for the series -- second down needing 8 or more, or third/fourth down needing 5 or more.
TFLlogicalTrue when the play was a tackle for loss.
TFL_passlogicalTrue when the play was a tackle for loss on a pass play (a sack).
TFL_rushlogicalTrue when the play was a tackle for loss on a rush play.
havoclogicalTrue when the defense disrupted the play: a pass breakup, tackle for loss, interception or forced fumble.
first_down_yardslogicalWhether the play gained enough yardage to earn a first down.
first_down_penaltylogical
first_down_earnedlogicalWhether the play earned a first down by means other than yardage (e.g. by penalty).
start.pos_team_spreaddoubleESPN's pos_team_spread value for the play state at the start of the play.
start.elapsed_sharedoubleESPN's elapsed_share value for the play state at the start of the play.
start.spread_timedoubleESPN's spread_time value for the play state at the start of the play.
end.pos_team_spreaddoubleESPN's pos_team_spread value for the play state at the end of the play.
end.elapsed_sharedoubleESPN's elapsed_share value for the play state at the end of the play.
end.spread_timedoubleESPN's spread_time value for the play state at the end of the play.
penalty_assessed_on_kickofflogicalWhether a penalty was assessed on a kickoff; such plays take the kickoff/touchback win-probability handling.
start.yardsToEndzone.touchbackintegerESPN's yardsToEndzone.touchback value for the play state at the start of the play.
EP_start_touchbackdoubleExpected points the offense would have had from a touchback on this play.
EP_startdoubleExpected points for the offense at the start of the play.
EP_enddoubleExpected points for the offense at the end of the play.
EP_penalty_cfdoubleCounterfactual expected points for the penalty branch -- the EP had the alternative penalty outcome been taken (null unless a penalty decision existed).
penalty_cf_yardsToEndzoneintegerYards to the end zone in the counterfactual penalty branch.
lag_EP_enddoubleValue of EP_end on the previous play, used for sequence-aware derivations.
EP_betweendoubleChange in expected points across the play, before penalty adjustment.
EPA_scrimmagedoubleEPA credited to the play on plays from scrimmage.
EPA_rushdoubleEPA credited to the play on rush plays.
EPA_passdoubleEPA credited to the play on pass plays.
EPA_explosivelogicalTrue when the play was explosive.
EPA_non_explosivedoubleEPA credited to the play on non-explosive plays.
EPA_explosive_passlogicalTrue when the pass play was explosive.
EPA_explosive_rushlogicalTrue when the rush play was explosive.
first_down_createdlogicalTrue when the play produced a first down for the offense.
EPA_successlogicalTrue when the play was successful by EPA.
EPA_success_early_downlogicalTrue when the play on an early down was successful by EPA.
EPA_success_early_down_passlogicalTrue when the pass play on an early down was successful by EPA.
EPA_success_early_down_rushlogicalTrue when the rush play on an early down was successful by EPA.
EPA_success_late_downlogicalTrue when the play on a late down was successful by EPA.
EPA_success_late_down_passlogicalTrue when the pass play on a late down was successful by EPA.
EPA_success_late_down_rushlogicalTrue when the rush play on a late down was successful by EPA.
EPA_success_standard_downlogicalTrue when the play on a standard down was successful by EPA.
EPA_success_passing_downlogicalTrue when the play on a passing down was successful by EPA.
EPA_success_passlogicalTrue when the pass play was successful by EPA.
EPA_success_rushlogicalTrue when the rush play was successful by EPA.
EPA_success_EPAdoubleEPA on successful plays.
EPA_success_standard_down_EPAdoubleEPA on successful plays on a standard down.
EPA_success_passing_down_EPAdoubleEPA on successful plays on a passing down.
EPA_success_pass_EPAdoubleEPA on successful pass plays.
EPA_success_rush_EPAdoubleEPA on successful rush plays.
EPA_middle_8_successlogicalTrue when the play in the middle eight was successful by EPA.
EPA_middle_8_success_passlogicalTrue when the pass play in the middle eight was successful by EPA.
EPA_middle_8_success_rushlogicalTrue when the rush play in the middle eight was successful by EPA.
EPA_penaltydoubleEPA credited to the play attributable to penalties.
EPA_penalty_directdoubleEPA attributable directly to the penalty on the play, separated from the EPA of the play itself (observed -11.7 to 8.05; null when no penalty applied).
EPA_spdoubleEPA credited to the play on special-teams plays.
EPA_fgdoubleEPA credited to the play on field-goal attempts.
EPA_puntdoubleEPA credited to the play on punt plays.
EPA_kickoffdoubleEPA credited to the play on kickoff plays.
start.ExpScoreDiff_touchbackdoubleESPN's ExpScoreDiff_touchback value for the play state at the start of the play.
start.ExpScoreDiffdoubleESPN's ExpScoreDiff value for the play state at the start of the play.
start.ExpScoreDiff_Time_Ratio_touchbackdoubleESPN's ExpScoreDiff_Time_Ratio_touchback value for the play state at the start of the play.
start.ExpScoreDiff_Time_RatiodoubleESPN's ExpScoreDiff_Time_Ratio value for the play state at the start of the play.
end.ExpScoreDiffdoubleESPN's ExpScoreDiff value for the play state at the end of the play.
end.ExpScoreDiff_Time_RatiodoubleESPN's ExpScoreDiff_Time_Ratio value for the play state at the end of the play.
wp_touchbackdoubleWin probability the offense would have had starting from a touchback.
wp_before_naivedoublePre-snap possession-team win probability from the spread-free (naive) WP model.
wp_touchback_naivedoubleNaive-model win probability for the kickoff-touchback substitute state, used as the pre-snap WP on kickoffs.
wp_after_naivedoubleEnd-of-play possession-team win probability from the naive model, after the game-logic adjustment chain.
def_wp_before_naivedoublePre-snap defense win probability under the naive model (1 - wp_before_naive).
home_wp_before_naivedoublePre-snap naive win probability mapped to the home team.
away_wp_before_naivedoublePre-snap naive win probability mapped to the away team.
lead_wp_before_naivedoubleNext play's pre-snap naive win probability, used in the end-of-half and change-of-possession adjustments.
lead_wp_before2_naivedoublePre-snap naive win probability two plays ahead, used where the immediately following row is a non-play.
def_wp_after_naivedoubleEnd-of-play defense win probability under the naive model.
home_wp_after_naivedoubleEnd-of-play naive win probability mapped to the home team.
away_wp_after_naivedoubleEnd-of-play naive win probability mapped to the away team.
wpa_naivedoubleWin probability added on the play under the spread-free (naive) model.
cpdouble
cp_game_statedoubleCompletion probability from the 8-feature game-state booster, scored on every pass play regardless of which model produced cp. On one scale across seasons, so use it (not cp) for anything summed or averaged; null on non-pass plays.
cp_modelcharacterWhich completion-probability booster scored cp on the play: "air_yards" (the 11-feature model, used where ESPN's play text gives a catch/target spot -- essentially 2025 onward) or "game_state" (the 8-feature model used everywhere else). The two are not on one scale, so group any cpoe aggregate by this column; null on non-pass plays.
cpoedouble
erainteger
xpassdouble
pass_oedouble
drive_startdoubleYard line at which the drive began.
drive_stoppedlogicalTrue when the play ended the drive.
drive_play_indexintegerSequence number of the play within its drive.
drive_offense_playsintegerOffensive plays run on the drive.
prog_drive_EPAdoubleCumulative EPA accrued by the drive up to and including this play.
prog_drive_WPAdoubleCumulative win-probability added by the drive up to and including this play.
drive_offense_yardsintegerOffensive yards gained on the drive.
drive_total_yardsintegerTotal yards gained on the drive.
qbr_epadoubleEPA variant used as an input to the QBR calculation.
weightdoubleListed weight (lbs).
non_fumble_sacklogicalTrue when the play was a sack that did not produce a fumble.
sack_epadoubleEPA credited to the play when it is a sack.
pass_epadoubleEPA credited to the play when it is a pass.
rush_epadoubleEPA credited to the play when it is a rush.
pen_epadoubleEPA attributable to a penalty on the play.
sack_weightdoubleWeighting applied to the sack component of the play.
pass_weightdoubleWeighting applied to the pass component of the play.
rush_weightdoubleWeighting applied to the rush component of the play.
pen_weightdoubleWeighting applied to the penalty component of the play.
action_playlogicalTrue when the play advanced the game state -- excludes timeouts, end-of-period markers and other non-action rows.
athlete_namecharacterPlayer full name.
rusher_player_idinteger
passer_player_idinteger
receiver_player_idinteger
fumble_player_idintegerCFBD athlete_id of the player who fumbled.
sack_player_idintegerComma-separated CFBD athlete_id(s) of the sacking defender(s).
sack_player_id2integerESPN athlete id of the second sacker on a split sack (regex fallback for an ESPN sidecar blind spot).
interception_player_idintegerCFBD athlete_id of the defender credited with an interception.
pass_breakup_player_idintegerCFBD athlete_id of the defender credited with the pass breakup (PBU).
fumble_forced_player_idintegerCFBD athlete_id of the defender credited with forcing the fumble.
fumble_recovered_player_idintegerCFBD athlete_id of the player recovering the fumble.
fg_kicker_player_idintegerESPN athlete id of the field-goal kicker.
punter_player_idinteger
kickoff_player_idintegerESPN athlete id of the player kicking off.
kickoff_return_player_idintegerESPN athlete id of the kickoff returner.
punt_return_player_idintegerESPN athlete id of the punt returner.
fg_block_player_idintegerESPN athlete id of the player who blocked the field goal.
punt_block_player_idcharacterESPN athlete id of the player who blocked the punt.
fg_return_player_idcharacterESPN athlete id of the player who returned the blocked or missed field goal.
punt_block_return_player_idcharacterESPN athlete id of the player who returned the blocked punt.
go_wpdoubleWin probability from going for it on fourth down: conversion-probability-weighted mean of the success and failure states (cfb4th port).
first_down_probdoubleModeled probability of converting the fourth down when going for it.
wp_succeeddoubleMean win probability across yardage outcomes given the fourth-down attempt converts.
wp_faildoubleMean win probability given the fourth-down attempt fails.
make_fg_wpdoubleWin probability given the field-goal attempt is made.
miss_fg_wpdoubleWin probability given the field-goal attempt misses.
fg_wpdoubleMake-probability-weighted win probability of attempting the field goal.
punt_wpdoubleWin probability of punting, from the bundled punt-outcome distribution.
go_boostdoublecfb4th's headline number: 100 * (go_wp - max(fg_wp, punt_wp)), in percentage points.
go_wp_diffdoublego_wp minus the recommended option's WP (0 when going for it is the recommendation, otherwise <= 0).
fg_wp_diffdoublefg_wp minus the recommended option's WP (0 when the field goal is the recommendation, otherwise <= 0).
punt_wp_diffdoublepunt_wp minus the recommended option's WP (0 when punting is the recommendation, otherwise <= 0).
fourth_down_recommendationcharacterMax-WP fourth-down choice among "go", "punt", and "field_goal".
two_pt_wpdoubleWin probability of going for two: conversion-probability-weighted mean of the 2-point and 0-point outcomes (cfb4th port).
xp_wpdoubleWin probability of kicking the extra point, weighting the make by the empirical CFB extra-point make rate.
prob_2ptdoubleTwo-point conversion probability from the bundled CFB two-point model.
two_pt_recommendationcharacterPoint-after recommendation: "go_for_2" when two_pt_wp exceeds xp_wp, otherwise "kick_xp".
two_pt_wp_diffdoubletwo_pt_wp minus xp_wp; positive favors going for two.

Example

from sportsdataverse.cfb.model_calculators import add_era_columns
add_era_columns(pl.DataFrame({"season": [2018]}), "xpass_model")

assert_rating_scale​

assert_rating_scale(ratings: 'pl.DataFrame', *, era: 'str' = 'modern', tol: 'float' = 1.6) -> 'float'

Warn if the ratings have drifted off the scale the constants were fit on.

THE FAILURE THIS PREVENTS. net_points_scale is a frozen statement about a relationship between two things: rating units and points. When the ratings change -- a different ridge penalty, a rescale, a rebuilt corpus -- the constant silently becomes wrong while every function keeps returning plausible numbers. That is exactly what happened: the shipped 44.5367 was fit on 2026-07-28, the ridge lambda moved on 08-01, the corpus was rebuilt on 08-02, and nothing failed. Measured out-of-sample the result was a calibration slope of 0.55 -- predictions stretched nearly 2x wider than reality -- for two days, undetected.

Parameters

ParameterTypeDefaultDescription
ratingsDataFrameTeam ratings frame carrying an adj_net column, as returned by cfb_ratings.efficiency_ratings. Frames without that column, or with fewer than 30 rows, are too thin to judge and return 1.0 unchecked.
erastr'modern'Era key into cfb_prediction_constants.CFB_CONSTANTS, used only to name the era in the warning text.
tolfloat1.6Fold-change tolerance. The check fires outside [1/tol, tol].

Returns

The observed/fitted sd ratio. 1.0 when the frame is too thin to judge, so a caller can treat "1.0" as "no evidence of drift" either way.

Example

from sportsdataverse.cfb import cfb_ratings
from sportsdataverse.cfb.cfb_game_predict import assert_rating_scale
ratings = cfb_ratings.efficiency_ratings(2024)
ratio = assert_rating_scale(ratings)

# Treat a large drift as a refit signal, not a nuisance warning

assert ratio < 1.6, "refit the constants before trusting predictions"

calculate_completion_probability​

calculate_completion_probability(df, *, season=None, return_as_pandas=False)

Completion probability for each pass attempt.

Mirrors the shape of sportsdataverse.nfl's calculators. Rows may come from a play-by-play frame or be typed by hand to ask a hypothetical; only the model card's declared columns are required, and extra columns pass through untouched.

Parameters

ParameterTypeDefaultDescription
dfFrame carrying down, distance, yards_to_goal, score_diff, seconds_remaining, is_home, period, passing_down, plus either a season column or the season argument when the model consumes an era feature.
seasonNoneSeason used to derive era columns when df has none.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with a cp column appended. Input columns are preserved, so chaining two calculators is lossless.

Example

from sportsdataverse.cfb import calculate_completion_probability
calculate_completion_probability(df, season=2024)

calculate_epa​

calculate_epa(df, *, season=None, return_as_pandas=False)

Expected points added: the change in EP across a play.

Recomputes ep when it is absent, matching nflfastR's behaviour. Requires ep_end -- the expected points after the play -- because EPA is a difference and this function scores rows, not sequences.

Parameters

ParameterTypeDefaultDescription
dfFrame with the EP features and an ep_end column.
seasonNoneUnused by the EP model; accepted for signature consistency.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with ep (if it was absent) and epa appended.

Example

from sportsdataverse.cfb import calculate_epa
calculate_epa(pbp)

calculate_expected_points​

calculate_expected_points(df, *, season=None, return_as_pandas=False)

Expected points for each row.

Mirrors sportsdataverse.nfl.calculate_expected_points(). The EP booster is multi:softprob over seven next-score classes; this collapses those probabilities to a points expectation using the package's own ep_class_to_score_mapping rather than restating the class order.

Parameters

ParameterTypeDefaultDescription
dfFrame carrying TimeSecsRem, yards_to_goal, distance, down_1 through down_4 and pos_score_diff_start.
seasonNoneUnused by this model (EP consumes no era feature); accepted so every calculator shares one signature.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with the seven class probability columns and an ep column appended.

Example

from sportsdataverse.cfb import calculate_expected_points
calculate_expected_points(pbp)

calculate_field_goal_probability​

calculate_field_goal_probability(df, *, season=None, return_as_pandas=False)

Field-goal make probability for each row.

Mirrors the shape of sportsdataverse.nfl's calculators. Rows may come from a play-by-play frame or be typed by hand to ask a hypothetical; only the model card's declared columns are required, and extra columns pass through untouched.

Parameters

ParameterTypeDefaultDescription
dfFrame carrying yards_to_goal, plus either a season column or the season argument when the model consumes an era feature.
seasonNoneSeason used to derive era columns when df has none.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with an fg_make_prob column appended. Named fg_make_prob, not fg_prob: calculate_expected_points emits fg_prob for the probability the NEXT SCORE is a field goal, which is a different quantity. Sharing the name made chaining the two silently lossy. Input columns are preserved, so chaining two calculators is lossless.

Example

from sportsdataverse.cfb import calculate_field_goal_probability
calculate_field_goal_probability(df, season=2024)

calculate_fourth_down​

calculate_fourth_down(df, *, season=None, return_as_pandas=False)

Fourth-down conversion model output for each row.

Mirrors the shape of sportsdataverse.nfl's calculators. Rows may come from a play-by-play frame or be typed by hand to ask a hypothetical; only the model card's declared columns are required, and extra columns pass through untouched.

Parameters

ParameterTypeDefaultDescription
dfFrame carrying down, distance, yards_to_goal, posteam_total, posteam_spread, plus either a season column or the season argument when the model consumes an era feature.
seasonNoneSeason used to derive era columns when df has none.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with fd_conversion_prob (probability the gain reaches distance) and fd_expected_yards appended. Input columns are preserved, so chaining two calculators is lossless.

Example

from sportsdataverse.cfb import calculate_fourth_down
calculate_fourth_down(df, season=2024)

calculate_qbr​

calculate_qbr(df, *, season=None, return_as_pandas=False)

Model QBR for each row.

Mirrors the shape of sportsdataverse.nfl's calculators. Rows may come from a play-by-play frame or be typed by hand to ask a hypothetical; only the model card's declared columns are required, and extra columns pass through untouched.

Parameters

ParameterTypeDefaultDescription
dfFrame carrying qbr_epa, sack_epa, pass_epa, rush_epa, pen_epa, plus either a season column or the season argument when the model consumes an era feature.
seasonNoneSeason used to derive era columns when df has none.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with a qbr column appended. Input columns are preserved, so chaining two calculators is lossless.

Example

from sportsdataverse.cfb import calculate_qbr
calculate_qbr(df, season=2024)

calculate_two_point_probability​

calculate_two_point_probability(df, *, season=None, return_as_pandas=False)

Two-point conversion success probability.

Mirrors the shape of sportsdataverse.nfl's calculators. Rows may come from a play-by-play frame or be typed by hand to ask a hypothetical; only the model card's declared columns are required, and extra columns pass through untouched.

Parameters

ParameterTypeDefaultDescription
dfFrame carrying posteam_spread, posteam_total, pos_score_diff, plus either a season column or the season argument when the model consumes an era feature.
seasonNoneSeason used to derive era columns when df has none.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with a two_pt_prob column appended. Input columns are preserved, so chaining two calculators is lossless.

Example

from sportsdataverse.cfb import calculate_two_point_probability
calculate_two_point_probability(df, season=2024)

calculate_win_probability​

calculate_win_probability(df, *, season=None, return_as_pandas=False)

Win probability for each row.

Selects the booster the way the pipeline does: wp_spread when the frame carries a spread_time column, wp_naive otherwise. The naive model is the spread model minus that single feature, so which one applies is decided by whether the caller has spread information at all.

Parameters

ParameterTypeDefaultDescription
dfFrame carrying the win-probability features. Include spread_time to use the spread model.
seasonNoneUnused by these models; accepted for signature consistency.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with a wp column appended.

Example

from sportsdataverse.cfb import calculate_win_probability
calculate_win_probability(pbp)

calculate_wpa​

calculate_wpa(df, *, season=None, return_as_pandas=False)

Win probability added: the change in WP across a play.

Recomputes wp when it is absent. Requires wp_end for the same reason calculate_epa requires ep_end.

Parameters

ParameterTypeDefaultDescription
dfFrame with the WP features and a wp_end column.
seasonNoneUnused by these models; accepted for signature consistency.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with wp (if it was absent) and wpa appended.

Example

from sportsdataverse.cfb import calculate_wpa
calculate_wpa(pbp)

calculate_xpass​

calculate_xpass(df, *, season=None, return_as_pandas=False)

Expected pass probability for each row.

Mirrors the shape of sportsdataverse.nfl's calculators. Rows may come from a play-by-play frame or be typed by hand to ask a hypothetical; only the model card's declared columns are required, and extra columns pass through untouched.

Parameters

ParameterTypeDefaultDescription
dfFrame carrying down, distance, yards_to_goal, pos_score_diff, TimeSecsRem, period, plus either a season column or the season argument when the model consumes an era feature.
seasonNoneSeason used to derive era columns when df has none.
return_as_pandasFalseReturn a pandas DataFrame instead of polars.

Returns

df with an xpass column (probability the play is a pass) appended. Input columns are preserved, so chaining two calculators is lossless.

Example

from sportsdataverse.cfb import calculate_xpass
calculate_xpass(df, season=2024)

cfb_adjusted_epa​

cfb_adjusted_epa(plays: 'pl.DataFrame | pd.DataFrame', *, ridge_lambda: 'float | None' = None, method: "Literal['current', 'pre598']" = 'current', return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Season opponent-adjusted per-team EPA from a season's play-by-play.

Fits one ridge of per-play EPA on offense-team, defense-team, and home-field indicators (every team shrunk toward the league average by its own play count) over the 0.05 <= wp_before_naive <= 0.95 pass and rush plays, nets each team's per-game raw EPA against the opponent's fitted strength, and averages to a season figure. In-sample/descriptive (the fit uses the whole season); for leak-free per-game values use cfb_adjusted_epa_by_game.

Parameters

ParameterTypeDefaultDescription
playsDataFrame | DataFrameA cfbfastR-schema play-by-play frame (polars or pandas) with the columns listed in the module docstring. One season at a time.
ridge_lambdafloat | NoneNoneRidge penalty. Under method="current" it is per play of a full team season: each team keeps n / (n + ridge_lambda * 577) of its own signal for its n fit plays and is shrunk toward the league average by the rest (~7% at a full season, most of it on a handful of plays); must be > 0. Under method="pre598" it is passed unscaled to the old standardized ridge (the per-observation penalty; no 577 scaling, no positivity check). None (default) means 0.075 for "current" (the owner's choice, ADJ_EPA_LAMBDA) and 0.035 for "pre598"`.
methodLiteral['current', 'pre598']'current'"current" (default) or "pre598", the fit this function used before #598 (0.1 <= wp_before <= 0.9 band, standardized ridge with the first team id as the reference level, lambda 0.035). pre598 reads wp_before instead of wp_before_naive. It exists for nfl-data's NFL team summaries, is not validated for NFL either, and is kept only for continuity until NFL is validated.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

One row per team (>= 2 valid games): team_id, pos_team, valid_games, adj_off_epa, adj_def_epa, off_strength_faced, def_strength_faced, net_adj_epa and their *_rank columns.

No returns table is published for this function: no capture: it needs play-by-play joined with schedule fields (home, neutral_site, pos_team_id) that neither load_cfb_pbp nor load_cfb_pbp_r carries; only cfb_ratings builds that join, internally.

Example

import sportsdataverse.cfb as cfb
pbp = cfb.load_cfb_pbp(seasons=[2023])
cfb.cfb_adjusted_epa(pbp).sort("net_adj_epa_rank").head()

# NFL team summaries (the pre-#598 method; reads wp_before)

cfb.cfb_adjusted_epa(nfl_plays, method="pre598")

cfb_adjusted_epa_by_game​

cfb_adjusted_epa_by_game(plays: 'pl.DataFrame | pd.DataFrame', *, ridge_lambda: 'float | None' = None, method: "Literal['current', 'pre598']" = 'current', return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Walk-forward (point-in-time) opponent-adjusted EPA, one row per team-game.

For each week w the opponent-strength ridge is fit on FIT_WP-band plays from **weeks before w` only**, then that week's games are adjusted with those as-of strengths -- so the value uses no future information and is valid as an in-season power-rating / model feature. Week 1 (no prior) yields null adjustments; not-yet-seen opponents fall back to the league baseline (an average team), and teams seen on few plays are shrunk most of the way there.

Parameters

ParameterTypeDefaultDescription
playsDataFrame | DataFrameA cfbfastR-schema play-by-play frame (polars or pandas) with the module-docstring columns plus week. One season at a time.
ridge_lambdafloat | NoneNoneRidge penalty. Under method="current" it is per play of a full team season: each team keeps n / (n + ridge_lambda * 577) of its own signal for its n fit plays and is shrunk toward the league average by the rest (~7% at a full season, most of it on a handful of plays); must be > 0. Under method="pre598" it is passed unscaled to the old standardized ridge (the per-observation penalty; no 577 scaling, no positivity check). None (default) means 0.075 for "current" (the owner's choice, ADJ_EPA_LAMBDA) and 0.035 for "pre598"`.
methodLiteral['current', 'pre598']'current'"current" (default) or "pre598", the fit this function used before #598 (see cfb_adjusted_epa). pre598 also keeps the old week order: it sorts by week alone and does not read seasonType, so postseason games that restart at week 1 are fit with (and leak into) the regular season, exactly as before. It exists for nfl-data's NFL team summaries, is not validated for NFL either, and is kept only for continuity until NFL is validated.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

One row per (game, team), sorted by week then team_id: game_id, week, team_id, opponent_id, pos_team, raw_off_epa, adj_off_epa, raw_def_epa, adj_def_epa, off_strength_faced (opponent offense), def_strength_faced (opponent defense), net_adj_epa. The adj_* / net columns are null for week 1 (and any week with no prior fit).

No returns table is published for this function: no capture: it needs play-by-play joined with schedule fields (home, neutral_site, pos_team_id) that neither load_cfb_pbp nor load_cfb_pbp_r carries; only cfb_ratings builds that join, internally.

Example

import sportsdataverse.cfb as cfb
pbp = cfb.load_cfb_pbp(seasons=[2023])
tg = cfb.cfb_adjusted_epa_by_game(pbp)
tg.filter(pl.col("week") >= 5).sort("net_adj_epa", descending=True).head()