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
|
|
required |
level
|
str
|
|
'da'
|
**kw
|
Passed to :func: |
{}
|
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
|
|
required |
census_geometry
|
Optional[Dict[str, GeoDataFrame]]
|
|
None
|
worldpop_path
|
Optional[str]
|
Explicit WorldPop raster. |
None
|
cache_dir
|
Optional[str]
|
Cache folder; |
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
|