pandas AttributeError: 'module' 对象没有属性 'hist'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29045636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 23:03:06  来源:igfitidea点击:

AttributeError: 'module' object has no attribute 'hist'

pythonpandasmatplotlibhistogramattributeerror

提问by Piotr Dajlido

I'm new to Python (and am using Spyder) and am trying to create some histograms of when the top movies from IMDB were created. I have imported the matplotlib, numpy and pandas, as well as the .txt file, but when I run the following lines of code:

我是 Python 的新手(并且正在使用 Spyder)并且正在尝试创建一些关于 IMDB 顶级电影何时创建的直方图。我已经导入了 matplotlib、numpy 和 pandas 以及 .txt 文件,但是当我运行以下代码行时:

plt.hist(data.year, bins=np.arange(1950, 2013), color='#cccccc')

I receive an error message:

我收到一条错误消息:

Traceback (most recent call last):
  File "stdin", line 1, in <module>
AttributeError: 'module' object has no attribute 'hist'

What am I doing wrong?

我究竟做错了什么?

回答by Piotr Dajlido

Your question provide very poor information and insight in your code. More data..

您的问题在您的代码中提供了非常差的信息和洞察力。更多数据..

Meanwhile check if you actually import your modules correctly, should have:

同时检查你是否真的正确导入了你的模块,应该有:

import matplotlib.pyplot as plt

in order to use histfunction

为了使用hist功能