Skip to main content
Version: 0.1.5

CFB — additional Python functions — sportsdataverse-data releases

load_cfb_betting_lines​

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

Load college football betting lines information

Parameters

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

Returns

Polars dataframe containing betting lines available for the available seasons.

col_nametypedescription
iddouble247Sports referencing id for the recruit.
game_idintegerESPN game identifier.
seasondoubleSeason (4-digit year).
game_desccharacterHuman-readable description of the game, typically including team names and context.
date_timecharacterDate and time of the game to which the betting line applies, as a string.
market_typecharacterGeographic market type (e.g. National).
abbrcharacterSelection/side this odds row applies to — a team abbreviation for spread and moneyline markets, or 'over'/'under' for total markets (the data is long-format, one row per book per selection per market_type).
linesdoubleNumeric line for this row's market — the per-side point spread for spread markets or the over/under total points for total markets; null for moneyline rows.
oddsintegerAmerican-odds price for this selection — the juice/vig on spread and total rows, or the moneyline price itself on moneyline rows.
opening_linesdoubleOpening numeric line for this row's market (per-side spread or over/under total points) before line movement; null for moneyline rows.
opening_oddsintegerOpening American-odds price for this selection before line movement (vig on spread/total rows, moneyline price on moneyline rows).
bookcharacterName of the sportsbook or oddsmaker that provided the betting line.
season_typecharacterESPN season type (2 = regular, 3 = postseason).
weekintegerGame week of the season.
home_team_idintegerESPN home team id (parsed from home_team_ref).
away_team_idintegerESPN away team id (parsed from away_team_ref).

Example

from sportsdataverse.cfb import load_cfb_betting_lines
lines = load_cfb_betting_lines()
print(lines.shape)

# Pandas round-trip

lines_pd = load_cfb_betting_lines(return_as_pandas=True)
lines_pd.head()

# Pipeline next step (filter to one provider in 2023)

import polars as pl
consensus_2023 = load_cfb_betting_lines().filter(
(pl.col("season") == 2023) & (pl.col("provider") == "consensus")
)

load_cfb_rosters_crosswalk​

load_cfb_rosters_crosswalk(return_as_pandas: 'bool' = False) -> 'pl.DataFrame'

Load the current ESPN x Fox CFB rosters crosswalk (single snapshot).

Unlike the per-season load_cfb_teams_crosswalk / load_cfb_schedule_crosswalk loaders, this one is season-less: ESPN's and Fox's team-roster endpoints only expose the current roster, so the published artifact is a single snapshot rather than a historical per-season series. It is built by cfbfastR-cfb-data's scripts/build_cfb_crosswalk.py (which fans the per-team sportsdataverse.cfb.cfb_rosters_crosswalk builder out over the current season's ESPN<->Fox team-id pairs) and refreshed on that repo's cadence.

Parameters

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

Returns

one row per matched player, carrying espn_team_id / fox_team_id provenance plus each provider's athlete id, name, jersey, position, and the match_method / matched_sources flags.

col_nametypedescription
espn_team_idinteger
fox_team_idcharacter
person_keycharacterNormalized player-name join key: 'Last, First' flipped, lowercased, ASCII-folded, punctuation stripped and runs of initials merged, so 'C.J.' and 'CJ' both give 'cj' (e.g. 'josh brown').
espn_athlete_idinteger
fox_athlete_idcharacter
yahoo_athlete_idcharacterPresent but unpopulated in the published data (all null): the asset is built with providers=('espn', 'fox'), so no Yahoo ids are joined.
namecharacterPosition name (e.g. Quarterback).
espn_jerseycharacter
fox_jerseycharacter
espn_positioncharacter
fox_positioncharacterPosition abbreviation from the Fox Sports roster (e.g. 'QB', 'OL', 'DB'); null when the player has no Fox roster match or Fox lists no position.
yahoo_positioncharacterPresent but unpopulated in the published data (all null): the asset is built with providers=('espn', 'fox'), so no Yahoo positions are joined.
match_methodcharacterCombination of matched sources, e.g. "fox+bart" / "fox_only" / "bart_only" / "espn_only".
matched_sourcescharacterPlus-joined provenance tag naming which rosters listed the player: 'espn+fox', 'espn' or 'fox'. The published asset is built without Yahoo, so 'yahoo' never appears.

Example

from sportsdataverse.cfb import load_cfb_rosters_crosswalk
xwalk = load_cfb_rosters_crosswalk()
print(xwalk.shape)

# Pandas round-trip

xwalk_pd = load_cfb_rosters_crosswalk(return_as_pandas=True)

# Pipeline next step (one team's ESPN<->Fox athlete map)

import polars as pl
osu = load_cfb_rosters_crosswalk().filter(pl.col("espn_team_id") == 194)