A Python library for retrieving, storing, and analyzing PPI data.
Project description
PPI Toolkit
A Python library for retrieving, storing, and analyzing Producer Price Index (PPI) data from the U.S. Bureau of Labor Statistics (BLS). The library supports:
- Downloading BLS PPI metadata and current commodity data
- Storing the data in a local SQLite database
- Searching PPI data series by fuzzy matching or direct lookups
- Computing annualized percentage changes (1-month, 3-month, 6-month, and 12-month horizons)
Features
-
Automated Data Ingestion
Fetch metadata and commodity data directly from the BLS text files, then store them in a local SQLite database. -
Clean, Well-Structured Database
metadatatable for series information (e.g.series_id,group_code,series_title, etc.)commoditiestable for monthly observations (year,period,value, etc.)
-
Fuzzy Text Search
Quickly locate series by approximate matching on their titles. -
Annualized Changes Calculation
Compute monthly annualized percentage changes over 1-, 3-, 6-, and 12-month intervals. -
Easy Plotting Hooks (Optional)
Integration points for generating charts usingmatplotlib,plotly, etc.
Quickstart
Below is a minimal example of how to install and use the library:
1. Install the Library
pip install ppi-toolkit
2. Set up the database
from ppi_toolkit.database import PPIDataBase
db = PPIDataBase()
db.setup_and_import_data()
- Search for a series
from ppi_toolkit.search import PPISearcher
searcher = PPISearcher() # Uses ~/ppi.db by default
results = searcher.search_titles("steel scrap")
for match in results:
print(match)
# Example output: {'series_id': 'WPS101211', 'series_title': 'Carbon steel scrap', 'score': 90}
- Join and analyze data
from ppi_toolkit.joiner import PPIJoiner
from ppi_toolkit.analyzer import PPIAnalyzer
# 1. Join data from both tables
joiner = PPIJoiner()
df_joined = joiner.get_joined_data("WPS011101")
print(df_joined.head())
# 2. Compute annualized changes
analyzer = PPIAnalyzer()
df_trends = analyzer.compute_annualized_changes("WPS011101", 2018, 1, 2023, 12)
print(df_trends[["date", "value", "ann_1m", "ann_3m", "ann_6m", "ann_12m"]].tail())
- Plot Data
from ppi_toolkit.plotting import plot_annualized_trends
df_trends = analyzer.compute_annualized_changes(
series_id="WPS011101",
start_year=2018, start_month=1,
end_year=2023, end_month=6
)
# 2. Plot the results
plot_annualized_trends(
df_trends,
series_title="Iron and Steel Scrap",
save_path="steel_scrap.png"
)
License
This project is released under the MIT License. Feel free to use and modify it in personal or commercial projects, respecting the license terms.
Acknowledgements
- Data provided courtesy of the Bureau of Labor Statistics Producer Price Index.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ppi_toolkit-0.2.1.tar.gz.
File metadata
- Download URL: ppi_toolkit-0.2.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00daf3da2b1b00521f114aade8ed9c926398370e00e23aef6d60398287966508
|
|
| MD5 |
8e3deb54273a652c78023f3d0765f3c6
|
|
| BLAKE2b-256 |
2bffb2082369d8bb48d7377a96d5a6c96bc6a73777809aaa382848fba0a4049a
|
File details
Details for the file ppi_toolkit-0.2.1-py3-none-any.whl.
File metadata
- Download URL: ppi_toolkit-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a966c6c99aeab19c1b18d33952078ea28ee421378f3b8f8c9dab45d261846ed
|
|
| MD5 |
8e66887cad29cd0cb7c8a874bd150239
|
|
| BLAKE2b-256 |
8c4fc31389ac916a26d99e1bf71a8ffeeb959026565f3511796c772ee9963242
|