FRED API and Python
Connecting to the Federal Reserve Datasets
#Install the FRED API
pip install fredapi
#Import panda
import pandas as pd
#Import matplotlib
import matplotlib.pyplot as plt
#Import FRED
from fredapi import Fred
#Add your FRED Private Key
Get John Smith LLM’s stories in your inbox
Join Medium for free to get updates from this writer.
fred=Fred(api_key=’abcdefghijklmnopqrstuvwxyz’)
#Load a Fred dataset (ex GDP)
data=fred.get_series(‘GDP’)
#To see the top 5 of the GDP dataset
data.head()
#To see the last 5 of the GDP dataset
data.tail()
#To get an observation for start and end
data = fred.get_series(‘GDP’, observation_start=’2019', observation_end = ‘2020’)







