Giter Site home page Giter Site logo

matt-saenz / pycps Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 42 KB

Load CPS microdata into a pandas DataFrame using the Census API

License: MIT License

Python 97.66% Shell 2.34%
census-api census-data current-population-survey python python-package

pycps's Introduction

PyCPS

Project Status: Active โ€“ The project has reached a stable, usable state and is being actively developed. Downloads

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

pycps's People

Contributors

matt-saenz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pycps's Issues

Number Query

I'm going to debug this further, but why when I include another column do I get 40000 more rows and also less unique values in one column?

print(get_asec(2023, ["HEFAMINC"]).shape)
print(get_asec(2023, ["HEFAMINC", "a_age"]).shape)

(88978, 1)
(146133, 2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.