очень запутан здесь и просто недостаточно осведомлен, чтобы понять суть проблемы. Я записываю данные о стоимости строительного оборудования в ноутбуке Jupyter, и все идет отлично. За исключением одного конкретного набора данных, я получаю сообщение об ошибке. После поиска в Google и поиска решения я должен прийти к stackoverflow. Это странно, потому что я не делаю ничего другого с этим набором данных. Я даже пытался воссоздать его. Это все, что я делаю:
dataretry.plot(kind="scatter", x="Price", y="Hours", alpha=0.3)
Я ожидал показать диаграмму рассеяния. Тем не менее, я получаю это массивное сообщение об ошибке:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3077 try:
-> 3078 return self._engine.get_loc(key)
3079 except KeyError:
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: 'Price'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-35-81e70cca10a1> in <module>
----> 1 dataretry.plot(kind="scatter", x="Price", y="Hours", alpha=0.3)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\plotting\_core.py in __call__(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
2939 fontsize=fontsize, colormap=colormap, table=table,
2940 yerr=yerr, xerr=xerr, secondary_y=secondary_y,
-> 2941 sort_columns=sort_columns, **kwds)
2942 __call__.__doc__ = plot_frame.__doc__
2943
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\plotting\_core.py in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
1975 yerr=yerr, xerr=xerr,
1976 secondary_y=secondary_y, sort_columns=sort_columns,
-> 1977 **kwds)
1978
1979
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\plotting\_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
1741 if isinstance(data, ABCDataFrame):
1742 plot_obj = klass(data, x=x, y=y, subplots=subplots, ax=ax,
-> 1743 kind=kind, **kwds)
1744 else:
1745 raise ValueError("plot kind %r can only be used for data frames"
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\plotting\_core.py in __init__(self, data, x, y, s, c, **kwargs)
843 # the handling of this argument later
844 s = 20
--> 845 super(ScatterPlot, self).__init__(data, x, y, s=s, **kwargs)
846 if is_integer(c) and not self.data.columns.holds_integer():
847 c = self.data.columns[c]
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\plotting\_core.py in __init__(self, data, x, y, **kwargs)
817 if is_integer(y) and not self.data.columns.holds_integer():
818 y = self.data.columns[y]
--> 819 if len(self.data[x]._get_numeric_data()) == 0:
820 raise ValueError(self._kind + ' requires x column to be numeric')
821 if len(self.data[y]._get_numeric_data()) == 0:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
2686 return self._getitem_multilevel(key)
2687 else:
-> 2688 return self._getitem_column(key)
2689
2690 def _getitem_column(self, key):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\frame.py in _getitem_column(self, key)
2693 # get column
2694 if self.columns.is_unique:
-> 2695 return self._get_item_cache(key)
2696
2697 # duplicate columns & possible reduce dimensionality
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py in _get_item_cache(self, item)
2487 res = cache.get(item)
2488 if res is None:
-> 2489 values = self._data.get(item)
2490 res = self._box_item_values(item, values)
2491 cache[item] = res
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\internals.py in get(self, item, fastpath)
4113
4114 if not isna(item):
-> 4115 loc = self.items.get_loc(item)
4116 else:
4117 indexer = np.arange(len(self.items))[isna(self.items)]
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3078 return self._engine.get_loc(key)
3079 except KeyError:
-> 3080 return self._engine.get_loc(self._maybe_cast_indexer(key))
3081
3082 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
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: 'Price'
Любая помощь приветствуется!