Enhanced PBP

LiveEnhancedPbpLoader 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 LiveEnhancedPbpFileLoader, LiveEnhancedPbpLoader

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

Bases: pbpstats.data_loader.live.pbp.loader.LivePbpLoader, 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:
data_provider = 'live'
parent_object = 'Game'
resource = 'EnhancedPbp'
class pbpstats.data_loader.live.enhanced_pbp.file.LiveEnhancedPbpFileLoader(file_directory)[source]

Bases: pbpstats.data_loader.live.pbp.file.LivePbpFileLoader

A LiveEnhancedPbpFileLoader object should be instantiated and passed into LiveEnhancedPbpLoader when loading data from file

Parameters:
  • game_id (str) – NBA Stats Game Id
  • file_directory (str) – Directory in which data should be loaded from. The specific file location will be live_<game_id>.json in the /pbp subdirectory.
class pbpstats.data_loader.live.enhanced_pbp.web.LiveEnhancedPbpWebLoader(file_directory=None)[source]

Bases: pbpstats.data_loader.live.pbp.web.LivePbpWebLoader

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