Skip to content

Instantly share code, notes, and snippets.

@linanqiu
Last active January 30, 2016 01:42
Show Gist options
  • Save linanqiu/fdac66eea6f9513eac8b to your computer and use it in GitHub Desktop.
Save linanqiu/fdac66eea6f9513eac8b to your computer and use it in GitHub Desktop.
Census Population Query Usage
import census
# say we want to get the number of females asians between 40 and 45 in Ohio, presented by county
# instead of
census.query(
'name'=['PCT0120147', 'PCT0120148', 'PCT0120149', 'PCT0120150', 'PCT0120151']
'geo': {'state': 'OH', 'county': '*'})
# oh and the table will be retuned separately for 41 year olds, 42 year olds etc.
# we have
dataframe1 = census.Population(
'geo'={'state': 'OH', 'county': '*'},
'filter'={'sex': 'female', 'age': [40, 45], 'race': 'asian'})
# data will be returned in a single table
# another query!
dataframe2 = census.Population(
'geo'={'state': 'OH', 'county': '*'},
'filter'={'sex': 'female', 'age': [18], 'race': ['white', 'black'], 'hispanic-latino-origin': True})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment