Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError when Update=True #10

Open
Omicrxn opened this issue Jul 29, 2020 · 5 comments
Open

KeyError when Update=True #10

Omicrxn opened this issue Jul 29, 2020 · 5 comments

Comments

@Omicrxn
Copy link

Omicrxn commented Jul 29, 2020

Hi i'm testing the python 3 code and I am getting this error all the time but only if i set NBAModel update to true hope you can help me:

**** http://www.basketball-reference.com/leagues/NBA_2019_games-october.html
**** http://www.basketball-reference.com/leagues/NBA_2019_games-november.html
**** http://www.basketball-reference.com/leagues/NBA_2019_games-december.html
    Unnamed: 0_level_0 Basic Box Score Stats            ...                    
              Starters                    MP   FG  FGA  ...  TOV   PF  PTS  +/-
0           Al Horford                 15:44    3    4  ...    1    0    7   +8
1         Kyrie Irving                 14:50    0    8  ...    1    0    0   +9
2         Jayson Tatum                 15:35    5   10  ...    0    1   13   +2
3         Jaylen Brown                 15:44    2    9  ...    1    2    5   +8
4       Gordon Hayward                 11:24    2    6  ...    0    0    4   +7
5             Reserves                    MP   FG  FGA  ...  TOV   PF  PTS  +/-
6         Terry Rozier                 12:40    3    5  ...    0    0    6   +3
7         Marcus Smart                 14:29    2    3  ...    1    1    7   -5
8        Marcus Morris                 11:18    2    4  ...    1    3    5   -4
9          Aron Baynes                  8:16    0    3  ...    1    1    0   -3
10        Daniel Theis                   NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN
11        Semi Ojeleye                   NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN
12  Guerschon Yabusele                   NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN
13      Brad Wanamaker                   NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN
14         Team Totals                   240   42   97  ...   14   20  105  NaN

[15 rows x 21 columns]

Traceback (most recent call last):
  File "venv\lib\site-packages\pandas\core\indexes\base.py", line 2889, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas\_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 97, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Kyrie Irving'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "NBA-prediction/model/model.py", line 228, in <module>
    model = NBAModel(update=True)
  File "NBA-prediction/model/model.py", line 52, in __init__
    self.df_pace, self.df_OR = self.make_matrices()
  File "NBA-prediction/model/model.py", line 179, in make_matrices
    df_pace, df_OR = self.full_update(url, df_pace, df_OR)
  File "NBA-prediction/model/model.py", line 163, in full_update
    df_pace = self.update_df(df_pace, team1, team2, pace)
  File "NBA-prediction/model/model.py", line 114, in update_df
    old_value = df[team2].loc[team1]
  File "venv\lib\site-packages\pandas\core\frame.py", line 2899, in __getitem__
    indexer = self.columns.get_loc(key)
  File "venv\lib\site-packages\pandas\core\indexes\base.py", line 2891, in get_loc
    raise KeyError(key) from err
KeyError: 'Kyrie Irving'

Process finished with exit code 1
@scl2b
Copy link

scl2b commented Jan 2, 2021

got the same, did you resolve it ?

@camsterguy
Copy link

I also have this problem! Any ideas?

@Drazzel
Copy link

Drazzel commented Oct 19, 2022

Experiencing a similar problem. Any updates?

@laterbe
Copy link

laterbe commented Jan 5, 2024

does anybody know the ideas?

@yuetyang
Copy link

I also have this problem! Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants