christopherjenness / NBA-prediction

Predict scores of NBA games using regularized matrix completion
151 stars 43 forks source link

KeyError when Update=True #10

Open Omicrxn opened 4 years ago

Omicrxn commented 4 years ago

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 commented 3 years ago

got the same, did you resolve it ?

camsterguy commented 3 years ago

I also have this problem! Any ideas?

Drazzel commented 2 years ago

Experiencing a similar problem. Any updates?

laterbe commented 11 months ago

does anybody know the ideas?

yuetyang commented 5 months ago

I also have this problem! Any ideas?