{"id":23459,"library":"cpi","title":"cpi","description":"Quickly adjust U.S. dollars for inflation using the Consumer Price Index (CPI). Uses FRED data. Current version 2.0.10, actively maintained with regular data updates.","status":"active","version":"2.0.10","language":"python","source_language":"en","source_url":"https://github.com/palewire/cpi","tags":["inflation","CPI","economics","FRED","data"],"install":[{"cmd":"pip install cpi","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Fetch CPI data from FRED API","package":"requests","optional":false},{"reason":"Data handling and time series operations","package":"pandas","optional":true}],"imports":[{"note":"Direct import is the common pattern; avoid relying on module-level import for the function.","wrong":"import cpi; cpi.to_usd()","symbol":"cpi.to_usd","correct":"from cpi import to_usd"},{"note":"adjust is the recommended API; from cpi import adjust is cleaner.","wrong":"import cpi; cpi.adjust()","symbol":"adjust","correct":"from cpi import adjust"}],"quickstart":{"code":"from cpi import to_usd\nprint(to_usd(100, 1990, 2023))","lang":"python","description":"Adjust $100 from 1990 to 2023 dollars."},"warnings":[{"fix":"Use from cpi import adjust; adjust(100, 1990, 2023)","message":"cpi.to_usd() is deprecated in favor of adjust()","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"To adjust from 2020 to 2023, use to_usd(amount, 2020, 2023). It uses CPI data through 2022.","message":"Year ranges are inclusive for the start year; end year is exclusive (i.e., data up to but not including end year).","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure internet access on first use. Cache location: ~/.cpi/ on Linux/macOS.","message":"First run downloads CPI data from FRED; requires internet. Subsequent runs use a local cache.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install cpi' or verify environment.","cause":"Library not installed or installed in wrong Python environment.","error":"ModuleNotFoundError: No module named 'cpi'"},{"fix":"Check that the input year is >= 1913 and <= current year+1.","cause":"Year outside available data range (usually 1913 onward).","error":"cpi.exceptions.CPINotFoundError: No CPI data found for 1990"},{"fix":"Use 'from cpi import adjust' instead of 'import cpi; cpi.to_usd()'.","cause":"Old import style used with newer version where function removed or renamed.","error":"AttributeError: module 'cpi' has no attribute 'to_usd'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}