download.download_data_fred()
Download and process data from FRED.
Usage
download.download_data_fred(
series,
start_date=None,
end_date=None,
)Downloads a specified data series from the Federal Reserve Economic Data (FRED) website, processes the data, and returns it as a data frame. The function constructs the URL based on the provided FRED series ID, performs an HTTP GET request to download the data in CSV format, and processes it to a tidy data frame format. The resulting data frame includes the date, value, and the series ID.
Parameters
series: str or list of str-
A character vector specifying the FRED series ID(s) to download (e.g., ‘GDP’, [‘GDP’, ‘UNRATE’]).
start_date: str = None-
A character string or date in ‘YYYY-MM-DD’ format specifying the start date for the data. If not provided, the full dataset is returned.
end_date: str = None- A character string or date in ‘YYYY-MM-DD’ format specifying the end date for the data. If not provided, the full dataset is returned.
Returns
pl.DataFrame-
A data frame containing the processed data with three columns:
- ‘date’: the date corresponding to the data point.
- ‘series’: the FRED series ID corresponding to the data.
- ‘value’: the value of the data series at that date.
Examples
from tidyfinance import download_data_fred
download_data_fred('CPIAUCNS')
download_data_fred(['GDP', 'CPIAUCNS'], '2010-01-01', '2010-12-31')