用熊猫绘图时的KeyError

时间:2020-09-15 10:59:06

标签: python pandas

我有以下python代码:

import matplotlib.pyplot as plt
plt.plot(dataset['YearsExperience'], dataset['salary'],'b.')

这是我得到的错误:

 KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2645             try:
-> 2646                 return self._engine.get_loc(key)
   2647             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: 'salary'

可以帮我解决这个问题吗?

0 个答案:

没有答案