Skip to content

pycensus.census.countries.usa.dhc.loader

Loader for the 2020 Decennial Census DHC, returning a common-schema GeoDataFrame.

Technical aspects

Mirrors :mod:pycensus.usa.acs.loader: reads as much as possible from pyCensus' parquet cache (:mod:pycensus.cache), fetching only the logical columns actually missing via :func:pycensus.usa.api.fetch_variables, and merges the result back into the shared per-level/region cache file. Output columns are prefixed dhc_.

load(aoi=None, states=None, level='block', year='latest', api_key=None, cache_dir=None, cache=True)

Load Decennial Census DHC data as a common-schema GeoDataFrame.

Parameters:

Name Type Description Default
aoi Optional[GeoDataFrame]

Area of interest. Used to auto-detect states if not given, and to clip the final result.

None
states Optional[Union[str, List[str]]]

State name(s)/abbreviation(s)/FIPS code(s) to load. Derived from aoi if omitted (aoi is then required).

None
level str

Standard geometry level (:data:pycensus.geometry_levels.STANDARD_LEVELS); "dec/dhc" is available down to "block".

'block'
year Union[int, str]

Vintage year, or "latest".

'latest'
api_key Optional[str]

Census API key. Resolved via :func:pycensus.api_keys.resolve_api_key if not given.

None
cache_dir Optional[str]

Root of pyCensus' parquet cache. Defaults to :func:pycensus.cache.default_cache_dir.

None
cache bool

If False, bypass the cache entirely -- always fetch fresh and don't persist the result.

True

Returns:

Type Description
GeoDataFrame

GeoDataFrame with GEOID, geometry, and one dhc_-prefixed

GeoDataFrame

column per logical column in :data:pycensus.usa.dhc.schema.SCHEMA.

Raises:

Type Description
ValueError

If neither states nor aoi is given.