lazy_fred is a Python library designed to simplify the process of collecting economic data from the Federal Reserve Economic Data (FRED) API. It automates searching for relevant series, filtering by frequency and popularity, and exporting the data into convenient CSV files.
- Automated Search: Searches FRED across various economic categories.
- Filtered Selection: Selects series based on popularity and frequency (daily, weekly, monthly).
- Error Handling: Includes retry mechanisms and logging for robust data collection.
- CSV Export: Saves the collected data in separate CSV files for easy analysis.
-
Clone the Repository:
git clone https://github.com/your-username/lazy_fred.git
-
Install Dependencies:
pip install -r requirements.txt
-
Obtain a FRED API Key:
- Visit the FRED website and get your free API key.
-
Configure Search Categories:
- Modify the
search_categories
list in the script to include the categories of interest. The defualt list of 30 items have been chosen from the structure of the FRED website navigation and some personal decisions.
- Modify the
-
Run the Script:
python lazy_fred.py
-
Output:
- The script will create three CSV files in your project directory:
filtered_series.csv
: Contains the search results from FRED cleaned to popularity over 50 and observation starts after 1900.daily_data.csv
: Contains daily time series data.monthly_data.csv
: Contains monthly time series data.weekly_data.csv
: Contains weekly time series data.
- The script will create three CSV files in your project directory:
-
AccessFred
Class:- Handles API key retrieval and validation.
-
collect_categories
Class:- Executes searches across categories and consolidates results.
-
daily_export
,monthly_export
, andweekly_export
Classes:- Filter series by frequency and popularity.
- Collect and export time series data.
The code has been packaged and can also be pip installed as
pip install lazy_fred
Make sure you are on the latest version (https://pypi.org/project/lazy_fred/).
The code is simple, create and instance and add your API key!
import lazy_fred as lf
lf.run_fred_data_collection("insert_api_key_here")
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.
This library is not affiliated with or endorsed by the Federal Reserve Bank of St. Louis or the FRED project.
- This project utilizes the
fredapi
andfred
libraries for interacting with the FRED API.
For any questions or feedback, please open an issue in the repository.