Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Census.ALL does not function #74

Open
poulson opened this issue May 3, 2019 · 1 comment
Open

Census.ALL does not function #74

poulson opened this issue May 3, 2019 · 1 comment

Comments

@poulson
Copy link

poulson commented May 3, 2019

It appears that using Census.ALL instead of something of the form {'for': 'state:*'} does not work, even on the core example in the README:

>>> c.acs5.get('B01001_004E', Census.ALL)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/poulson/miniconda3/lib/python3.6/site-packages/census/core.py", line 298, in get
    return super(ACSClient, self).get(*args, **kwargs)
  File "/home/poulson/miniconda3/lib/python3.6/site-packages/census/core.py", line 155, in get
    merged_results = [merge(result) for result in zip(*all_results)]
  File "/home/poulson/miniconda3/lib/python3.6/site-packages/census/core.py", line 154, in <genexpr>
    for fifty_fields in chunks(fields, 50))
  File "/home/poulson/miniconda3/lib/python3.6/site-packages/census/core.py", line 64, in wrapper
    result = func(self, *args, **kwargs)
  File "/home/poulson/miniconda3/lib/python3.6/site-packages/census/core.py", line 170, in query
    'for': geo['for'],
TypeError: string indices must be integers

I installed the census API via pip: is it possible that this issue has already been fixed in master?

@jeancochrane
Copy link
Contributor

Looking at the code, I think Census.ALL has to be used with a geographic convenience method. For example, the equivalent query using the state method works:

In [9]: c.acs5.state('B01001_004E', Census.ALL)                                                                                                                                                                    
Out[9]: 
[{'B01001_004E': 99703.0, 'state': '72'},
 {'B01001_004E': 155491.0, 'state': '01'},
 {'B01001_004E': 26172.0, 'state': '02'},
 {'B01001_004E': 231773.0, 'state': '04'},
...

This makes sense in that Census.ALL is very literally just a wildcard character:

ALL = '*'

If this is true, the docs could probably be adjusted to clarify that Census.ALL isn't an appropriate choice for the get method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants