【发布时间】:2021-03-25 12:12:21
【问题描述】:
我正在开展一个项目,我正在尝试分析来自美国宾夕法尼亚州匹兹堡的大量 ACS 人口普查数据。我可以轻松地访问 data.census.gov 来获取我正在寻找的 138 个人口普查区域所需的数据,但这根本没有效率。所以我下载了 cenpy 库,它对纽约市的 ACS 数据非常有用。以下是纽约市的示例:
NYC_income = products.ACS(2019).from_place('New York City, NY', level = 'tract',
variables = ['B19013_001E'])
这很好用,会给我一个带有我传入的 ACS 变量的地理数据框。我已经在匹兹堡尝试过,但它不起作用,错误也不是很有帮助:
pgh_Test = products.ACS(2019).from_place('Pittsburgh, PA', level='tract',
variables = ['B01001A_001E'])
这将返回一个错误:
KeyError: 'Response from API is malformed. You may have submitted too many queries,
formatted the request incorrectly, or experienced significant network connectivity
issues. Check to make sure that your inputs, like placenames, are spelled correctly,
and that your geographies match the level at which you intend to query. The original
error from the Census is:\\n(API ERROR 400:Failed to execute query.([]))'
我还尝试了如何拼写Pittsburgh 的其他变体,例如Pittsburgh City、Pittsburgh city、Pittsburg,还尝试拼写状态而不是使用首字母缩写词。
最后,我很好奇是否有人遇到过这个问题以及如何解决它,以便我可以通过 cenpy 访问匹兹堡 ACS 数据,而不是通过 data.census.gov 选择每个人口普查区。
提前谢谢你!
【问题讨论】: