All Courses

Getting an key error while practicing machine learning

By Sundarresan86, 3 years ago
  • Bookmark
0

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2894             try:
-> 2895                 return self._engine.get_loc(casted_key)
   2896             except KeyError as err:

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'Max Temp'

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

KeyError                                  Traceback (most recent call last)
<ipython-input-46-3cef4020c178> in <module>
      1 plt.figure(figsize=(12,8))
----> 2 plt.scatter(dataset['Min Temp'],dataset['Max Temp'],c='b',marker='o')
      3 plt.title('Min Temp VS Max Temp')
      4 plt.xlabel('Min Temp')
      5 plt.ylabel('Max Temp')

~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
   2900             if self.columns.nlevels > 1:
   2901                 return self._getitem_multilevel(key)
-> 2902             indexer = self.columns.get_loc(key)
   2903             if is_integer(indexer):
   2904                 indexer = [indexer]

~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2895                 return self._engine.get_loc(casted_key)
   2896             except KeyError as err:
-> 2897                 raise KeyError(key) from err
   2898 
   2899         if tolerance is not None:

KeyError: 'Max Temp'

<Figure size 864x576 with 0 Axes>


Jupiter 6.1.4
0 Answer
Your Answer

Webinars

More webinars

Related Discussions

Running random forest algorithm with one variable

View More