stats.nba.com Data Loaders

stats.nba.com data loaders are used to load data for a specific resource either from file stored on disk or via an API request to stats.nba.com.

Base

class pbpstats.data_loader.stats_nba.base.StatsNbaLoaderBase[source]

Bases: object

Base Class for all stats.nba.com data loaders

This class should not be instantiated directly

data

returns data from response JSON as a list of dicts

static dedupe_events_row_set(events_row_set)[source]

Dedupes list of results while preserving order

Used to dedupe events rowSets pbp response because some games have duplicate events

Parameters:events_row_set (list) – List of results from API Response
Returns:deduped list of results
league

Returns League for game id.

First 2 in game id represent league - 00 for nba, 10 for wnba, 20 for g-league

league_id

Returns League Id for league.

00 for nba, 10 for wnba, 20 for g-league

make_list_of_dicts(results_set_index=0)[source]

Creates list of dicts from source data

Parameters:results_set_index (int) – Index results are in. Default is 0
Returns:list of dicts with data for results
season

Returns season for game id

4th and 5th characters in game id represent season year ex. for 2016-17 season 4th and 5th characters would be 16 and season should return 2016-17 For WNBA just returns season year

season_type

Returns season type for game id

3rd character in game id represent season type - 2 for reg season, 4 for playoffs, 5 for play in

Boxscore

Enhanced PBP

PBP

Possessions

Game Finder

Scoreboard

Shots

Game Summary

File Loader

class pbpstats.data_loader.stats_nba.file_loader.StatsNbaFileLoader[source]

Bases: pbpstats.data_loader.stats_nba.base.StatsNbaLoaderBase

Base class for loading stats.nba.com files saved on disk.

All stats.nba.com data loader classes should inherit from this class.

This class should not be instantiated directly.

Web Loader

class pbpstats.data_loader.stats_nba.web_loader.StatsNbaWebLoader[source]

Bases: pbpstats.data_loader.stats_nba.base.StatsNbaLoaderBase

Base class for loading data from data.nba.com API request.

All stats.nba.com data loader classes should inherit from this class.

This class should not be instantiated directly.