Python 创建特定列的绘图时出错

Python 创建特定列的绘图时出错,python,matplotlib,dataset,Python,Matplotlib,Dataset,我对python很陌生,但遇到了这种错误 这是我的代码(数据集存储在AAPL中,列被命名为“Close/Last”) 这是我的错误 --------------------------------------------------------------------------- KeyError回溯(最近一次呼叫最后一次) /get_loc中的usr/local/lib/python3.6/dist-packages/pandas/core/index/base.py(self、key、me

我对python很陌生,但遇到了这种错误

这是我的代码(数据集存储在AAPL中,列被命名为“Close/Last”)

这是我的错误

---------------------------------------------------------------------------
KeyError回溯(最近一次呼叫最后一次)
/get_loc中的usr/local/lib/python3.6/dist-packages/pandas/core/index/base.py(self、key、method、tolerance)
2894尝试:
->2895自动返回引擎。获取锁定(铸造键)
2896除KeyError作为错误外:
pandas/_libs/index.pyx在pandas中。_libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx在pandas中。_libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi在pandas._libs.hashtable.PyObjectHashTable.get_item()中
pandas/_libs/hashtable_class_helper.pxi在pandas._libs.hashtable.PyObjectHashTable.get_item()中
KeyError:“关闭\\Last”
上述异常是以下异常的直接原因:
KeyError回溯(最近一次呼叫最后一次)
2帧
在()
1#可视化数据
2 plt.图(figsize=(12.5,4.5))
---->3 plt.plot(AAPL['Close\Last'],标签='AAPL')
4 plt.title(“苹果调整收盘价历史记录”)
5 plt.xlabel(2015年11月23日至2020年11月20日)
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in_u__获取项目(self,key)
2904如果self.columns.nlevels>1:
2905返回自我。\u获取项目\u多级(键)
->2906索引器=self.columns.get_loc(键)
2907如果是_整数(索引器):
2908索引器=[索引器]
/get_loc中的usr/local/lib/python3.6/dist-packages/pandas/core/index/base.py(self、key、method、tolerance)
2895自动返回引擎。获取锁定(铸造键)
2896除KeyError作为错误外:
->2897从err升起钥匙错误(钥匙)
2898
2899如果公差不是无:
KeyError:“关闭\\Last”
有人能帮我解决这个错误吗?我试图找到一些解决方案,但不幸的是我没有找到任何解决方案。谢谢

plt.figure(figsize=(12.5, 4.5))
plt.plot(AAPL['Close\Last'], label = 'AAPL')
plt.title('Apple Adj. Close Price History')
plt.xlabel('Nov. 23, 2015 - Nov. 20, 2020')
plt.ylabel('Adj. Close Price in USD ($)')
plt.legend(loc='upper left')
plt.show()
---------------------------------------------------------------------------
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)
   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: 'Close\\Last'

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

KeyError                                  Traceback (most recent call last)
2 frames
<ipython-input-13-3f81144f394d> in <module>()
      1 #Visualize the data
      2 plt.figure(figsize=(12.5, 4.5))
----> 3 plt.plot(AAPL['Close\Last'], label = 'AAPL')
      4 plt.title('Apple Adj. Close Price History')
      5 plt.xlabel('Nov. 23, 2015 - Nov. 20, 2020')

/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in __getitem__(self, key)
   2904             if self.columns.nlevels > 1:
   2905                 return self._getitem_multilevel(key)
-> 2906             indexer = self.columns.get_loc(key)
   2907             if is_integer(indexer):
   2908                 indexer = [indexer]

/usr/local/lib/python3.6/dist-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: 'Close\\Last'
<Figure size 900x324 with 0 Axes>