Skip to main content
Version: 0.1.5

NBA — additional Python functions — Basketball-Reference

bref_awards​

bref_awards(season: 'Optional[int]' = None, *, return_as_pandas: 'bool' = False, proxy: 'Any' = None, **kwargs: 'Any') -> 'pl.DataFrame | pd.DataFrame'

End-of-season award voting, all awards stacked into one frame.

Port of hoopR's bref_awards(). NBA only -- wehoop wraps no WNBA awards page, so none is guessed at here.

Parameters

ParameterTypeDefaultDescription
seasonOptional[int]NoneSeason in 4-digit ending-year format. Defaults to the current NBA season.
return_as_pandasboolFalseReturn a pandas.DataFrame instead of polars.
proxyAnyNoneProxy configuration in the requests proxies= shape.

Returns

One row per candidate per award: award (mvp, roy, dpoy, smoy, mip, clutch_poy, coy), rank, player, age, team, votes_first, points_won, points_max, award_share, plus season. Zero rows when the page carries no voting table (award voting predates 1956 for none of them).

col_nametypedescription
rankcharacterRank.
playercharacterPlayer name.
agedoublePlayer age (in years).
teamcharacterTeam-side label or team identifier.
votes_firstdoubleFirst-place votes.
points_wondoubleVoting points won.
points_maxdoubleMaximum possible voting points.
award_sharedoubleShare of the maximum voting points.
awardcharacterAward slug (mvp, roy, dpoy, smoy, mip, clutch_poy, coy).
seasonintegerSeason year.

Example

from sportsdataverse.nba.bref import bref_awards

df = bref_awards(season=2024)
print(df.shape)

# Pandas output

df_pd = bref_awards(season=2024, return_as_pandas=True)

# Pipeline next step (one line)

df.filter(pl.col("award") == "mvp").sort("award_share", descending=True).head()

bref_draft​

bref_draft(season: 'Optional[int]' = None, *, return_as_pandas: 'bool' = False, proxy: 'Any' = None, **kwargs: 'Any') -> 'pl.DataFrame | pd.DataFrame'

NBA draft results with each pick's career totals and advanced metrics.

Port of hoopR's bref_draft(). NBA only.

Parameters

ParameterTypeDefaultDescription
seasonOptional[int]NoneDraft year (e.g. 2024). Defaults to the current NBA season.
return_as_pandasboolFalseReturn a pandas.DataFrame instead of polars.
proxyAnyNoneProxy configuration in the requests proxies= shape.

Returns

One row per pick: pick_overall, round, team, player, college_name, seasons, g, mp, pts, trb, ast, fg_pct …, ws, ws_per_48, bpm, vorp, plus season. Zero rows when the draft page is absent.

col_nametypedescription
rankerdoubleRow rank.
pick_overalldoubleOverall draft pick number.
teamcharacterTeam-side label or team identifier.
playercharacterPlayer name.
college_namecharacterCollege / pre-draft team.
seasonscharacterNBA seasons played.
gcharacterGames played.
mpcharacterMinutes played.
ptscharacterPoints scored.
trbcharacterCareer total rebounds.
astcharacterAssists.
fg_pctcharacterField goal percentage (0-1).
fg3_pctcharacterThree-point field goal percentage (0-1).
ft_pctcharacterFree throw percentage (0-1).
mp_per_gcharacterMinutes (per_game table) / mp total (totals table).
pts_per_gcharacterPoints (scaled to the chosen table).
trb_per_gcharacterCareer total rebounds per game for the drafted player, from Basketball-Reference's draft table. Every value is an empty string in the sampled 2026 draft, whose picks had no NBA stats yet, so the column stays text there.
ast_per_gcharacterCareer assists per game for the drafted player, from Basketball-Reference's draft table. Every value is an empty string in the sampled 2026 draft, whose picks had no NBA stats yet, so the column stays text there.
wscharacterCareer win shares.
ws_per_48characterCareer win shares per 48 minutes for the drafted player, from Basketball-Reference's draft table. Every value is an empty string in the sampled 2026 draft, whose picks had no NBA stats yet, so the column stays text there.
bpmcharacterCareer box plus/minus.
vorpcharacterCareer value over replacement player.
seasonintegerSeason year.

Example

from sportsdataverse.nba.bref import bref_draft

df = bref_draft(season=2024)
print(df.shape)

# Pandas output

df_pd = bref_draft(season=2003, return_as_pandas=True)

# Pipeline next step (one line)

df.sort("vorp", descending=True).head()

bref_injuries​

bref_injuries(*, return_as_pandas: 'bool' = False, proxy: 'Any' = None, **kwargs: 'Any') -> 'pl.DataFrame | pd.DataFrame'

The current NBA injury report.

Port of hoopR's bref_injuries(). This is the live report -- there is no season argument and no history. hoopR uses it in place of RotoWorld, which NBC retired.

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseReturn a pandas.DataFrame instead of polars.
proxyAnyNoneProxy configuration in the requests proxies= shape.

Returns

One row per injured player: player, team_name, date_update and note (status plus description). Zero rows when no one is listed or the page is unreachable.

col_nametypedescription
playercharacterPlayer name.
team_namecharacterFull team display name (e.g. 'Las Vegas Aces').
date_updatecharacterDate the status was last updated.
notecharacterInjury status and description.

Example

from sportsdataverse.nba.bref import bref_injuries

df = bref_injuries()
print(df.shape)

# Pandas output

df_pd = bref_injuries(return_as_pandas=True)

# Pipeline next step (one line)

df.filter(pl.col("note").str.contains("(?i)out")).head()

bref_player_bios​

bref_player_bios(letter: 'str' = 'a', *, return_as_pandas: 'bool' = False, proxy: 'Any' = None, **kwargs: 'Any') -> 'pl.DataFrame | pd.DataFrame'

The player index for one last-name initial -- bios plus the id slugs.

Port of hoopR's bref_player_bios(). NBA only. This doubles as the Basketball-Reference player dictionary: player_id is the slug that bref_player_game_log takes.

Parameters

ParameterTypeDefaultDescription
letterstr'a'Single letter a-z (last-name initial). Only the first character is used, case-insensitively.
return_as_pandasboolFalseReturn a pandas.DataFrame instead of polars.
proxyAnyNoneProxy configuration in the requests proxies= shape.

Returns

One row per player: player, player_id (e.g. jamesle01), year_min, year_max, pos, height, weight, birth_date, colleges, plus the echoed letter. player_id is omitted when the number of player links on the page does not match the number of rows (the same guard the R wrapper applies).

col_nametypedescription
playercharacterPlayer name.
player_idcharacterUnique player identifier.
year_mindoubleFirst season played.
year_maxdoubleLast season played.
poscharacterPosition.
heightcharacterPlayer height (string e.g. '6-2' or inches).
weightdoublePlayer weight in pounds.
birth_datecharacterDate of birth (YYYY-MM-DD).
collegescharacterCollege(s).
lettercharacterLast-name initial (echoes the letter argument).

Example

from sportsdataverse.nba.bref import bref_player_bios

df = bref_player_bios(letter="j")
print(df.shape)

# Build the id dictionary for the whole alphabet

import string
ids = [bref_player_bios(ch) for ch in string.ascii_lowercase]

# Pipeline next step (one line)

df.filter(pl.col("year_max") >= 2024).select(["player", "player_id"]).head()

bref_player_game_log​

bref_player_game_log(player_id: 'str', season: 'Optional[int]' = None, *, return_as_pandas: 'bool' = False, proxy: 'Any' = None, **kwargs: 'Any') -> 'pl.DataFrame | pd.DataFrame'

A player's regular-season game-by-game log.

Port of hoopR's bref_player_game_log(). NBA only. The playoff log on the same page (player_game_log_post) is not wrapped, matching the R surface.

Parameters

ParameterTypeDefaultDescription
player_idstrBasketball-Reference player id slug -- the id in the player's URL, e.g. jokicni01 from /players/j/jokicni01.html. Use bref_player_bios as the id dictionary.
seasonOptional[int]NoneSeason in 4-digit ending-year format. Defaults to the current NBA season.
return_as_pandasboolFalseReturn a pandas.DataFrame instead of polars.
proxyAnyNoneProxy configuration in the requests proxies= shape.

Returns

One row per regular-season game: ranker, player_game_num_career, date, team, location (@ for away), opp, result, is_starter, mp, the full shooting / box columns, game_score, plus_minus, plus echoed player_id / season. Month-separator and no-date rows are dropped. Zero rows when the player did not play that season.

col_nametypedescription
rankerdoubleRow rank.
player_game_num_careerdoubleCareer game number.
team_game_num_seasondouble
datecharacterDate in YYYY-MM-DD format.
teamcharacterTeam-side label or team identifier.
locationcharacterLocation.
oppcharacterOpponent abbreviation.
resultcharacterResult.
is_startercharacter1 if the player started.
mpcharacterMinutes played.
fgdouble
fgadoubleField goal attempts.
fg_pctdoubleField goal percentage (0-1).
fg3double
fg3adoubleThree-point field goal attempts.
fg3_pctdoubleThree-point field goal percentage (0-1).
fg2double
fg2adouble
fg2_pctdouble
efg_pctdouble
ftdouble
ftadoubleFree throw attempts.
ft_pctdoubleFree throw percentage (0-1).
orbdouble
drbdouble
trbdoubleCareer total rebounds.
astdoubleAssists.
stldoubleSteals.
blkdoubleBlocks.
tovdoubleTurnovers.
pfdoublePersonal fouls.
ptsdoublePoints scored.
game_scoredoubleBart Torvik single-game quality score.
plus_minusdoublePlus/minus point differential while on court.
player_idcharacterUnique player identifier.
seasonintegerSeason year.

Example

from sportsdataverse.nba.bref import bref_player_game_log

df = bref_player_game_log(player_id="jokicni01", season=2024)
print(df.shape)

# Pandas output

df_pd = bref_player_game_log("jamesle01", 2024, return_as_pandas=True)

# Pipeline next step (one line)

df.select(["date", "opp", "pts", "trb", "ast"]).head()

bref_team_roster​

bref_team_roster(team: 'str', season: 'Optional[int]' = None, *, return_as_pandas: 'bool' = False, proxy: 'Any' = None, **kwargs: 'Any') -> 'pl.DataFrame | pd.DataFrame'

A team's roster for one season.

Port of hoopR's bref_team_roster(). NBA only.

Parameters

ParameterTypeDefaultDescription
teamstrBasketball-Reference team abbreviation (BOS, LAL, GSW). Historical franchises use their era code (NJN, SEA).
seasonOptional[int]NoneSeason in 4-digit ending-year format. Defaults to the current NBA season.
return_as_pandasboolFalseReturn a pandas.DataFrame instead of polars.
proxyAnyNoneProxy configuration in the requests proxies= shape.

Returns

One row per rostered player: number, player, pos, height, weight, birth_date, flag, years_experience, college, plus echoed team / season. Zero rows when the team/season combination has no page.

col_nametypedescription
numberdoubleNumber.
playercharacterPlayer name.
poscharacterPosition.
heightcharacterPlayer height (string e.g. '6-2' or inches).
weightdoublePlayer weight in pounds.
birth_datecharacterDate of birth (YYYY-MM-DD).
flagcharacter
years_experiencecharacterYears of NBA experience (R for rookies).
collegecharacterCollege.
teamcharacterTeam-side label or team identifier.
seasonintegerSeason year.

Example

from sportsdataverse.nba.bref import bref_team_roster

df = bref_team_roster(team="BOS", season=2024)
print(df.shape)

# A historical franchise code

sonics = bref_team_roster(team="SEA", season=1996)

# Pipeline next step (one line)

df.select(["player", "pos", "height", "college"]).head()