-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Just tried the example script for NBA (examples_nba.py) and ran into this error when script was in the middle of get_player_stats():
Traceback (most recent call last):
File "examples_nba.py", line 4, in <module>
df = nba.get_player_stats('Bruno Caboclo')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/BRScraper/nba.py", line 346, in get_player_stats
num = df[df['Season']=='Career'].index[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File ".venv/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 5320, in __getitem__
return getitem(key)
^^^^^^^^^^^^
IndexError: index 0 is out of bounds for axis 0 with size 0
Seems issue is with assuming the player's stats table is at index 0 here: df = pd.read_html(url)[0]. I think it should find the table based on the header name "Per Game" or "Totals" instead of assuming same index for each player (diff. players have diff. layouts for diff. reasons).
Most of the rest of the example script works like a charm! Thanks so much for open-sourcing this! Super helpful :)
Metadata
Metadata
Assignees
Labels
No labels