So, this is my first time using the Census API (or any API at all), and I have had some amount of luck so far. Rather than using the census package or cenpy, I have just been creating the URL's by hand since it is not that difficult.
For example, the following successfully gets me the number of people who speak different languages by state and congressional district.
This Works:
import requests
import pandas as pd
r = requests.get('https://api.census.gov/data/2016/acs/acs1/subject?get=S1601_C01_002E,S1601_C01_004E,S1601_C01_008E,S1601_C01_012E&for=congressional%20district:*&in=state:*&key=<my key>')
r.status_code
data = r.json()
df = pd.DataFrame(data)
header = df.iloc[0]
df = df[1:]
df.columns = header
lang = df.rename(columns = {'congressional district': 'cd',
'S1601_C01_002E': 'English',
'S1601_C01_004E': 'Spanish',
'S1601_C01_008E': 'IndoEuropean',
'S1601_C01_012E': 'AsianPacific'})
However, I am now interested retrieving a variable that is a percentage. When I try to pull it, I get -888888888 for all the values in the field. I'm assuming there is a simple way to retrieve this data in the correct format that I am missing. Anyone know what that is?
Faulty Code:
r = requests.get('https://api.census.gov/data/2016/acs/acs1/subject?get=S1501_C01_015E&for=congressional%20district:*&in=state:*&key=<my key>')
r.status_code
data = r.json()
Results:
[['S1501_C01_015E', 'state', 'congressional district'],
['-888888888', '01', '01'],
['-888888888', '01', '02'],
['-888888888', '01', '03'],
['-888888888', '01', '04'],
['-888888888', '01', '05'],...