stats.nba.comAPInbaPlayerTrackingNBAAPI
stats.nba.com API NBAAPInbaPlayerTracking
stats.nba.com APINBAAPIAPI20
nbaPlayerTrackingstats.nba.com APINBAnbaPlayerTracking
nbaPlayerTrackingstats.nba.comAPIAPI20IPHTTPPythonrequestspandasAPIJSONpandasDataFrame
nbaPlayerTracking5
nbaPlayerTrackingnbaPlayerTracking45%
Pythonrequestsstats.nba.com API
import requests import pandas as pd APIURL url = headers = User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3 params = LeagueID: 00, NBA Season: 2022-23, SeasonType: Regular Season, PlayerID: 1629662 ID GET response = requests.get(url, headers=headers, params=params) if response.status_code == 200: JSON data = response.json() result_set = data[resultSets][0] headers = result_set[headers] rows = result_set[rowSet] pandasDataFrame df = pd.DataFrame(rows, columns=headers) print(df.head()) else: print(, response.status_code)
stats.nba.com APIURLAPIGET200JSONPythonPandasDataFrame
game_dataDataFrame
import math def calculate_distance(row): player1_x, player1_y = row[LOC_X_PLAYER1], row[LOC_Y_PLAYER1] player2_x, player2_y = row[LOC_X_PLAYER2], row[LOC_Y_PLAYER2] return math.sqrt((player1_x – player2_x)**2 + (player1_y – player2_y)**2) game_data game_data[DISTANCE] = game_data.apply(calculate_distance, axis=1) print(game_data[[PLAYER1_NAME, PLAYER2_NAME, DISTANCE]].head())
calculate_distanceDataFramePandasapplyDataFrameDataFrame
stats.nba.com APIAPI
stats.nba.com API20
Pythonpandasgroupby()matplotlibseaborn
stats.nba.com API
NBAAPI
APIIP
stats.nba.com API
stats.nba.com APInbaPlayerTrackingNBANBAstats.nba.com API
© 2015-2023 ALL RIGHTS RESERVED.
SHOWAPI POWERED BY SHOWAPI