Skip to content

pycensus.census.countries.canada.elections

Toronto election results (federal 2025, Ontario 2025, municipal 2022) at poll level, resampled to H3 res 8 and 2021 dissemination areas.

load(scope, level='da', **kw)

One frame: level da (index GEOID = DAUID), h3 (index h3_cell, res 8) or poll.

Example: load("national", level="da").

Parameters:

Name Type Description Default
scope str

"national", "state" or "municipal".

required
level str

"da", "h3" or "poll".

'da'
**kw

Passed to :func:load_all.

{}

Returns:

Type Description
DataFrame

The frame of that level.

load_all(scope, census_geometry=None, worldpop_path=None, cache_dir=None, area=None)

{"poll", "h3", "da"} frames for scope in national/state/municipal.

census_geometry: {"da": GeoDataFrame(GEOID|DAUID, geometry)} (2021 dissemination areas around Toronto).

Parameters:

Name Type Description Default
scope str

"national", "state" or "municipal".

required
census_geometry Optional[Dict[str, GeoDataFrame]]

{"da": dissemination areas}.

None
worldpop_path Optional[str]

Explicit WorldPop raster.

None
cache_dir Optional[str]

Cache folder; None = the pycensus cache.

None
area

Study area (shapely geometry, EPSG:4326 -- e.g. the union of the census geometry): the federal and Ontario elections take every polling division whose representative point lies in it (all of the province publishes them); None = the City of Toronto. The municipal election is the City of Toronto's in any case.

None