Skip to content

Instantly share code, notes, and snippets.

@Sven-Bo
Created April 5, 2023 19:06
This Python script downloads key economic indicators, such as GDP, Unemployment Rate, Consumer Price Index, and Federal Funds Rate, from the FRED (Federal Reserve Economic Data) database using the pandas-datareader library. The data is then exported to an Excel file named 'economic_calendar.xlsx'. The user can customize the date range and econom…
import pandas_datareader as pdr # pip install pandas-datareader
import pandas as pd
start = "2020-01-01"
end = "2020-07-31"
# List of FRED codes for economic indicators
economic_indicators = {
"GDP": "GDP",
"Unemployment Rate": "UNRATE",
"Consumer Price Index": "CPIAUCSL",
"Federal Funds Rate": "FEDFUNDS",
}
# Download economic indicator data
df_economic = pd.DataFrame()
for name, code in economic_indicators.items():
df_economic[name] = pdr.get_data_fred(code, start, end)
# Export to Excel
df_economic.to_excel('economic_calendar.xlsx')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment