avelkoski / FRB

Python Client for Interfacing with the Federal Reserve Bank of St. Louis' Economic Data API (FRED®)
MIT License
163 stars 41 forks source link

Attribute Error when querying DGS10; 'Dataframe object has no attribute "convert_objects"' #11

Open carvetighter opened 4 years ago

carvetighter commented 4 years ago

I'm having an issue when I try to pull data from the 10 year yield treasure 'DGS10'. I'm using frb version 1.1.4

Below is the error messages:

_Traceback (most recent call last): File "main.py", line 106, in main() File "main.py", line 92, in main series_10y = pull_10y_yield(dt_start, dt_stop) File "main.py", line 65, in pull_10y_yield df_10y = fred_conn.series.observations( File "C:\Users\Frosty SB 02\Anaconda3\envs\emba_fsa\lib\site-packages\fred\utils__init.py", line 17, in _wrapped return func(*args,params=params,**kwargs) File "C:\Users\Frosty SB 02\Anaconda3\envs\emba_fsa\lib\site-packages\fred\clients\eseries.py", line 175, in observations response = _get_request(self.url_root,self.api_key,path,response_type,params) File "C:\Users\Frosty SB 02\Anaconda3\envs\emba_fsa\lib\site-packages\fred\helpers__init.py", line 117, in _get_request response = _dispatch(response_type)(content) File "C:\Users\Frosty SB 02\Anaconda3\envs\emba_fsa\lib\site-packages\fred\helpers__init__.py", line 47, in _dict response = _data_frame(content).to_dict(orient='records') File "C:\Users\Frosty SB 02\Anaconda3\envs\emba_fsa\lib\site-packages\fred\helpers\init__.py", line 58, in _data_frame final_frame = _convert(frame) File "C:\Users\Frosty SB 02\Anaconda3\envs\emba_fsa\lib\site-packages\fred\helpers\init.py", line 36, in _convert frame = frame.convert_objects(convert_numeric=True) File "C:\Users\Frosty SB 02\Anaconda3\envs\emba_fsa\lib\site-packages\pandas\core\generic.py", line 5139, in getattr return object.getattribute__(self, name) AttributeError: 'DataFrame' object has no attribute 'convertobjects'

Below is the applicable code:

fred_conn = Fred(
        api_key = 'my-api-key',
        response_type = 'df'
    )
    df_10y = fred_conn.series.observations(
        series_id = 'DGS10',
        observation_start = date_start.strftime('%Y-%m-%d'),
        observation_end = date_stop.strftime('%Y-%m-%d'),
        frequency = 'd'
    )

    print(df_10y[:10])

Below is my list of python packages used:

Name Version Build Channel astroid 2.4.2 py38_0 blas 1.0 mkl ca-certificates 2020.10.14 0 certifi 2020.6.20 py38_0 chardet 3.0.4 pypi_0 pypi colorama 0.4.4 py_0 cycler 0.10.0 py38_0 frb 1.1.4 pypi_0 pypi freetype 2.10.4 hd328e21_0 icu 58.2 ha925a31_3 idna 2.10 pypi_0 pypi intel-openmp 2020.2 254 isort 5.6.4 py_0 jpeg 9b hb83a4c4_2 kiwisolver 1.2.0 py38h74a9793_0 lazy-object-proxy 1.4.3 py38he774522_0 libpng 1.6.37 h2a8f88b_0 libtiff 4.1.0 h56a325e_1 lxml 4.6.1 pypi_0 pypi lz4-c 1.9.2 hf4a77e7_3 matplotlib 3.3.2 0 matplotlib-base 3.3.2 py38hba9282a_0 mccabe 0.6.1 py38_1 mkl 2020.2 256 mkl-service 2.3.0 py38hb782905_0 mkl_fft 1.2.0 py38h45dec08_0 mkl_random 1.1.1 py38h47e9c7a_0 numpy 1.19.1 py38h5510c5b_0 numpy-base 1.19.1 py38ha3acd2a_0 olefile 0.46 py_0 openssl 1.1.1h he774522_0 pandas 1.1.3 py38ha925a31_0 pandas-datareader 0.9.0 pypi_0 pypi pillow 8.0.0 py38hca74424_0 pip 20.2.4 py38_0 pylint 2.6.0 py38_0 pyparsing 2.4.7 py_0 pyqt 5.9.2 py38ha925a31_4 python 3.8.5 h5fd99cc_1 python-dateutil 2.8.1 py_0 pytz 2020.1 py_0 qt 5.9.7 vc14h73c81de_0 requests 2.24.0 pypi_0 pypi setuptools 50.3.0 py38h9490d1a_1 sip 4.19.13 py38ha925a31_0 six 1.15.0 py_0 sqlite 3.33.0 h2a8f88b_0 tk 8.6.10 he774522_0 toml 0.10.1 py_0 tornado 6.0.4 py38he774522_1 urllib3 1.25.11 pypi_0 pypi vc 14.1 h0510ff6_4 vs2015_runtime 14.16.27012 hf0eaf9b_3 wheel 0.35.1 py_0 wincertstore 0.2 py38_0 wrapt 1.11.2 py38he774522_0 xz 5.2.5 h62dcd97_0 zlib 1.2.11 h62dcd97_4 zstd 1.4.5 h04227a9_0

timoschowski commented 3 years ago

If you change https://github.com/avelkoski/FRB/blob/692bcf576e17bd1a81db2b7644f4f61aeb39e5c7/fred/helpers/__init__.py#L55 to

frame = frame.convert_dtypes()

it works.

atadgib commented 3 years ago

If you change https://github.com/avelkoski/FRB/blob/692bcf576e17bd1a81db2b7644f4f61aeb39e5c7/fred/helpers/__init__.py#L55

to frame = frame.convert_dtypes()

it works.

Yup, that worked. Thanks Tim.