pycensus.census.countries.euskadi.eustat.municipal_indicators¶
Real municipal-level indicators from Eustat's PXWeb "Banco de Datos" (BDE) API.
Technical aspects
Separate from eustat/loader.py (which sources population/area from
GISCO LAU, prefix eustat_population/eustat_areaKm2/
eustat_populationDensity). This module adds additional real
Eustat-sourced municipal fields -- business establishments, births,
deaths -- fetched live from the same PXWeb Data Bank API documented in
euskadi/api.py (POST https://www.eustat.eus/bankupx/api/v1/es/DB/{table}).
Kept in its own module (rather than folded into loader.py's single
GISCO-sourced _fetch_missing) because these three tables are a
genuinely different source/request shape (PXWeb JSON-stat2 query vs.
GISCO GeoPackage columns) -- mirrors how spain/censo2021 stays a
separate module from spain/ine for the same reason.
Real tables used (municipio codes are 5-digit INE/LAU codes, e.g.
Gipuzkoa municipalities are "20xxx" -- the same code space as
spain.ine/spain.censo2021's section GEOID[:5], confirmed by
cross-checking Donostia/San Sebastian's code, "20069", appears
identically in both this API's municipio variable values and
spain.geography's municipality boundary table):
-
establishments (
eustat_establishments): tablePX_200163_cdirae_est04b.px("Establecimientos en la C.A. de Euskadi por municipio y CNAE-2009. 2008-2025"),CNAE-2009="0"(Total, all sectors), most recent availableperiodo. Verified live 2026-08-25: Donostia/San Sebastian (municipio="20069") = 18,037 establishments forperiodo="2025"-- matches the figure already recorded ineuskadi/api.py's own module docstring (verified independently there 2026-08-20). Full coverage: all 89 Gipuzkoa municipalities have a real value, no population threshold. -
birthsPeriod2021_2025 (
eustat_birthsPeriod2021_2025): tablePX_010302_cmnp_enac51.px("Nacimientos vivos de madre residente por municipio..."),orden de nacimiento="10"(Total, all birth orders),quinquenio de nacimiento de la madre="100"(Total, all maternal-age cohorts),periodo="20212025"(the most recent closed 5-year window). This is a cumulative 5-year count, not an annual rate -- named accordingly rather than implying an annual figure. Verified live 2026-08-25: Donostia = 5,530 live births 2021-2025 (~1,106/yr for a ~188k population -- a plausible crude birth rate of ~5.9/1000). Full coverage, no population threshold. -
deathsPeriod2021_2025 (
eustat_deathsPeriod2021_2025): tablePX_010303_cmnp_edef31.px("Defunciones de la C.A. de Euskadi por municipio, sexo, quinquenio de nacimiento y periodo"),sexo="10"(Total, both sexes),quinquenio de nacimiento="100"(Total, all birth-year cohorts),periodo="20212025". Verified live 2026-08-25: Donostia = 10,413 deaths 2021-2025 (~2,083/yr, ~11.1/1000 -- plausible for an aging Basque coastal city, higher than the crude birth rate above, consistent with Spain's well-documented population aging). Full coverage, no population threshold.
School enrollment (PX_040601_ceens_mun01.px) and the
activity/unemployment-rate tables mentioned in
euskadi/api.py's docstring were investigated but are NOT
implemented here in this pass -- the former needs a defensible single
"total students" query across its titularidad/nivel/modelo
breakdown that wasn't nailed down in the time available, and the
latter are population-thresholded (only towns >10k/40k/100k) and would
be mostly-NaN for Gipuzkoa's 89 municipalities. Both are real,
documented follow-ups, not fabricated gaps.
No API key is required.
Source
https://www.eustat.eus/bankupx/api/v1/es/DB (see euskadi/api.py)
fetch_establishments(period=ESTABLISHMENTS_PERIOD)
¶
Fetch real total establishment counts (all CNAE-2009 sectors) per municipality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period
|
str
|
Eustat period code. |
ESTABLISHMENTS_PERIOD
|
Returns:
| Type | Description |
|---|---|
Series
|
Counts indexed by 5-digit municipality code. |
fetch_births(period=BIRTHS_DEATHS_PERIOD)
¶
Fetch real cumulative live-birth counts (all orders/maternal cohorts) per municipality for one 5-year period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period
|
str
|
Eustat period code. |
BIRTHS_DEATHS_PERIOD
|
Returns:
| Type | Description |
|---|---|
Series
|
Counts indexed by 5-digit municipality code. |
fetch_deaths(period=BIRTHS_DEATHS_PERIOD)
¶
Fetch real cumulative death counts (both sexes, all birth cohorts) per municipality for one 5-year period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period
|
str
|
Eustat period code. |
BIRTHS_DEATHS_PERIOD
|
Returns:
| Type | Description |
|---|---|
Series
|
Counts indexed by 5-digit municipality code. |
load_municipal_indicators(region='20')
¶
Load all three real Eustat BDE municipal indicators, joined on 5-digit municipality GEOID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
Optional[str]
|
Territory code prefix to filter to (default |
'20'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with |
DataFrame
|
|
DataFrame
|
columns (each real, independently live-verified -- see module |
DataFrame
|
docstring). |
load_extra_indicators(region='20')
¶
Every _EXTRA indicator for the municipalities (5-digit codes starting with region; None = all), as eustat_<name>
columns (bare names for global-schema features), plus GEOID. A failing table is skipped with a warning, never fatal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
Optional[str]
|
2-digit province code prefix; |
'20'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per municipality. |