Python 值制作excel数据直方图时出错

Python 值制作excel数据直方图时出错,python,pandas,Python,Pandas,我正在尝试制作excel数据的柱状图。我使用了以下代码: import pandas as pd import matplotlib.pyplot as py data=pd.read_excel('file.xlsx',header=1, parse_cols="Q") plt.hist(data, bin=10) plt.show() 但它给出了这样一个错误: Traceback (most recent call last): File "<ipython-input-1-0

我正在尝试制作excel数据的柱状图。我使用了以下代码:

import pandas as pd
import matplotlib.pyplot as py
data=pd.read_excel('file.xlsx',header=1, parse_cols="Q")
plt.hist(data, bin=10)
plt.show()
但它给出了这样一个错误:

Traceback (most recent call last):

  File "<ipython-input-1-0ffa7ab287c3>", line 4, in <module>
    plt.hist(data, bin=10)

  File "C:\Program Files\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 2890, in hist
    stacked=stacked, **kwargs)

  File "C:\Program Files\Anaconda\lib\site-packages\matplotlib\axes\_axes.py", line 5562, in hist
    if isinstance(x, np.ndarray) or not iterable(x[0]):

  File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\frame.py", line 1678, in __getitem__
    return self._getitem_column(key)

  File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\frame.py", line 1685, in _getitem_column
    return self._get_item_cache(key)

  File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\generic.py", line 1052, in _get_item_cache
    values = self._data.get(item)

  File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\internals.py", line 2565, in get
    loc = self.items.get_loc(item)

  File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\index.py", line 1181, in get_loc
    return self._engine.get_loc(_values_from_object(key))

  File "index.pyx", line 129, in pandas.index.IndexEngine.get_loc (pandas\index.c:3656)

  File "index.pyx", line 149, in pandas.index.IndexEngine.get_loc (pandas\index.c:3534)

  File "hashtable.pyx", line 696, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:11911)

  File "hashtable.pyx", line 704, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:11864)

KeyError: 0
回溯(最近一次呼叫最后一次):
文件“”,第4行,在
plt.hist(数据,bin=10)
文件“C:\Program Files\Anaconda\lib\site packages\matplotlib\pyplot.py”,第2890行,在hist中
堆叠=堆叠,**千克)
文件“C:\Program Files\Anaconda\lib\site packages\matplotlib\axes\\u axes.py”,第5562行,在hist中
如果isinstance(x,np.ndarray)或not iterable(x[0]):
文件“C:\Program Files\Anaconda\lib\site packages\pandas\core\frame.py”,第1678行,在\uuu getitem中__
返回self.\u getitem\u列(键)
文件“C:\Program Files\Anaconda\lib\site packages\pandas\core\frame.py”,第1685行,在\u getitem\u列中
返回self.\u获取\u项目\u缓存(密钥)
文件“C:\Program Files\Anaconda\lib\site packages\pandas\core\generic.py”,第1052行,在\u get\u item\u缓存中
values=self.\u data.get(项目)
get中的文件“C:\Program Files\Anaconda\lib\site packages\pandas\core\internals.py”,第2565行
loc=自身项目。获取loc(项目)
文件“C:\Program Files\Anaconda\lib\site packages\pandas\core\index.py”,第1181行,在get\U loc中
返回self.\u引擎。获取\u loc(\u值\u来自\u对象(键))
pandas.index.IndexEngine.get_loc(pandas\index.c:3656)中的文件“index.pyx”,第129行
pandas.index.IndexEngine.get_loc(pandas\index.c:3534)中的文件“index.pyx”,第149行
pandas.hashtable.PyObjectHashTable.get_项(pandas\hashtable.c:11911)中第696行的文件“hashtable.pyx”
pandas.hashtable.PyObjectHashTable.get_项(pandas\hashtable.c:11864)中第704行的文件“hashtable.pyx”
关键错误:0
这就是我的数据的样子


有人知道如何解决这个问题吗?

请给出完整的堆栈跟踪我编辑的问题您可以包括
打印
数据的输出吗。顺便说一句,
hist()
的参数称为
bin
而不是
bin