census icon indicating copy to clipboard operation
census copied to clipboard

API returns value of -666666666

Open jeancochrane opened this issue 5 years ago • 7 comments

Some calls to acs5.state_county_tract() return the value -666666666. This seems like a semantically significant value, but I can't find documentation on what it means.

For a reproducible example, this call returns the value in question:

>>> c = Census(os.environ['CENSUS_API_KEY'], year=2016)
>>> c.acs5.state_county_tract('B19081_001E', 42, 101, '989100')

[{'B19081_001E': -666666666.0, 'state': '42', 'county': '101', 'tract': '989100'}]

Any thoughts on what this response means, and how I should handle it? So far I've just been converting them to nulls.

jeancochrane avatar Apr 04 '19 22:04 jeancochrane

Here are those definitions:

https://www.census.gov/data/developers/data-sets/acs-1year/notes-on-acs-estimate-and-annotation-values.html

loganpowell avatar Apr 08 '19 12:04 loganpowell

Exactly what I was looking for, thanks @loganpowell!

jeancochrane avatar Apr 08 '19 14:04 jeancochrane

How do you think the library should handle this response @fgregg? I'm happy to give a PR a shot if you can provide guidance.

jeancochrane avatar Apr 08 '19 14:04 jeancochrane

I think it would be good to configure the library to do two things based on a user setting.

  1. cast these to null, and emit a warning
  2. raise an exception

Not sure what the default should be? Thoughts?

fgregg avatar Apr 08 '19 15:04 fgregg

My reading of the docs is that this value means one of either:

  1. No data
  2. Not enough data to make an estimate
  3. Ratio of medians could not be calculated (?)

I don't feel confident I understand what's going on with 3), but 1) and 2) both indicate to me that casting to null and raising a warning would be a good default, since null is a common interpretation of "no data".

jeancochrane avatar Apr 08 '19 15:04 jeancochrane

casting to null and raising a warning is probably a bit more backwards compatible too

fgregg avatar Apr 08 '19 15:04 fgregg

not sure if the behaviour should be set on initialization of census class or on the get data methods

probably on the methods.

fgregg avatar Apr 08 '19 15:04 fgregg