Skip to main content

College football — 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
idFloat64247Sports referencing id for the recruit.
game_idInt64ESPN game identifier.
seasonFloat64Season (4-digit year).
game_descStringHuman-readable description of the game, typically including team names and context.
date_timeStringDate and time of the game to which the betting line applies, as a string.
market_typeStringGeographic market type (e.g. National).
abbrStringSelection/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).
linesFloat64Numeric 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.
oddsInt64American-odds price for this selection — the juice/vig on spread and total rows, or the moneyline price itself on moneyline rows.
opening_linesFloat64Opening numeric line for this row's market (per-side spread or over/under total points) before line movement; null for moneyline rows.
opening_oddsInt64Opening American-odds price for this selection before line movement (vig on spread/total rows, moneyline price on moneyline rows).
bookStringName of the sportsbook or oddsmaker that provided the betting line.
season_typeStringESPN season type (2 = regular, 3 = postseason).
weekInt64Game week of the season.
home_team_idInt64ESPN home team id (parsed from home_team_ref).
away_team_idInt64ESPN 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_idInt64
fox_team_idString
person_keyStringNormalized 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_idInt64
fox_athlete_idString
yahoo_athlete_idStringPresent but unpopulated in the published data (all null): the asset is built with providers=('espn', 'fox'), so no Yahoo ids are joined.
nameStringPosition name (e.g. Quarterback).
espn_jerseyString
fox_jerseyString
espn_positionString
fox_positionStringPosition 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_positionStringPresent but unpopulated in the published data (all null): the asset is built with providers=('espn', 'fox'), so no Yahoo positions are joined.
match_methodStringCombination of matched sources, e.g. "fox+bart" / "fox_only" / "bart_only" / "espn_only".
matched_sourcesStringPlus-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)