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"])
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-1.0.1.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file pycpsdata-1.0.1.tar.gz
.
File metadata
- Download URL: pycpsdata-1.0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a6e218866c0d469254773c55c1102abf27451c88fad280e7bf85b043b51d7d8 |
|
MD5 | c3b9567b0f93e24cc3ff016d39e09f14 |
|
BLAKE2b-256 | 36a2038735288504b76973e11f99f64abc36505669954d819c0076b0cb6be807 |
File details
Details for the file pycpsdata-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pycpsdata-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6638be027b56c9eeedfe0427163531f60117fb4f069c3a72a20553a95723b75a |
|
MD5 | 0f79b74cf7626bec9b7ed2cb897af656 |
|
BLAKE2b-256 | 4b3af5e56e70c7b6070b68adc3e4353a92c45cd7aceee18d41c8a87dced242e3 |