Python interface to the US Census Bureau API for ACS, Decennial Census, PUMS, population estimates, and migration flows.
Project description
PyPUMS
Python interface to the US Census Bureau API — American Community Survey, Decennial Census, PUMS microdata, population estimates, and migration flows.
Quick Start
Get county-level median household income for California:
import pypums
df = pypums.get_acs(
geography="county",
variables=["B19013_001"],
state="CA",
year=2023,
)
df.head()
Make a map with tract-level data:
df = pypums.get_acs(
geography="tract",
variables=["B19013_001"],
state="CA",
county="037",
year=2023,
geometry=True, # returns a GeoDataFrame
)
df.plot(column="estimate", legend=True, figsize=(12, 8))
Work with PUMS microdata:
pums = pypums.get_pums(
variables=["AGEP", "SEX", "WAGP"],
state="CA",
year=2023,
recode=True, # adds human-readable labels
)
pums.head()
Features
get_acs()— American Community Survey data (1-year and 5-year)get_decennial()— Decennial Census data (2000, 2010, 2020)get_pums()— PUMS microdata with replicate weight supportget_estimates()— Population Estimates Program dataget_flows()— ACS migration flows (county and MSA level)load_variables()— Search and browse Census variable codes- MOE functions —
moe_sum(),moe_ratio(),moe_prop(),moe_product(),significance() - Spatial support — Attach TIGER/Line geometries, returns GeoDataFrames
- Survey design —
SurveyDesignclass with successive difference replication - Caching — File-based caching with configurable TTL
- CLI — Command-line access to all data functions
Installation
uv add pypums
For spatial/mapping support:
uv add "pypums[spatial]"
Census API Key
You need a free Census API key. Request one here, then:
export CENSUS_API_KEY="your-key-here"
Or set it in Python:
import pypums
pypums.census_api_key("your-key-here")
Documentation
Full documentation: https://pypums.readthedocs.io
Development
To contribute to this library, first checkout the code. Then install uv and set up the project:
cd pypums
uv sync --extra test
To run the tests:
uv run pytest
To run the linter:
uvx ruff check .
uvx ruff format --check .
Citation
@misc{pypums,
author = {Sergio Sanchez Zavala},
title = {PyPUMS: Python interface to the US Census Bureau API},
year = {2019},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/chekos/pypums}}
}
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 pypums-0.3.1.tar.gz.
File metadata
- Download URL: pypums-0.3.1.tar.gz
- Upload date:
- Size: 54.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b9ae21e8063dab3b7a99f7c5dff0d859690b66350277015a073ae111a54d6c6
|
|
| MD5 |
7524b00e73876253ec4516e1a08b4134
|
|
| BLAKE2b-256 |
7c94d378be6cd24d145dcdd42efbd4aa1aa493bfde1b3045fb37bfff7be893cd
|
Provenance
The following attestation bundles were made for pypums-0.3.1.tar.gz:
Publisher:
publish.yml on chekos/pypums
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypums-0.3.1.tar.gz -
Subject digest:
8b9ae21e8063dab3b7a99f7c5dff0d859690b66350277015a073ae111a54d6c6 - Sigstore transparency entry: 1097006145
- Sigstore integration time:
-
Permalink:
chekos/pypums@966ce5073ebc2b6cdbc47074364d44f3944606a5 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/chekos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@966ce5073ebc2b6cdbc47074364d44f3944606a5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pypums-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pypums-0.3.1-py3-none-any.whl
- Upload date:
- Size: 65.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
811ddb444d762baea61833ff786c70c182480a5a6fcba66d314a6f378fe1d587
|
|
| MD5 |
521fa2d4b1d6193376d773d05b652c79
|
|
| BLAKE2b-256 |
59ec2bfd94432dad8f2a3fbbb06674483e842974dcaa72adfc9487e52e338589
|
Provenance
The following attestation bundles were made for pypums-0.3.1-py3-none-any.whl:
Publisher:
publish.yml on chekos/pypums
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypums-0.3.1-py3-none-any.whl -
Subject digest:
811ddb444d762baea61833ff786c70c182480a5a6fcba66d314a6f378fe1d587 - Sigstore transparency entry: 1097006146
- Sigstore integration time:
-
Permalink:
chekos/pypums@966ce5073ebc2b6cdbc47074364d44f3944606a5 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/chekos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@966ce5073ebc2b6cdbc47074364d44f3944606a5 -
Trigger Event:
release
-
Statement type: