datamade / census

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

census.acs5_state does not work for years from 2010-2015 #71

Open xzhou56 opened 5 years ago

xzhou56 commented 5 years ago

To whom it may concern:

I am trying to use census.acs5_state and census.acs5_state_place. They only worked well for the year 2009 and 2016, but not working for years from 2010 to 2015. Is there anything wrong with these years?

Thanks.

semcogli commented 5 years ago

Could you post your codes and error message?

xzhou56 commented 5 years ago

Sure. c.acs5.state('B01001_004E', '*',year=2015) if changing the year to 2009 or 2016, it works.

The same issue happened to state_place: c.acs5.state_place(tuple(varlist),'','',year=2010)

Error message: CensusException: Error report

HTTP Status 404 - /data/2010/acs5


type Status report

message /data/2010/acs5

description The requested resource is not available.


semcogli commented 5 years ago

it works for me. Requests for years from 10 to 15 returned data as normal. Not sure what happens there. one thing you can try is to reinstall your census library and see if that helps. Best regards.

c.acs5.state('B01001_004E', '*',year=2015) [{'B01001_004E': 156380.0, 'state': '01'}, {'B01001_004E': 26276.0, 'state': '02'}, {'B01001_004E': 231249.0, 'state': '04'}, {'B01001_004E': 103613.0, 'state': '05'}, {'B01001_004E': 1295030.0, 'state': '06'},

xzhou56 commented 5 years ago

Thanks. I uninstalled and re-installed, but it still didn't work for me.

So I went back to census API document, we found that, the api call for 2009 data is a little different from all other years. In 2009: api.census.gov/data/2009/acs5? But in other years: https://api.census.gov/data/2011/acs/acs5?

I don't know if this affects your library but wanna share here just in case someone else has a similar issue like me.

semcogli commented 5 years ago

the issue you mentioned has been taken cared of, I believe, https://github.com/datamade/census/blob/master/census/core.py line 278, you can see the endpoint url switches depends on the years you are querying. you can check your local file and see if it is correct.

palewire commented 5 years ago

I upgraded to the latest version and this was fixed for me.