mortada/fredapi

FredDL.py 32 get_series C:\Python27\lib\site-packages\fredapi\fred.py 132 _parse C:\Python27\lib\site-packages\fredapi\fred.py 65 exceptions.AttributeError: 'datetime.datetime' object has no attribute 'to_datetime'

ErkanCDU opened this issue · 6 comments

Just a standard example gives an error:
from fredapi import Fred
fred = Fred(api_key='..')
data = fred.get_series('GDP')

tried restarting and playing around with various date import commands, but the simple code

gives the error output:

Traceback (most recent call last):
File "", line 254, in run_nodebug
File "..FredDL.py", line 32, in
data = fred.get_series('GDP')
File "C:\Python27\lib\site-packages\fredapi\fred.py", line 132, in get_series
data[self._parse(child.get('date'))] = val
File "C:\Python27\lib\site-packages\fredapi\fred.py", line 65, in _parse
return to_datetime(date_str, format=format).to_datetime()
AttributeError: 'datetime.datetime' object has no attribute 'to_datetime'

that's weird - this actually works fine for me. What version of fredapi are you using?

Oh ... I think this is probably because you are on an older version of pandas, what's your pandas version?

@ErkanCDU upgrading to fredapi 0.3.6 should fix your issue.

Hi,

thanks for the quick comments. I am now convinced that something is wrong with my system. After reinstalling the packages, a different error pops up. I will let you know when I have found the solution

Traceback (most recent call last):
File "", line 254, in run_nodebug
File "C:\Users\Erkki\Dropbox_JmpCode\Data\NewsAnal\ProcessNewsAnal\TimeVaryingRegressionSparsity\Korobilis\FredDL.py", line 32, in
data = fred.get_series('GDP')
File "C:\Python27\lib\site-packages\fredapi\fred.py", line 113, in get_series
from pandas import to_datetime, Series
File "C:\Python27\lib\site-packages\pandas__init__.py", line 7, in
from pandas import hashtable, tslib, lib
File "pandas\src\numpy.pxd", line 865, in init pandas.hashtable (pandas\hashtable.c:23780)
ValueError: numpy.ufunc has the wrong size, try recompiling

Ah I see, does seem like a problem on your system. I'd recommend using Anaconda to manage your python modules https://store.continuum.io/cshop/anaconda/

The version control was indeed the issue, after reinstalling everything (via Anaconda as you suggested, it works now). Thanks. Case closed.