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

1 python matplotlib histogram attributeerror pandas

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

plt.hist(data.year, bins=np.arange(1950, 2013), color='#cccccc')
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息:

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

我究竟做错了什么?

Pio*_*ido 9

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

同时检查您是否确实正确导入模块,应该:

import matplotlib.pyplot as plt
Run Code Online (Sandbox Code Playgroud)

为了使用hist功能