Skip to main content
 首页 » 编程设计

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

2025年05月04日10EasonJim

我是 Python 的新手(我正在使用 Spyder),我正在尝试创建一些直方图来表示 IMDB 中热门电影的创建时间。我已经导入了 matplotlib、numpy 和 pandas 以及 .txt 文件,但是当我运行以下代码行时:

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

我收到一条错误消息:

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

我做错了什么?

请您参考如下方法:

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

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

import matplotlib.pyplot as plt 

为了使用hist函数