Possessions¶
DataNbaPossessionLoader
loads possession data for a game and creates Possession
objects for each possession
The following code will load possession data for game id “0021900001” from a pbp file located in the /pbp
subdirectory of the /data
directory
from pbpstats.data_loader import DataNbaPossessionFileLoader, DataNbaPossessionLoader
source_loader = DataNbaPossessionFileLoader("/data")
possession_loader = DataNbaPossessionLoader("0021900001", source_loader)
print(possession_loader.items[0].data) # prints dict with the first possession of the game
-
class
pbpstats.data_loader.data_nba.possessions.loader.
DataNbaPossessionLoader
(game_id, source_loader)[source]¶ Bases:
pbpstats.data_loader.nba_possession_loader.NbaPossessionLoader
Loads data.nba.com source possession data for game. Possessions are stored in items attribute as
Possession
objectsParameters: - game_id (str) – NBA Stats Game Id
- source_loader –
DataNbaPossessionFileLoader
orDataNbaPossessionWebLoader
object
-
data_provider
= 'data_nba'¶
-
parent_object
= 'Game'¶
-
resource
= 'Possessions'¶
-
class
pbpstats.data_loader.data_nba.possessions.file.
DataNbaPossessionFileLoader
(file_directory=None)[source]¶ Bases:
object
A
DataNbaPossessionFileLoader
object should be instantiated and passed intoDataNbaPossessionLoader
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.possessions.web.
DataNbaPossessionWebLoader
(file_directory=None)[source]¶ Bases:
object
A
DataNbaPbpWebLoader
object should be instantiated and passed intoDataNbaPossessionLoader
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.