Load CPS microdata into a pandas DataFrame using the Census API.
Project description
PyCPS
Overview
Python package for loading Current Population Survey (CPS) microdata into a pandas DataFrame using the Census Bureau Data API, including basic monthly CPS and CPS ASEC microdata.
Note: This product uses the Census Bureau Data API but is not endorsed or certified by the Census Bureau.
For an R version of this package, check out cpsR.
Setup Instructions
Install the package:
pip install pycpsdata # Alas, pycps was taken
and store your Census API key in an environment variable named CENSUS_API_KEY
.
Example Usage
from pycps import get_asec
asec = get_asec(2021, ["a_age", "marsupwt"])
# Getting CPS ASEC microdata for 2021
asec
# a_age marsupwt
# 0 56 687.71
# 1 57 687.71
# 2 78 646.86
# 3 65 1516.95
# 4 66 1516.95
# ... ... ...
# 163538 69 514.11
# 163539 70 516.25
# 163540 66 516.25
# 163541 55 386.37
# 163542 52 386.37
#
# [163543 rows x 2 columns]
asec.marsupwt.sum()
# 326195439.67
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycpsdata-0.1.0.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for pycpsdata-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be210de29173c502613c8aa72751866b09f9b3449ebb9c4decd74e1846ea611d |
|
MD5 | 119f0b32b386860ea961cc9cf9eed279 |
|
BLAKE2b-256 | 949e6eda8493478eb83d2c50278280a6bd6f016554e11da53e4bf4dbc0bdccb8 |