datamade / census

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

acs5.state_county_blockgroup error #79

Closed capGrundy closed 4 years ago

capGrundy commented 4 years ago

Exception Value: | error: unknown/unsupported geography heirarchy census\core.py in query, line 200 I'm not up to speed in python to try to troubleshoot, but the problem may be in the call, where according to the Census API, you are missing tract in that call:

https://api.census.gov/data/2017/acs/acs5/examples.html state› county› tract› block group

Your command: state_county_tract(fields, state_fips, county_fips, tract)

capGrundy commented 4 years ago

If you need a dataset to test 08>001>008542>2054

semcogli commented 4 years ago

A BG query without tract ID is valid when searching for all BGs. Like this https://api.census.gov/data/2017/acs/acs5?get=NAME,B01001_001E&for=block%20group:*&in=state:01%20county:025

However, if you need to query a particular tract, you have to supply a tract ID. something like this c.acs5.get(('NAME', 'B00001_001E'),geo={'for':'block group:1', 'in':'state:01 county:025 tract:957602'} )

capGrundy commented 4 years ago

I meant to include this command: state_county_blockgroup(fields, state_fips, county_fips, blockgroup)

Your get statement works, but the following: out_result = c.acs5.state_county_blockgroup(('NAME', 'B01003_001E'), '01', '025', '1')

Returns: error: ambiguous geography "block group:1". You must either specify a wildcard or full qualify it with tract

semcogli commented 4 years ago

in your case, you need to specify a tract id. c.acs5.state_county_blockgroup(('NAME', 'B01003_001E'), '01', '025','1', '957602')

the call will work without track id when you need to grab all block groups c.acs5.state_county_blockgroup(('NAME', 'B01003_001E'), '01', '025', '*')

hope this helps.

capGrundy commented 4 years ago

That did it. I had some malformed codes, and the way it's written in the readme file was missing the tratiling tract value, and I was following it literally.

Thank you and your help, and thanks for a quality app.