0

Looks like a range of ACS variables regarding housing are missing for the ACS:

B06013_001E

BO6013_002E

BO6013_003E

BO6013_004E

and others in this group as well.

What is one to do when they are missing? Contact the census? Look for updated variable names somewhere? Heres code to reproduce the problem:

import requests
import pandas as pd

HOST, dataset = "https://api.census.gov/data", "acs/acs1"

get_vars = ['B06013_001E']
get_vars = ["NAME"] + get_vars

print(get_vars)

predicates = {}
predicates["get"] = ",".join(get_vars)
predicates["for"] = ["state:37","county:37183"]

print(predicates)

for year in range(2005, 2018):
    try:
        base_url = "/".join([HOST, str(year), dataset])
        r = requests.get(base_url, params=predicates)
        df = pd.DataFrame(columns=r.json()[0], data=r.json()[1:])
    except ValueError:
        print('decoding JSON has failed')
0

While the Census modifies them as little as possible, the variable IDs in the ACS do change over time, as certain crosstabs can be dropped, others are added, and new variables are included. It's even possible that an ID can remain the same but the value associated with it can slightly change; for example categories that represent a range of dollar values may be adjusted over time to increase the range of a top-coded value, not frequently but possibly once within a ten year time frame.

With each ACS release they document what has changed since the previous one. For example, here are changes to the 1-year ACS in 2018.

In the API documentation, each iteration of a dataset is going to contain a description of that dataset, with links to geographies, variables, and examples. Here's a link to the 1-year 2018 series.

If you want to pull the variable list into your script, you can build up dictionaries of variables over time and determine how consistent they are and if / when they change. To grab the variables for one year, you can do something like this:

vars_url=f'https://api.census.gov/data/{year}/{dsource}/{dname}/variables.json'
response=requests.get(vars_url)

#"variables" is top key in the file - reference it to flatten the file so individual variables become keys 
variables=response.json()['variables']
variables

In choosing your tables, it's probably best to start with the present and work your way back. There were more changes in the early years of the ACS relative to later years.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.