datamade / census

A Python wrapper for the US Census API.
BSD 3-Clause "New" or "Revised" License
633 stars 137 forks source link

Raise unsupported geography if variable response returns null #29

Open fgregg opened 8 years ago

fgregg commented 8 years ago

If you request a variable that is not available at a specific geography, then the response return null. I think this should cause the query to raise a CensusException.

Example: Median monthly housing costs is available as the tract level http://api.census.gov/data/2014/acs5/?get=B25105_001E&for=tract:*&in=state:17%20county:001

but not at the block group level:

http://api.census.gov/data/2014/acs5/?get=B25105_001E&for=block%20group:*&in=state:17%20county:001%20tract:00100

If @jcarbaugh agrees, then I'll make a PR.

fgregg commented 8 years ago

There are other reasons, besides, excluded geographies why a variable would be suppressed and return null.

However, this spreadsheet lists the ~600 ACS variables that have geographic restrictions. We could use this as a check.

Personally, I would find it very useful to get an error message saying that a variable was not available at the geography I requested.