Boxscore

StatsNbaLeagueGameLogLoader loads all games for a season and creates StatsNbaGameItem objects for each game

The following code will load data for the 2019-20 NBA Regular Season

from pbpstats.data_loader import StatsNbaLeagueGameLogWebLoader, StatsNbaLeagueGameLogLoader

source_loader = StatsNbaLeagueGameLogWebLoader("/data")
league_game_log_loader = StatsNbaLeagueGameLogLoader("nba", "2019-20", "Regular Season", source_loader)
print(league_game_log_loader.items[0].data) # prints dict for first game
class pbpstats.data_loader.stats_nba.league_game_log.loader.StatsNbaLeagueGameLogLoader(league, season, season_type, source_loader)[source]

Bases: pbpstats.data_loader.stats_nba.base.StatsNbaLoaderBase

Loads stats.nba.com source data for season. Games are stored in items attribute as StatsNbaGameItem objects

Parameters:
  • league (str) – Options are ‘nba’, ‘wnba’ or ‘gleague’
  • season (str) – Formatted as 2019-20 for NBA and G-League, 2019 of WNBA.
  • season_type (str) – Options are ‘Regular Season’ or ‘Playoffs’ or ‘Play In’
  • source_loaderStatsNbaLeagueGameLogFileLoader or StatsNbaLeagueGameLogWebLoader object
data_provider = 'stats_nba'
parent_object = 'Season'
resource = 'Games'
class pbpstats.data_loader.stats_nba.league_game_log.file.StatsNbaLeagueGameLogFileLoader(file_directory)[source]

Bases: pbpstats.data_loader.stats_nba.file_loader.StatsNbaFileLoader

A StatsNbaLeagueGameLogFileLoader object should be instantiated and passed into StatsNbaLeagueGameLogLoader when loading data from file

Parameters:file_directory (str) – Directory in which data should be loaded from. The specific file location will be stats_leaguegamelog_<league>_<season>_<season_type>.json in the /schedule subdirectory.
load_data(league, season, season_type)[source]
class pbpstats.data_loader.stats_nba.league_game_log.web.StatsNbaLeagueGameLogWebLoader(file_directory=None)[source]

Bases: pbpstats.data_loader.stats_nba.web_loader.StatsNbaWebLoader

A StatsNbaLeagueGameLogWebLoader object should be instantiated and passed into StatsNbaLeagueGameLogLoader 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_<league>_<season>_<season_type>.json in the /schedule subdirectory. If not provided response data will not be saved on disk.
load_data(league, season, season_type)[source]