API reference¶
Full reference for the calcfidata Python package. Generated from in-source docstrings using mkdocstrings.
calcfidata
¶
calcfidata — Python client for CalcFi Open Data.
34 free CC-BY financial and macroeconomic time series mirrored from primary sources (FRED, BLS, Freddie Mac, US Treasury, BEA, World Bank). Lazy-loaded from the Hugging Face dataset mirror so users only download what they need.
Quick start:
>>> import calcfidata as cf
>>> df = cf.load("30-year-fixed")
>>> df.tail()
date value unit
2607 2026-05-15 6.95 percent
>>> series = cf.list_series()
>>> series.head()
slug title row_count
0 30-year-fixed 30-Year Fixed Mortgage Rate 2607
1 15-year-fixed 15-Year Fixed Mortgage Rate 1812
Citation: Salmisto, J. (2026). CalcFi Open Data: 34 Free CC-BY Financial and Macro Time Series Mirrored from Primary Sources [Dataset]. Figshare. https://doi.org/10.6084/m9.figshare.32332290
load(slug)
cached
¶
Load a single CalcFi Open Data series by slug.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slug
|
str
|
Series identifier (e.g. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Columns: |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If the slug is unknown (the underlying CSV returns 404). |
Examples:
Source code in python/calcfidata/client.py
list_series()
cached
¶
Return the full catalog of available series.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Columns: |
Examples:
Source code in python/calcfidata/client.py
metadata(slug)
cached
¶
Return the Frictionless datapackage.json metadata for a series.
Includes the primary-source URL, the canonical CalcFi page, the license, keywords, and the schema for the CSV.
Examples:
Source code in python/calcfidata/client.py
multi(slugs, align_on='outer')
¶
Load multiple series and join them into a single wide DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slugs
|
iterable of str
|
Series identifiers. |
required |
align_on
|
('outer', 'inner', 'left')
|
Pandas merge |
"outer"
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Indexed on |
Examples:
Source code in python/calcfidata/client.py
Module constants¶
The package exposes a few module-level constants you can use to construct URLs without hard-coding:
| Name | Description |
|---|---|
calcfidata.DATASET_URL |
Canonical Hugging Face dataset page |
calcfidata.HF_BASE |
Base URL for resolving series CSV/JSON files |
calcfidata.__version__ |
Installed package version |
calcfidata.__doi__ |
Permanent Figshare DOI of the underlying dataset |
calcfidata.__orcid__ |
Author ORCID iD |
Error handling¶
calcfidata.load(slug) raises requests.HTTPError if the slug is unknown — the underlying CSV returns a 404 from Hugging Face. Wrap calls in try/except if you're loading from a user-supplied slug list:
import requests
import calcfidata as cf
try:
df = cf.load(user_input)
except requests.HTTPError:
print(f"Series '{user_input}' not found. See cf.list_series() for valid slugs.")
Threading¶
The internal requests.get calls are not protected by a lock, but functools.lru_cache is thread-safe in CPython. You can call cf.load() concurrently from multiple threads — duplicate network requests for the same slug may fire if the cache is cold, but the result is consistent.
Versioning¶
calcfidata follows Semantic Versioning. The data schema is part of the contract: changes to column names or types require a major version bump. New series are additive (minor bump). Bug fixes and provenance-comment improvements are patch bumps.
See the changelog for release notes.