我正在做一个项目,我试图分析来自美国宾夕法尼亚州匹兹堡市的大量ACS人口普查数据。我可以很容易地访问data.census.gov,获取我正在寻找的138个人口普查区所需的数据,但这根本没有效率。所以我下载了cenpy图书馆,它对纽约市ACS数据非常有用。以下是纽约市的一个例子:
NYC_income = products.ACS(2019).from_place('New York City, NY', level = 'tract',
variables = ['B19013_001E'])
这很好,将给我一个带有我传入的ACS变量的geodataframe。我在匹兹堡试过这个方法,但不起作用,错误也没有多大帮助:
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选择每个单独的人口普查区
提前谢谢你
使用
'County Subdivision'
作为place_type
。似乎这有助于正确解决问题:输出:
此参数的其他值为
'Incorporated Place'
和'Census Designated Place'
。从the documentation:请参阅this colab中的演示
相关问题 更多 >
编程相关推荐