今天在进行时间序列问题处理时候,发生如下报错:
AttributeError: module 'pandas' has no attribute 'datetime'
因为在新的pands版本中pandas已不再支持datetime模块。
from datetime import datetime
需要导入datetime库。
原代码:
import pandas as pd
births_by_date.index = [pd.datetime(2012, month, day)
for (month, day) in births_by_date.index]#导入datetime模块
将代码修改为:
from datetime import datetime
births_by_date.index = [datetime(2012, month, day)
for (month, day) in births_by_date.index]
再次运行,即可解决问题: