Category : nba-api

import pandas as pd import requests headers = { ‘Connection’: ‘keep-alive’, ‘Accept’: ‘application/json, text/plain, */*’, ‘x-nba-stats-token’: ‘true’, ‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36’, ‘x-nba-stats-origin’: ‘stats’, ‘Sec-Fetch-Site’: ‘same-origin’, ‘Sec-Fetch-Mode’: ‘cors’, ‘Referer’: ‘https://stats.nba.com/’, ‘Accept-Encoding’: ‘gzip, deflate, br’, ‘Accept-Language’: ‘en-US,en;q=0.9’, } from nba_api.stats.endpoints import leaguegamefinder # get game logs from ..

Read more

I want to get data from nba site to create shot chart. I get it from this site https://datavizardry.com/2020/01/28/nba-shot-charts-part-1/?fbclid=IwAR3BheHQkSAmCJRr_z7ux1ygbspLjLdrvTRjWAVHOrr2BPvVh7jsIos_e9w and my code looks like this: from nba_api.stats.endpoints import shotchartdetail import json import pandas as pd response = shotchartdetail.ShotChartDetail( team_id=0, player_id=0, season_nullable=’2001-02′, season_type_all_star=’Regular Season’ ) content = json.loads(response.get_json()) results = content[‘resultSets’][0] headers = results[‘headers’] rows = ..

Read more

I’m trying to compare two Players going head to head, but the PlayervsPlayer Endpoint returns empty dataframes (except for the dataframes that return the player info – which are the last two dataframes) from nba_api.stats.endpoints import playervsplayer test = playervsplayer.PlayerVsPlayer(vs_player_id = melo, player_id = lbj) df = test.get_data_frames() I tried passing in the parameter: season=SeasonAll.all ..

Read more

here is the mismatch error I keep getting. I’m inputting "202710". Traceback (most recent call last): File "nbastatsrecieveit.py", line 29, in <module> df.columns = headers File "C:Users*AppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespandascoregeneric.py", line 5149, in __setattr__ return object.__setattr__(self, name, value) File "pandas_libsproperties.pyx", line 66, in pandas._libs.properties.AxisProperty.__set__ File "C:Users*AppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespandascoregeneric.py", line 564, in _set_axis self._mgr.set_axis(axis, labels) File "C:Users*AppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespandascoreinternalsmanagers.py", line 226, in set_axis ..

Read more

I recently have been trying to use the NBA API to pull shot chart data. I’ll link the documentation for the specific function I’m using here. I keep getting a traceback as follows: Traceback (most recent call last): File "nbastatsrecieve2.py", line 27, in <module> df.to_excel(filename, index=False) File "C:Users*AppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespandascoregeneric.py", line 2023, in to_excel formatter.write( File "C:Users*AppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagespandasioformatsexcel.py", ..

Read more