'module' 对象在 python 中没有属性 'date_range'

'module' object has no attribute 'date_range' in python

我正在学习 pandas Python.Below 是我在终端中的代码:

import pandas as pd
dates = pd.date_range('20130101', periods=6)

然后我收到这条消息:

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

如何解决这个问题?

您找不到 date_range,因为您使用的是 pandas 版本 0.7.0,它在 pandas 时间非常旧(~2012 年 2 月 9 日)-当前稳定版本(2015 年 1 月 29 日)是 0.15.2。

您想要升级,不仅是因为错误修复和新功能,还因为您将在网络上找到的许多示例不适合您。