pycensus.census.countries.canada.constants¶
Static Canada geography reference data shared by every Canada census source.
Technical aspects
Canada's administrative divisions used here: - Nation (country level) - Province/territory (PRUID, 2-digit StatCan code) - 10 provinces + 3 territories - Census subdivision (CSDUID, 7-digit StatCan code: 2-digit PRUID + 2-digit census division + 3-digit CSD) - Canada's municipality-equivalent (city/town/village/reserve/etc.)
PROVINCE_CODES (PRUID -> English name) and every CSD's PRUID
prefix were cross-checked directly against the real 2021 boundary
files (see :mod:pycensus.canada.geography) and the real 2021 Census
Population and Dwelling Counts table (PID 98-10-0002) -- both verified
live 2026-08-20. PROVINCE_ABBR uses Canada Post's standard 2-letter
postal abbreviations (independently well-known, not StatCan-specific
codes).
Source
https://www12.statcan.gc.ca/census-recensement/2021/geo/index-eng.cfm
province_code(province)
¶
Normalize a province name, postal abbreviation, or PRUID to its 2-digit PRUID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
province
|
str
|
Province name, postal abbreviation, or 2-digit code. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Two-digit StatCan PRUID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
province_abbr(province)
¶
Normalize a province name, abbreviation, or PRUID to its postal abbreviation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
province
|
str
|
Province name, abbreviation or PRUID. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Postal abbreviation. |