basketballrelativity / py_ball

Python API for stats.nba.com with a focus on NBA and WNBA applications
https://basketballrelativity.github.io/py_ball/
MIT License
104 stars 14 forks source link

shotchartdetail - Shot_Chart_Detail is empty #7

Closed naymikm closed 4 years ago

naymikm commented 4 years ago

I was working through your shot probability notebook and noticed the LeagueAverages is there but the Shot_Chart_Detail is empty. I tried a few game_id's and same result.

league_id = '00' #NBA
player_id = '0' #All players
game_id = '1021900008'
season = '2018-19' 

shots = player.Player(headers=HEADERS,
                      endpoint='shotchartdetail',
                      league_id=league_id,
                      player_id=player_id,
                      game_id=game_id,
                      season=season)
shot_df = pd.DataFrame(shots.data['Shot_Chart_Detail'])
shot_df.head(15)

print(shots.data)
{'Shot_Chart_Detail': [],
 'LeagueAverages': [{'GRID_TYPE': 'League Averages',
   'SHOT_ZONE_BASIC': 'Above the Break 3',
   'SHOT_ZONE_AREA': 'Back Court(BC)',
   'SHOT_ZONE_RANGE': 'Back Court Shot',
   'FGA': 43,
   'FGM': 2,
   'FG_PCT': 0.047},
  {'GRID_TYPE': 'League 
 ... 

Update: I did find some that work. i.e. the example in your location_data example

league_id = '00' #NBA
player_id = '0' #All players
game_id = '0021800699'
season = '2018-19'

shots = player.Player(headers=HEADERS,
                      endpoint='shotchartdetail',
                      league_id=league_id,
                      player_id=player_id,
                      game_id=game_id,
                      season=season)
shot_df = pd.DataFrame(shots.data['Shot_Chart_Detail'])
shot_df.head(15)

^ prints the shot_df
naymikm commented 4 years ago

Better suited for shot prob github