Skip to main content
Version: 0.1.5

CFB — additional Python functions — ESPN

espn_cfb_game_rosters​

espn_cfb_game_rosters(game_id: 'int', raw=False, return_as_pandas=False, **kwargs) -> 'pl.DataFrame'

espn_cfb_game_rosters() - Pull the game by id.

Parameters

ParameterTypeDefaultDescription
game_idintUnique game_id, can be obtained from espn_cfb_schedule().
rawFalse
return_as_pandasboolFalseIf True, returns a pandas dataframe. If False, returns a polars dataframe.

Returns

Polars dataframe of game roster data with columns: 'athlete_id', 'athlete_uid', 'athlete_guid', 'athlete_type', 'first_name', 'last_name', 'full_name', 'athlete_display_name', 'short_name', 'weight', 'display_weight', 'height', 'display_height', 'age', 'date_of_birth', 'slug', 'jersey', 'linked', 'active', 'alternate_ids_sdr', 'birth_place_city', 'birth_place_state', 'birth_place_country', 'headshot_href', 'headshot_alt', 'experience_years', 'experience_display_value', 'experience_abbreviation', 'status_id', 'status_name', 'status_type', 'status_abbreviation', 'hand_type', 'hand_abbreviation', 'hand_display_value', 'draft_display_text', 'draft_round', 'draft_year', 'draft_selection', 'player_id', 'starter', 'valid', 'did_not_play', 'display_name', 'ejected', 'athlete_href', 'position_href', 'statistics_href', 'team_id', 'team_guid', 'team_uid', 'team_slug', 'team_location', 'team_name', 'team_nickname', 'team_abbreviation', 'team_display_name', 'team_short_display_name', 'team_color', 'team_alternate_color', 'is_active', 'is_all_star', 'team_alternate_ids_sdr', 'logo_href', 'logo_dark_href', 'game_id'

col_nametypedescription
athlete_idintegerESPN athlete id.
athlete_uidcharacter
athlete_guidcharacter
athlete_typecharacter
first_namecharacterAthlete first name.
last_namecharacterAthlete last name.
full_namecharacterVenue full name (e.g. Tenney Stadium).
athlete_display_namecharacterPlayer display name.
short_namecharacterRanking source short name (e.g. AP Poll).
weightdoubleListed weight (lbs).
display_weightcharacterHuman-readable weight (e.g. 205 lbs).
heightdoubleListed height (inches).
display_heightcharacterHuman-readable height (e.g. 6' 1").
slugcharacterURL slug for the team.
jerseycharacterJersey number.
linkedlogical
activelogicalTRUE if the player was active for the game.
alternate_ids_sdrcharacter
birth_place_citycharacter
birth_place_statecharacter
birth_place_countrycharacter
birth_country_alternate_idcharacter
birth_country_abbreviationcharacter
headshot_hrefcharacterURL of the athlete headshot image.
headshot_altcharacter
flag_hrefcharacter
flag_altcharacter
flag_relcharacter
experience_yearsintegerYears of experience.
experience_display_valuecharacter
experience_abbreviationcharacter
status_idcharacterESPN commitment status id.
status_namecharacterStatus-type key (e.g. STATUS_FINAL).
status_typecharacterStatus type.
status_abbreviationcharacter
hand_typecharacter
hand_abbreviationcharacter
hand_display_valuecharacter
ageinteger
date_of_birthcharacterPlayer date of birth (if published).
starterlogicalTRUE if the athlete started the game.
jersey_rightcharacter
validlogicalTRUE if the roster entry is flagged valid by ESPN.
did_not_playlogicalTRUE if the athlete did not play.
display_namecharacterHuman-readable metric name.
athlete_hrefcharacter
position_hrefcharacter
statistics_hrefcharacter
team_idintegerESPN team id.
orderintegerTeam order within the competition (0 = first).
home_awaycharacterhome or away.
winnerlogicalTRUE if this team won the game.
team_guidcharacter
team_uidcharacter
team_slugcharacterTeam slug for the stat row.
team_locationcharacterTeam location / school name.
team_namecharacterTeam nickname.
team_nicknamecharacterTeam nickname label.
team_abbreviationcharacterTeam abbreviation.
team_display_namecharacterFull team display name.
team_short_display_namecharacterShort team display name.
team_colorcharacterPrimary team color.
team_alternate_colorcharacterAlternate team color.
is_activelogicalWhether the team is currently active.
is_all_starlogicalWhether the team is an all-star team.
team_alternate_ids_sdrcharacter
logo_hrefcharacterURL of the default team logo.
logo_dark_hrefcharacterURL of the dark-variant team logo.
game_idintegerESPN game identifier.

Example

from sportsdataverse.cfb import espn_cfb_game_rosters
rosters = espn_cfb_game_rosters(game_id=401628334)
print(rosters.shape)

# Pandas round-trip

rosters_pd = espn_cfb_game_rosters(game_id=401628334, return_as_pandas=True)
rosters_pd.head()

# Pipeline next step (filter to game starters)

import polars as pl
starters = espn_cfb_game_rosters(game_id=401628334).filter(
pl.col("starter") == True
)

espn_cfb_play_participants​

espn_cfb_play_participants(game_id: 'int', *, raw: 'bool' = False, return_as_pandas: 'bool' = False, resolve_missing: 'bool' = True, resolve_missing_max: 'int' = 50, **kwargs: 'Any') -> 'pl.DataFrame | pd.DataFrame | dict[str, Any]'

Pull ESPN per-play participants for a college-football game.

The college-football entry point of the shared sportsdataverse.football.play_participants.espn_play_participants; see it for the column contract ({type}_player_name / {type}_player_id scalars plus the {type}_player_names / {type}_player_ids lists per participant type ESPN ships).

Parameters

ParameterTypeDefaultDescription
game_idintESPN game / event identifier.
rawboolFalseIf True, returns the raw list of play-items dicts.
return_as_pandasboolFalseIf True, returns a pandas DataFrame; otherwise polars.
resolve_missingboolTrueFetch athletes the sidecar omits from their $ref.
resolve_missing_maxint50Cap on those per-athlete requests (default 50).

Returns

Polars (or pandas) DataFrame, one row per play; the raw play dicts when raw=True.

col_nametypedescription
game_idintegerESPN game identifier.
play_idintegerESPN play id.
kicker_player_namecharacter
passer_player_namecharacterName of the passer on a passing play.
receiver_player_namecharacterName of the receiver on a passing play.
rusher_player_namecharacterName of the rusher on a rushing play.
scorer_player_namecharacter
returner_player_namecharacter
pass_defender_player_namecharacter
penalized_player_namecharacter
sacked_by_player_namecharacter
pat_scorer_player_namecharacter
punter_player_namecharacterName of the punter.
kicker_player_idcharacter
passer_player_idcharacter
receiver_player_idcharacter
rusher_player_idcharacter
scorer_player_idcharacter
returner_player_idcharacter
pass_defender_player_idcharacter
penalized_player_idcharacter
sacked_by_player_idcharacter
pat_scorer_player_idcharacter
punter_player_idcharacter
kicker_position_idcharacter
passer_position_idcharacter
receiver_position_idcharacter
rusher_position_idcharacter
scorer_position_idcharacter
returner_position_idcharacter
pass_defender_position_idcharacter
penalized_position_idcharacter
sacked_by_position_idcharacter
pat_scorer_position_idcharacter
punter_position_idcharacter
kicker_player_namescharacter
passer_player_namescharacter
receiver_player_namescharacter
rusher_player_namescharacter
scorer_player_namescharacter
returner_player_namescharacter
pass_defender_player_namescharacter
penalized_player_namescharacter
sacked_by_player_namescharacter
pat_scorer_player_namescharacter
punter_player_namescharacter
kicker_player_idscharacter
passer_player_idscharacter
receiver_player_idscharacter
rusher_player_idscharacter
scorer_player_idscharacter
returner_player_idscharacter
pass_defender_player_idscharacter
penalized_player_idscharacter
sacked_by_player_idscharacter
pat_scorer_player_idscharacter
punter_player_idscharacter

Example

from sportsdataverse.cfb import espn_cfb_play_participants
participants = espn_cfb_play_participants(game_id=401628334)
print(participants.shape)

espn_cfb_teams​

espn_cfb_teams(groups=None, return_as_pandas=False, **kwargs) -> 'pl.DataFrame'

espn_cfb_teams - look up the college football teams

Parameters

ParameterTypeDefaultDescription
groupsintNoneUsed to define different divisions. 80 is FBS, 81 is FCS.
return_as_pandasboolFalseIf True, returns a pandas dataframe. If False, returns a polars dataframe.

Returns

Polars dataframe containing schedule dates for the requested season. This function caches by default, so if you want to refresh the data, use the command sportsdataverse.cfb.espn_cfb_teams.clear_cache().

col_nametypedescription
team_abbreviationcharacterTeam abbreviation.
team_alternate_colorcharacterAlternate team color.
team_colorcharacterPrimary team color.
team_display_namecharacterFull team display name.
team_idcharacterESPN team id.
team_is_activelogical
team_is_all_starlogical
team_locationcharacterTeam location / school name.
team_logosinteger
team_namecharacterTeam nickname.
team_nicknamecharacterTeam nickname label.
team_short_display_namecharacterShort team display name.
team_slugcharacterTeam slug for the stat row.
team_uidcharacter

Example

from sportsdataverse.cfb import espn_cfb_teams
teams = espn_cfb_teams()
print(teams.shape)

# Pull FCS teams (group 81)

fcs = espn_cfb_teams(groups=81, return_as_pandas=True)
fcs.head()

# Pipeline next step (build an abbreviation lookup)

teams = espn_cfb_teams()
abbr_map = dict(zip(teams["team_id"], teams["team_abbreviation"]))

scoreboard_event_parsing​

scoreboard_event_parsing(event)

Internal helper that flattens an ESPN scoreboard event dict into a shape

suitable for pd.json_normalize.

Parameters

ParameterTypeDefaultDescription
eventdictA single scoreboard events[*] entry from the ESPN college-football scoreboard API.

Returns

The same event dict, mutated in place with home/away copies of the competitors and trimmed of unused link/odds keys.

Example

from sportsdataverse.cfb import espn_cfb_schedule
sched = espn_cfb_schedule(dates=2023, week=5)