Skip to content

pycensus.census.countries.spain.serpavi.loader

SERPAVI rent per m2 by census section / district / municipality / province (2011-2024).

Technical aspects

Source: MIVAU bulk workbook (tax data, Modelo 100 + Catastro), one sheet per level ('Secciones censales', 'Distritos', 'Municipios', 'Provincias', 'CCAA'); columns are <MEASURE>_<GROUP>_<YY>. The server answered 403 to plain curl but serves the CDN file (verified 2026-10-25, 71 MB) to browser-like headers (_http.BROWSER_HEADERS). Sections follow the INE 2021 census section code (CUSEC, 10 digits), so GEOID matches spain.ine/censo2021.

Measures kept (monthly EUR/m2, rent per property, area, count): group VC = collective housing (flats; used for the headline value), VU = single-family/rural. Output columns: serpavi_rent_m2_{median,p25,p75}_{vc,vu}_{YYYY}, serpavi_rent_total_median_{vc,vu}_{YYYY}, serpavi_area_m2_median_{vc,vu}_{YYYY}, serpavi_n_{vc,vu}_{YYYY}, plus serpavi_rent_m2_latest (VC median, else VU median, latest year with data). Sections with too few observations are suppressed by the Ministry (NaN). Basque Country and Navarre (foral tax regimes) are NaN/partial in early years; check coverage per year in coverage; use Eustat/Gobierno de Navarra sources to fill. The parsed sheet is cached as parquet next to the xlsx so the 71 MB workbook is read only once.

municipality_crosswalk(data_dir=None)

Province name + municipality name -> 5-digit INE code (from the SERPAVI 'Municipios' sheet), used to join name-only sources.

Parameters:

Name Type Description Default
data_dir Optional[str]

Folder of the raw downloads; None = the pycensus cache.

None

Returns:

Type Description
DataFrame

CPRO, NPRO, CUMUN, NMUN.

load_attributes(provinces=None, level='section', data_dir=None, years=None)

Return SERPAVI columns for level ('section'|'district'|'municipality'|'province'), optionally restricted to 2-digit provinces and years. Adds serpavi_rent_m2_latest and serpavi_rent_m2_latest_year.

Parameters:

Name Type Description Default
provinces Optional[Iterable[str]]

2-digit province codes.

None
level str

"section", "district", "municipality" or "province".

'section'
data_dir Optional[str]

Folder of the raw downloads; None = the pycensus cache.

None
years Optional[Iterable[int]]

Years kept; None = all.

None

Returns:

Type Description
DataFrame

One row per unit.

coverage(df, year=2024)

Share of rows with a VC median rent per m2 for year, by 2-digit province.

Parameters:

Name Type Description Default
df DataFrame

Output of :func:load_attributes.

required
year int

Year checked.

2024

Returns:

Type Description
Series

Share by province.