So, I was attempting to grab USD/CNY rates from FRED using Pandas with the following code I found on another stack exchange post:
import pandas.io.data as web
cny = wb.get_data_fred('DEXCHUS')
However I got an error-
ImportError: The pandas.io.data module is moved to a separate package (pandas-datareader). After installing the pandas-datareader package (https://github.com/pydata/pandas-datareader), you can change the import ``from pandas.io import data, wb`` to ``from pandas_datareader import data, wb``.
I followed the GitHub instructions to install pandas-datareader and then changed to from pandas.io import data, wb
then when I try to run my code I get an error that the module has no get_data_fred
.
How can I use the updated package to get the FRED data?
There are a few different ways to get the FRED data. For the generic
DataReader
call, try (using version 0.5.0):Or, more similar to the syntax you had previously:
The
data.get_data_fred
method just returns the following, which provides a third way to get your data:All results should be identical, however I prefer the more general first call myself.