hi
looking for an easy way to get all player's or team's charts, for a season or all seasons...
from nba_py import shotchart
from nba_py.player import get_player
import json
import pandas as pd
from nba_py.constants import TEAMS
from nba_py import team
pid = get_player('Kevin', 'Durant')
tid = TEAMS['SAC']['id']
team_details = team.TeamDetails(tid)
sc = shotchart.ShotChart(tid)
#print sc.json['resultSets']
# Grab the headers to be used as column headers for our DataFrame
headers = sc.json['resultSets'][0]['headers']
# Grab the shot chart data
shots = sc.json['resultSets'][0]['rowSet']
shot_df = pd.DataFrame(shots, columns=headers)
# View the head of the DataFrame and all its columns
shot_df.to_csv('shot_chart.csv', encoding='utf-8')
with open('shot_chart.json', 'w') as outfile:
json.dump(sc.json, outfile)
hi looking for an easy way to get all player's or team's charts, for a season or all seasons...