You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement Phases 0-2: Census API, MOE, PUMS, and spatial support (#296)
* Implement Phases 0-2: Census API, MOE, PUMS, and spatial support
Adds the full Census API integration stack:
Phase 0 - Foundation:
- pypums/api/key.py: API key management via env vars
- pypums/api/geography.py: 21+ geography levels with FIPS resolution
- pypums/cache.py: file-based DataFrame caching with TTL
Phase 1 - Core data functions:
- pypums/acs.py: get_acs() with tidy/wide output, MOE scaling, summary vars
- pypums/decennial.py: get_decennial() for 2000/2010/2020 Census data
- pypums/variables.py: load_variables() for variable discovery
Phase 2 - MOE + Spatial + Enhanced PUMS:
- pypums/moe.py: moe_sum, moe_prop, moe_ratio, moe_product, significance
- pypums/pums.py: get_pums() via Census API with filtering, recoding, rep weights
- pypums/spatial.py: geometry=True support via TIGER/Line, as_dot_density()
All 87 tests pass (Phase 0 through Phase 2 + existing tests).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Adapt Phase 2 modules to use shared api.client from Phase 0/1
Use CENSUS_API_BASE and call_census_api from pypums.api.client
instead of inlining httpx calls. Keeps thin _call_census_api
wrappers in each module for test mockability.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Address all 11 PR review comments
- Fix multi-state silent data loss in get_pums (loop + concat)
- Add max_attempts guard to prevent infinite loop in as_dot_density
- Implement show_call parameter to print Census API URL/params
- Add division-by-zero guards in moe_ratio and moe_prop
- Calculate congress number dynamically instead of hardcoding
- Use ordered list for GEOID column concatenation in acs/decennial
- Accept survey parameter in get_acs (acs1/acs5)
- Add GEOID column existence check in attach_geometry
- Restrict clevel to supported values in significance()
- Document sparse PUMS recodes dictionary
- Normalize single-digit FIPS codes with zfill(2)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
0 commit comments