1

I was following this tutorial for requesting from the 2010 Decennial Census. It specifies the following code for printing a list of state names ("NAME"), state areas ("AREALAND"), and state total populations ("P001001"):

import requests


HOST = "https://api.census.gov/data"
year = "2010"
dataset = "dec/sf1"


base_url = "/".join([HOST, year, dataset])

predicates = {}


get_vars = ["NAME", "AREALAND", "P001001"]

predicates["get"] = ",".join(get_vars)


predicates["for"] = "state:*"

col_names = ["name", "total_pop", "state"]
r = requests.get(base_url, params = predicates)

print (r.text)

When I run the code I get the following error:

error: error: unknown variable 'AREALAND'

Looking at the 2010 Decennial Census Variable List I don't see 'AREALAND' listed. Has the API been changed since the tutorial was made, or am I making some other kind of error? The tutorial was published to YouTube on March 4th, 2020.

1

1 Answer 1

0

The variable for area used for 2010 data is "CSA".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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