Boxscore

StatsNbaShotsLoader loads shot data for a game and creates StatsNbaShot objects for all shots

The following code will load shot data for game id “0021900001” from a file located in a subdirectory of the /data directory

from pbpstats.data_loader import StatsNbaShotsFileLoader, StatsNbaShotsLoader

source_loader = StatsNbaShotsFileLoader("/data")
shot_loader = StatsNbaShotsLoader("0021900001", source_loader)
print(shot_loader.items[0].data) # prints dict with data for one shot from game
class pbpstats.data_loader.stats_nba.shots.loader.StatsNbaShotsLoader(game_id, source_loader)[source]

Bases: pbpstats.data_loader.stats_nba.base.StatsNbaLoaderBase

Loads stats.nba.com source shot data for game. Shots are stored in items attribute as StatsNbaShot objects

Parameters:
data_provider = 'stats_nba'
make_list_of_dicts(results_set_index=0)[source]

Creates list of dicts from home and away source data

Parameters:results_set_index (int) – Index results are in. Default is 0
Returns:list of dicts with shot data for all shots
parent_object = 'Game'
resource = 'Shots'
class pbpstats.data_loader.stats_nba.shots.file.StatsNbaShotsFileLoader(file_directory)[source]

Bases: pbpstats.data_loader.stats_nba.file_loader.StatsNbaFileLoader

A StatsNbaShotsFileLoader object should be instantiated and passed into StatsNbaShotsLoader when loading data from file

Parameters:file_directory (str) – Directory in which data should be loaded from. The specific file location will be stats_home_shots_<game_id>.json and stats_away_shots_<game_id>.json in the /game_details subdirectory.
load_data(game_id)[source]
class pbpstats.data_loader.stats_nba.shots.web.StatsNbaShotsWebLoader(file_directory=None)[source]

Bases: pbpstats.data_loader.stats_nba.web_loader.StatsNbaWebLoader

A StatsNbaShotsWebLoader object should be instantiated and passed into StatsNbaShotsLoader when loading data directly from the NBA Stats API

Parameters:file_directory (str) – (optional, use it if you want to store the response data on disk) Directory in which data should be either stored. The specific file location will be stats_home_shots_<game_id>.json and stats_away_shots_<game_id>.json in the /game_details subdirectory. If not provided response data will not be saved on disk.
load_data(game_id)[source]