2017-06-02 128 views
0

對於下面的代碼屬性錯誤:模塊對象有沒有屬性「to_date_time」

import quandl 
import pandas as pd 

api_key = open('quandlapikey.txt','r').read() 

df = quandl.get('FMAC/HPI_AK',authtoken=api_key) 

print(df.head()) 

我收到此錯誤:

File "/usr/local/lib/python2.7/dist-packages/Quandl-3.1.0-py2.7.egg/quandl/get.py", line 63, in get return data.to_pandas() File "/usr/local/lib/python2.7/dist-packages/Quandl-3.1.0-py2.7.egg/quandl/model/data_mixin.py", line 20, in to_pandas df[self.column_names[0]] = df[self.column_names[0]].apply(pd.to_datetime) AttributeError: 'module' object has no attribute 'to_datetime'

回答

0

您需要升級你的pandas版。

this答案:

The to_datetime function was introduced in 0.8.0, so you'll have to upgrade your pandas to use it. Ideally to the latest stable version.

嘗試使用:

pip install pandas --upgrade 
+0

它顯示:蟒蛇,大熊貓已經是最新版本。 –

+0

它顯示了什麼版本?你可以使用'pd .__ version__'來檢查它。 –

+0

哦!它顯示0.7.0 –

相關問題