census
census copied to clipboard
Support census blocks?
Thanks for the fantastic library. I noticed that there is support for obtaining block-group-level data, but not block-level. Is there any chance you can add support for blocks?
IIRC, while the Census collects data at the block level, they only report at the block-group level and above.
No, their API does provide block-level data for some datasets. For example, the 2020 Redistricting Data Summary File (PL 94-171) has block-level data.
You can test this for yourself by adding the following function to core.py:
@supported_years()
def state_county_block(self, fields, state_fips, county_fips, block, tract=None, **kwargs):
geo = {
'for': 'block:{}'.format(block),
'in': 'state:{} county:{}'.format(state_fips, county_fips),
}
if tract:
geo['in'] += ' tract:{}'.format(tract)
return self.get(fields, geo=geo, **kwargs)
And then running a query like this:
data = c.pl.state_county_block(
('NAME', 'P1_001N'), # table
'29', # state
'189', # county
Census.ALL, # blockgroup
year='2020'
)
@Kirkman mind if I copy this and do a pull request?