Lightweight Python package for exploring and acquiring U.S. Census data with spatial integration
Project description
pycen
Lightweight Python package for exploring and acquiring U.S. Census data with intuitive spatial integration.
flowchart TD
A[Need Census data?]
A --> B & C
subgraph PYCEN["<i>pycen</i>"]
direction TB
B[<b>`explore`</b><br/>Intuitive metadata<br/>keyword search]
C[<b>`acquire`</b><br/>Data + boundaries<br/>in one call]
C --> D
C --> E
D[<b>`quick_check`</b><br/>Quality validation]
E[<b>`quick_viz`</b><br/>Instant maps]
end
B --> F
D & E --> F[Domain analysis]
style A fill:#94a3b8,stroke:#334155,stroke-width:2px,color:#000
style B fill:#3b82f6,stroke:#1e40af,stroke-width:2px,color:#fff
style C fill:#3b82f6,stroke:#1e40af,stroke-width:2px,color:#fff
style D fill:#22c55e,stroke:#15803d,stroke-width:2px,color:#fff
style E fill:#22c55e,stroke:#15803d,stroke-width:2px,color:#fff
style F fill:#94a3b8,stroke:#334155,stroke-width:2px,color:#000
style PYCEN fill:#1e293b,stroke:#64748b,stroke-width:2px,color:#fff
overview
pycen makes the exploration and acquisition of U.S. Census data accessible and intuitive for spatial data scientists. It presents Census API metadata as collapsible, interactive tree tables organized by topics. Built-in and customizable themes highlight curated variable combinations based on domain knowledge, making complex variable hierarchies easy to navigate. Spatial workflows are streamlined: one function call returns both data and boundaries as a GeoDataFrame, with separate tabular and spatial downloads available. Multi-year data fetch and longitudinal comparisons are also supported.
sample use
# basic workflow
import pycen
from pycen import explore, acquire
# 1. Explore variables
explore.search("income", year=2021, dataset="acs5").show()
explore.lookup("B19013_001E", year=2021, dataset="acs5")
# 2. Acquire data
gdf = acquire.get_censhp(
variables=["B19013_001E", "B01003_001E"],
geography="tract",
state="CA",
county="Alameda",
year=2021,
)
acquire.quick_viz(gdf, "B19013_001E")
core functions
Explore
explore.search(query, year, dataset)- supports exact term match and fuzzy keyword searchexplore.browse(year, dataset)- view all variables via interactive tree table with theme variable highlightsexplore.lookup(code, year, dataset)- inspect variable details
Acquire
acquire.get_censhp(...)- data + boundaries --> GeoDataFrameacquire.get_census(...)- data only --> DataFrameacquire.get_boundaries(...)- boundaries only --> shp/gpkgacquire.quick_check(gdf)- N/A values summaryacquire.quick_viz(gdf, column)- exploratory map + distribution histogram for select variable
Info
pycen.get_product()- list datasets and yearspycen.get_geography()- list geography levels by dataset
Notes
- Datasets:
acs5,acs1,dec_pl,dec_sf1 - Spatial features require:
geopandas,pygris
API key for higher rate limits:
pycen.set_api_key("YOUR_KEY") # get key at api.census.gov/data/key_signup.html
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 pycen-0.1.0a1.tar.gz.
File metadata
- Download URL: pycen-0.1.0a1.tar.gz
- Upload date:
- Size: 60.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39c345dd47dd8d5147993b693fe307dae7febaa449b2495295ae977eff62fa5e
|
|
| MD5 |
acbba13cb8b5c1f9a89bd44bc68c3e54
|
|
| BLAKE2b-256 |
50f3574cc25740dc3f2c2088c49592e6c413479940eb17871e967a88c947bab4
|
File details
Details for the file pycen-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: pycen-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 62.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fbef947cfb8f6e997898841fbe7e201d25c73ca80603d8e13a8d0d9b7d0df5f
|
|
| MD5 |
cd5c713090111b3d5ac8d09db1dbb9e0
|
|
| BLAKE2b-256 |
21640ddb3fde9a8d60818b514c3ad08835170268ec6befebc867296f0f9fc3db
|