All Projects → cenpy-devs → Cenpy

cenpy-devs / Cenpy

Licence: other
Explore and download data from Census APIs

Projects that are alternatives of or similar to Cenpy

Face Id With Medical Masks
Face ID recognition with medical masks
Stars: ✭ 103 (-0.96%)
Mutual labels:  jupyter-notebook
Yabox
Yet another black-box optimization library for Python
Stars: ✭ 103 (-0.96%)
Mutual labels:  jupyter-notebook
Python Fundamentals
Introductory Python Series for UC Berkeley's D-Lab
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Intro To Deep Learning
A collection of materials to help you learn about deep learning
Stars: ✭ 103 (-0.96%)
Mutual labels:  jupyter-notebook
Pose Interpreter Networks
Real-Time Object Pose Estimation with Pose Interpreter Networks (IROS 2018)
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Dmm
Deep Markov Models
Stars: ✭ 103 (-0.96%)
Mutual labels:  jupyter-notebook
Fma
FMA: A Dataset For Music Analysis
Stars: ✭ 1,391 (+1237.5%)
Mutual labels:  jupyter-notebook
Team Learning
主要展示Datawhale的组队学习计划。
Stars: ✭ 1,397 (+1243.27%)
Mutual labels:  jupyter-notebook
Practical Ml W Python
Source code for 'Practical Machine Learning with Python' by Dipanjan Sarkar, Raghav Bali, and Tushar Sharma
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Partia Computing Michaelmas
Activities and exercises for the Part IA computing course in Michaelmas Term
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Ec2 Spot Workshops
Collection of workshops to demonstrate best practices in using Amazon EC2 Spot Instances. https://aws.amazon.com/ec2/spot/
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Boxdetection
A Box detection algorithm for any image containing boxes.
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Sharing isl python
An Introduction to Statistical Learning with Applications in PYTHON
Stars: ✭ 105 (+0.96%)
Mutual labels:  jupyter-notebook
Solution Accelerator Many Models
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Satimg
Satellite data processing experiments
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Nlp essentials
Essential and Fundametal aspects of Natural Language Processing with hands-on examples and case-studies
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Ossdc Visionbasedacc
Discuss requirments and develop code for #1-mvp-vbacc MVP (see also this channel on ossdc.org Slack)
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Tensorflow2.0 Examples
🙄 Difficult algorithm, Simple code.
Stars: ✭ 1,397 (+1243.27%)
Mutual labels:  jupyter-notebook
Keras Hello World
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook
Circle Line Analytics
Stars: ✭ 104 (+0%)
Mutual labels:  jupyter-notebook

CenPy

.. image:: https://img.shields.io/static/v1.svg?label=documentation&message=latest&color=blueviolet :target: https://cenpy-devs.github.io/cenpy .. image:: https://travis-ci.org/cenpy-devs/cenpy.svg?branch=master :target: https://travis-ci.org/cenpy-devs/cenpy .. image:: https://img.shields.io/pypi/dm/cenpy.svg :target: https://pypi.org/project/cenpy/ .. image:: https://zenodo.org/badge/36956226.svg :target: https://zenodo.org/badge/latestdoi/36956226 .. image:: https://img.shields.io/badge/Census%20Slack--lightgrey.svg :target: https://uscensusbureau.slack.com/messages/C8Y5PUE4D

An interface to explore and query the US Census API and return Pandas Dataframes. This package is intended for exploratory data analysis and draws inspiration from sqlalchemy-like interfaces and acs.R. With separate APIs for application developers and folks who only want to get their data quickly & painlessly, cenpy should meet the needs of most who aim to get US Census Data from Python.

A few examples are available from our website <https://cenpy-devs.github.io/cenpy>__:

  • getting data quickly using Cenpy <https://nbviewer.jupyter.org/github/cenpy-devs/cenpy/blob/master/notebooks/product-api.ipynb>__.
  • analyzing segregation over time & across space using cenpy and segregation <https://nbviewer.jupyter.org/github/cenpy-devs/cenpy/blob/master/notebooks/segregation.ipynb>__
  • a road to frictionless urban data science using cenpy and osmnx <https://nbviewer.jupyter.org/github/cenpy-devs/cenpy/blob/master/notebooks/osmnx-and-cenpy.ipynb>__
  • developer building blocks <http://nbviewer.ipython.org/github/cenpy-devs/cenpy/blob/master/notebooks/automatic-wrapper.ipynb>__.
  • piecing together the developer building blocks (by @dfolch) <https://nbviewer.jupyter.org/gist/dfolch/2440ba28c2ddf5192ad7>__

Installation

Cenpy is easiest to install using conda, a commonly-used package manager for scientific python. First, install Anaconda <https://www.anaconda.com/distribution/>__.

Then, cenpy is available on the conda-forge channel: ::

conda install -c conda-forge cenpy

Alternatively, you can install cenpy via pip, the python package manager, if you have installed geopandas and rtree: ::

pip install cenpy

For Users

Most of the time, users want a simple and direct interface to the US Census Bureau's main products: the 2010 Census and the American Community Survey. Fortunately, cenpy provides a direct interface to these products. For instance, the American Community Survey's most recent 5-year estimates can be accessed using:

::

import cenpy
acs = cenpy.products.ACS()
acs.from_place('Chicago, IL')

Likewise, the decennial census can be accessed using:

::

import cenpy
decennial = cenpy.products.Decennial2010()
decennial.from_place('Seattle, WA')

For more information on how the product API works, consult the notebook on the topic <https://nbviewer.jupyter.org/github/cenpy-devs/cenpy/blob/master/notebooks/product-api.ipynb>__.

For Developers

The API reference is available at cenpy-devs.github.io/cenpy <https://cenpy-devs.github.io/cenpy>__. The products are typically what most end-users will want to interact with. If you want more fine-grained access to the USCB APIs, you will likely want to build on top of APIConnection and TigerConnection.

At a high level, the APIConnection object connects to resources exposed on the US Census Bureau's API at https://api.census.gov/data.json. Its methods and relevant utilities are defined in cenpy.remote. The TigerConnection wraps one map service exposed at http://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb and is defined in cenpy.tiger. Each TigerConnection is composed of many ESRILayer objects, which wrap an individual geography within the ESRI map service. For instance, an ACS TigerConnection may contain State, County, and Tract ESRILayer objects within their layer attribute.

To use the developer-focused API, you can create an APIConnection using its shortcode:

::

cxn = cenpy.remote.APIConnection('DECENNIALSF12010')

Check the variables required and geographies supported:

::

cxn.variables #is a pandas dataframe containing query-able vbls
cxn.geographies #is a pandas dataframe containing query-able geographies

Note that some geographies (like tract) have requirements higher in the hierarchy that you'll have to specify for the query to work.

The structure of the query function maps to the Census API's use of get, for, and in. The main arguments for the query function are cols, geo_unit and geo_filter, and map back to those predicates, respectively. If more predicates are required for the search, they can be added as keyword arguments at the end of the query.

The cols argument must be a list of columns to retrieve from the dataset. Then, you must specify the geo_unit and geo_filter, which provide what the unit of aggregation should be and where the units should be. geo_unit must be a string containing the unit of analysis and an identifier. For instance, if you want all counties in Arizona, you specify geo_unit = 'county:*' and geo_filter = {'state':'04'}.

To create a TigerConnection:

::

cxn = cenpy.tiger.TigerConnection('tigerWMS_ACS2013')

Then, all of the ESRILayer objects are contained in the layer attribute:

::

cxn.layers

the cxn.query method passes the relevant query down to the chosen layer and returns a geopandas dataframe. The actual query is structured like SQL, and follows the ESRI documentation. <https://tigerweb.geo.census.gov/arcgis/sdk/rest/index.html#//02ss0000006v000000>__

Contributing

To contribute to cenpy:

  1. Use cenpy! Every user is a contributor in kind. If you feel like it, file an issue <https://help.github.com/en/articles/github-glossary#issue>__:

    • to tell us how you use cenpy.
    • to post a code snippit, a jupyter notebook, or whatever you can.
    • to tell us about your blog posts! <https://medium.com/@mswhitetoyou/scraping-us-census-data-via-cenpy-9aeab12c877e>__
    • to ask questions about how you might use census data from Python, and we'll try to help.
  2. If you're using cenpy and something goes wrong, file an issue <https://help.github.com/en/articles/github-glossary#issue>__ telling us:

    • what you want that is not in cenpy or doesn't work well in other packages
    • what functionality in cenpy isn't working how you believe it ought
    • what in the documentation isn't spelled correctly or is confusing
  3. Fork <https://help.github.com/en/articles/github-glossary#fork>__ the cenpy-devs/cenpy github repository, make changes, and send us a pull request <https://help.github.com/en/articles/github-glossary#pull-request>__

ToDo:

  • A product in cenpy.products for County Business Statistics
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].