PBP¶
DataNbaPbpLoader
loads pbp data for a game and creates DataNbaPbpItem
objects for each event
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 DataNbaPbpFileLoader, DataNbaPbpLoader
source_loader = DataNbaPbpFileLoader("/data")
pbp_loader = DataNbaPbpLoader("0021900001", source_loader)
print(pbp_loader.items[0].data) # prints dict with the first event of the game
-
class
pbpstats.data_loader.data_nba.pbp.loader.
DataNbaPbpLoader
(game_id, source_loader)[source]¶ Bases:
pbpstats.data_loader.data_nba.base.DataNbaLoaderBase
Loads data.nba.com source pbp data for game. Events are stored in items attribute as
DataNbaPbpItem
objectsParameters: - game_id (str) – NBA Stats Game Id
- source_loader –
DataNbaPbpFileLoader
orDataNbaPbpWebLoader
object
-
data
¶ returns raw JSON response data
-
data_provider
= 'data_nba'¶
-
parent_object
= 'Game'¶
-
resource
= 'Pbp'¶
-
class
pbpstats.data_loader.data_nba.pbp.file.
DataNbaPbpFileLoader
(file_directory=None)[source]¶ Bases:
pbpstats.data_loader.data_nba.file_loader.DataNbaFileLoader
A
DataNbaPbpFileLoader
object should be instantiated and passed intoDataNbaPbpLoader
when loading data from fileParameters: 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.pbp.web.
DataNbaPbpWebLoader
(file_directory=None)[source]¶ Bases:
pbpstats.data_loader.data_nba.web_loader.DataNbaWebLoader
A
DataNbaPbpWebLoader
object should be instantiated and passed intoDataNbaPbpLoader
when loading data directly from the NBA Stats APIParameters: 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.