Appendix C — The pandas-datareader Package

The pandas-datareader package provides an interface to several different remote data sources, including FRED, AlphaVantage, etc.

C.1 FRED Data

FRED (Federal Reserve Economic Data) provides a wide range of economic datasets covering various aspects such as national accounts, labor markets, prices, interest rates, exchange rates, and more.

We can access FRED datasets directly in Python using the pandas_datareader package, as follows:

from pandas_datareader import get_data_fred

dataset_id = "GDP" # quarterly

#df = get_data_fred(dataset_id)
df = get_data_fred(dataset_id, start="2001-01-01", end="2023-01-01")
df.head()
GDP
DATE
2001-01-01 10470.231
2001-04-01 10599.000
2001-07-01 10598.020
2001-10-01 10660.465
2002-01-01 10783.500

The dataset identifier “GDP” corresponds with a given dataset on the FRED website.