census icon indicating copy to clipboard operation
census copied to clipboard

How to get population by zip code?

Open ratchetwrench opened this issue 5 years ago • 8 comments

I am trying to query the population by zip code, but I am not sure how to approach it with this library.

ratchetwrench avatar May 10 '19 23:05 ratchetwrench

Have you tried the acs5.zipcode method? The variable for total population is B01003_001E, so you should be able to make calls like this (with zip code 60608):

>>> c.acs5.zipcode('B01003_001E', 60608)
[{'B01003_001E': 78877.0, 'zip code tabulation area': '60608'}]

jeancochrane avatar May 12 '19 02:05 jeancochrane

@jeancochrane : I am looking to do the same thing, however for my application, I need ACS1, do you know if there is way to get this data for acs1 ? I don't see a zipcode method for acs1, so I am looking at alternatives.

UGuntupalli avatar Jun 09 '20 04:06 UGuntupalli

@UGuntupalli I don't think zip code tabulation areas are an available geography for ACS1, see: https://www.census.gov/programs-surveys/geography/guidance/geo-areas/zctas.html#ti129385160 My understanding is that ACS1 doesn't have a large enough sample size to accurately reflect that level of geographic resolution, but I'm not an expert. Here's a comparison of different yearly estimates: https://www.census.gov/programs-surveys/acs/guidance/estimates.html

jeancochrane avatar Jun 09 '20 14:06 jeancochrane

@jeancochrane , Thank you for pointing me to that resource. For the problem I am trying to solve, a reasonable estimate and an approximation of level of change is sufficient. I am not really bothered about the precision, so if there is a way to do it with ACS1 that would be great. Thank you for clarifying that zip code tabulation is not available. I opened a new issue to see if county level query can be run. (#91)

UGuntupalli avatar Jun 09 '20 15:06 UGuntupalli

As an alternative, you might try https://github.com/datamade/census_area, which extends this library to let you query by arbitrary geographies (you could use a GeoJSON of the zip codes you care about). The precision of the estimate will probably be misleading but if you don't care so much about that it might work for you.

jeancochrane avatar Jun 09 '20 15:06 jeancochrane

Hm, I seem to be getting an error now using c.acs5.zipcode, when I run the above I get:

c.acs5.zipcode('B01003_001E', 60608)
CensusException: error: ambiguous geography "zip code tabulation area:60608". You must either specify a wildcard or full qualify it with state

Not sure what this means?

VincentLa avatar Mar 18 '21 02:03 VincentLa

@VincentLa While I couldn't get it to work as it's meant to. I have been able to pull the needed data by passing zcta = '*' into the function. It will return a list of dictionaries (one for each zip code). Not ideal, but you can loop through it and pull the data for your zip code of interest

MikeLeahy24 avatar Dec 06 '21 20:12 MikeLeahy24

@UGuntupalli , were you able to figure out anyway to get ACS1 estimates?

nish-08 avatar Jan 09 '23 17:01 nish-08