Giter VIP home page Giter VIP logo

Comments (4)

johnziebro avatar johnziebro commented on August 31, 2024

As described in issue 30's fix, the test code does not work for table DP03:

import censusdata as cd
tableInfo = cd.censustable("acs5", 2019, "DP03")
fullTable = cd.download("acs5", 2019, cd.censusgeo([('state', '51'), ('county', '059')]),
list(tableInfo.keys()), tabletype='subject')

ValueError: Unexpected response (URL: https://api.census.gov/data/2019/acs/acs5/subject?get=NAME,DP03_0001E,DP03_0001PE,DP03_0002E,DP03_0002PE,DP03_0003E,DP03_0003PE,DP03_0004E,DP03_0004PE,DP03_0005E,DP03_0005PE,DP03_0006E,DP03_0006PE,DP03_0007E,DP03_0007PE,DP03_0008E,DP03_0008PE,DP03_0009E,DP03_0009PE,DP03_0010E,DP03_0010PE,DP03_0011E,DP03_0011PE,DP03_0012E,DP03_0012PE,DP03_0013E,DP03_0013PE,DP03_0014E,DP03_0014PE,DP03_0015E,DP03_0015PE,DP03_0016E,DP03_0016PE,DP03_0017E,DP03_0017PE,DP03_0018E,DP03_0018PE,DP03_0019E,DP03_0019PE,DP03_0020E,DP03_0020PE,DP03_0021E,DP03_0021PE,DP03_0022E,DP03_0022PE,DP03_0023E,DP03_0023PE,DP03_0024E,DP03_0024PE,DP03_0025E&for=county:059&in=state:51): error: error: unknown variable 'DP03_0001E'

As a workaround the test code will work for table S2301. S2301_C02_008E and S2301_C02_001E can be extracted in this manner, albeit with much increased bandwidth usage due to downloading a complete table for each required administration boundary.

tableInfo = cd.censustable("acs5", 2019, "S2301")
fullTable = cd.download("acs5", 2019, cd.censusgeo([('state', '51'), ('county', '059')]),
list(tableInfo.keys()), tabletype='subject')
fullTable.T[fullTable.T.index.str.contains('_C02_008E')]

Fairfax County, Virginia: Summary level: 050, state:51> county:059
S2301_C02_008E 82.3

from censusdata.

johnziebro avatar johnziebro commented on August 31, 2024

As a side note, what I find very strange about this issue is that the Census API responds with 'S2301_C02_008E' variable does not exist, but if the full table S2301 is downloaded directly from the Census Bureau, it does exist in the table.

from censusdata.

jtleider avatar jtleider commented on August 31, 2024

Hi,

The errors are because tabletype was not properly specified (see documentation). For subject variables (those starting in S), tabletype='subject' needs to be passed as an argument for download. Similarly, for data profile variables (those starting in DP), tabletype='profile' needs to be specified. By specifying those arguments I was able to fix both errors you mentioned. This is not related to whether the whole table is downloaded or only a part.

If there are any errors this does not address please let me know.

from censusdata.

johnziebro avatar johnziebro commented on August 31, 2024

That explains it, thank you for the correction and clarification! Somehow I missed this in the docs. Closing as resolved.

Relevant docs:
https://jtleider.github.io/censusdata/variables.html
https://jtleider.github.io/censusdata/api.html?highlight=tabletype

from censusdata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.