Open equilibliam opened 8 months ago
I'm experiencing a bug with playbyplayv3 as well, though apparently different than yours.
Actually, I think I've spotted a bug with your code:
def fetch_play_by_play(game_id):
play_by_play_data = playbyplayv3.PlayByPlayV3(game_id)
play_by_play_data = playbyplaydata.get_data_frames()[0]
return play_by_play_data
Specifically in line 2 of the above function, shouldn't the line read:
play_by_play_data = play_by_play_data.get_data_frames()[0]
It looks like the error is being thrown a line above that so that might not change anything anyway.
Anyway, this is the error I'm experiencing with the endpoint:
from nba_api.stats.endpoints import playbyplayv3
pbp = playbyplayv3.PlayByPlayV3(game_id='22201163')
print(pbp.get_data_frames()[0])
Traceback (most recent call last):
File "c:\Users\Owner\Desktop\Code\testPy.py", line 55, in <module>
play_by_play_data = playbyplayv3.PlayByPlayV3('22201163')
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nba_api\stats\endpoints\playbyplayv3.py", line 63, in __init__
self.get_request()
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nba_api\stats\endpoints\playbyplayv3.py", line 73, in get_request
self.load_response()
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nba_api\stats\endpoints\playbyplayv3.py", line 76, in load_response
data_sets = self.nba_response.get_data_sets(self.endpoint)
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nba_api\stats\library\http.py", line 150, in get_data_sets
return endpoint_parser.get_data_sets()
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nba_api\stats\library\parserv3.py", line 309, in get_data_sets
pbp_head = self.get_playbyplay_headers()
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nba_api\stats\library\parserv3.py", line 284, in get_playbyplay_headers
tmp = self.nba_dict[list(self.nba_dict.keys())[1]]
IndexError: list index out of range
Not sure if they're related but they're both bugs with playbyplayv3 so figured I'd chime in too.
@pfredCL, you need use full game_id:
from nba_api.stats.endpoints import playbyplayv3
pbp = playbyplayv3.PlayByPlayV3(game_id='0022201163')
print(pbp.get_data_frames()[0])
@shufinskiy you're a lifesaver, thank you!
NBA API Version
1.4.1
Issue
When attempting to fetch play-by-play data using the playbyplayv3.PlayByPlayV3() method from the nba_api library, a TypeError is raised indicating that NBAStatsResponse.get_data_sets() takes 1 positional argument but 2 were given.
Thanks for all the work on this library - it is so so so useful.
Code
Stack trace