Enhanced PBP

DataNbaEnhancedPbpLoader loads pbp data for a game and creates EnhancedPbpItem objects for each event

Enhanced data for each event includes current players on floor, score, fouls to give and number of fouls committed by each player, plus additional data depending on event type

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

from pbpstats.data_loader import DataNbaEnhancedPbpFileLoader, DataNbaEnhancedPbpLoader

source_loader = DataNbaEnhancedPbpFileLoader("/data")
pbp_loader = DataNbaEnhancedPbpLoader("0021900001", source_loader)
print(pbp_loader.items[0].data)  # prints dict with the first event of the game
class pbpstats.data_loader.data_nba.enhanced_pbp.loader.DataNbaEnhancedPbpLoader(game_id, source_loader)[source]

Bases: pbpstats.data_loader.data_nba.pbp.loader.DataNbaPbpLoader, pbpstats.data_loader.nba_enhanced_pbp_loader.NbaEnhancedPbpLoader

Loads data.nba.com source enhanced pbp data for game. Events are stored in items attribute as EnhancedPbpItem objects

Parameters:
Raises:

InvalidNumberOfStartersException: If all 5 players that start the period for a team can’t be determined. You can add the correct period starters to overrides/missing_period_starters.json in your data directory to fix this.

data_provider = 'data_nba'
parent_object = 'Game'
resource = 'EnhancedPbp'
class pbpstats.data_loader.data_nba.enhanced_pbp.file.DataNbaEnhancedPbpFileLoader(file_directory=None)[source]

Bases: pbpstats.data_loader.data_nba.pbp.file.DataNbaPbpFileLoader

A DataNbaEnhancedPbpFileLoader object should be instantiated and passed into DataNbaEnhancedPbpLoader when loading data from file

Parameters:file_directory (str) – Directory in which data should be loaded from. The specific file location will be data_<game_id>.json in the /pbp subdirectory.
class pbpstats.data_loader.data_nba.enhanced_pbp.web.DataNbaEnhancedPbpWebLoader(file_directory=None)[source]

Bases: pbpstats.data_loader.data_nba.pbp.web.DataNbaPbpWebLoader

A DataNbaEnhancedPbpWebLoader object should be instantiated and passed into DataNbaEnhancedPbpLoader 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 data_<game_id>.json in the /pbp subdirectory. If not provided response data will not be saved on disk.