Vote up to Idea gender by zip code Vote down to Idea gender by zip code

Rank146

Idea#97

This idea is active.
Using Data »

gender by zip code

I'm attempting to write some Python code to retrieve this information. I only have a little experience with APIs, and I'm kind of lost.

import requests

query_params = { 'apikey': 'mykey',

'place': , #would like to select all

'state': # would like to select all

#probably need one for ZCTAs?

}

# PO120001 - PO120049 all sex by age categories

# not sure how to request them

endpoint = 'http://api.census.gov/data/2010/sf1' # this is probably wrong

response = requests.get(endpoint, params=query_params)

data = response.json # i think

Has anyone done anything like this? Is Python the wrong way to be doing it?

Thanks

Comment

Submitted by Community Member 1 year ago

Vote Activity

  1. Approved
    1 year ago
  2. Disapproved
    1 year ago

Events

  1. The idea was posted
    1 year ago

Comments (3)

  1. Moderator

    Not sure if you've seen this, but the guys at Sunlight labs made a python wrapper for calling the API:

    https://pypi.python.org/pypi/census/0.5

    Cheers!

    1 year ago
    1. Community Member Idea Submitter

      Sweet, thank you. I'll check this out.

      1 year ago
  2. I posted a dissected query in this topic as well, so you can manually test your queries to make sure you get back what you're expecting to get back.

    http://apiforum.ideascale.com/a/dtd/Polygon-block-group-and-census-data/419235-18378

    1 year ago