Skip to main content

gerda

Lightweight Python loader for the German Election Database (GERDA). Downloads and returns pandas DataFrames for German federal, state, local, mayoral, Landrat, county, and European Parliament elections (1945–2026), plus boundary crosswalks. Python port of the gerda R package.

Install

pip install gerda                 # base install (pandas)
pip install "gerda[polars]"       # adds polars output support

Requires Python 3.11+.

Use

import gerda

# List all 47 datasets with geography, years, boundary target, and formats
catalog = gerda.datasets()

# Load federal county-level results
df = gerda.load("federal_cty_harm")

# Load harmonized municipal data and convert to polars
df = gerda.load("federal_muni_harm_25", as_polars=True)

# Force a fresh download (bypass cache)
df = gerda.load("federal_cty_harm", refresh=True)

# State-election results by constituency (Wahlkreis)
ltw = gerda.load("ltw_wkr_unharm")

# County-executive (Landrat) candidates
landrat = gerda.load("landrat_candidates")

# Annual county-council seat composition on current boundaries
seats = gerda.load("county_council_seats")

Files are downloaded from the GERDA data repository and cached in a platform-specific user cache directory: ~/.cache/gerda/ on Linux, ~/Library/Caches/gerda/ on macOS, %LOCALAPPDATA%\gerda\Cache\gerda on Windows. The exact path is available at runtime:

from gerda.cache import cache_dir
print(cache_dir())

Cached files keep their original dataset names (e.g. federal_cty_harm.rds), so it's safe to inspect or prune the cache by hand. RDS files are read with pyreadr; column dtypes (notably string AGS codes with leading zeros) are preserved automatically.

Dataset keys

The structured columns returned by gerda.datasets() can be used to select datasets by election type, geographic level, years, boundary target, available formats, and whether they contain candidate information.

  • federal_wkr_*: federal constituencies, keyed by wkr_nr and election year; long files additionally identify vote type (stimme) and party.
  • ltw_wkr_*: state constituencies, keyed by state, wkr_nr, and election year; long files additionally identify vote type and party.
  • landrat_unharm: county-executive elections, identified by ags, election date, and round. landrat_candidates adds person-level candidates.
  • county_council_seats: annual county seat composition on fixed current county boundaries, identified by county and year.
  • federal_cty_unharm: use county_code and election_year. The legacy aliases ags and year remain through Python gerda 0.6 and will be removed in v0.7.

Party crosswalk

Map GERDA party names to ParlGov attributes:

import gerda

gerda.party_crosswalk(["cdu", "spd", "linke_pds"], "left_right")
# 0    6.2503
# 1    3.6451
# 2    1.2152
# dtype: float64

gerda.party_crosswalk(["cdu", "afd"], "family_name_short")
# 0      chr
# 1    right

See gerda.crosswalk.destinations() for the full list of 21 destination columns (party names, family, ideology scales, identifiers).

Scope

This package provides three workflows from the broader R package: load, datasets, and party_crosswalk. The bundled INKAR / Zensus 2022 tables and their merge helpers (add_gerda_covariates, add_gerda_census) are intentionally not ported — Python users can do their own merges. If you need them, use the R package.

Citation

Heddesheimer, Sichart, Wiedemann, and Hilbig. "German Elections Database (GERDA)." Scientific Data (2025). doi:10.1038/s41597-025-04811-5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gerda-0.2.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gerda-0.2.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file gerda-0.2.0.tar.gz.

File metadata

  • Download URL: gerda-0.2.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for gerda-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bb46991dde5ad77fc8d1f8ef5a74b3f05b6a17f8708bc57e258df4f7a708bc25
MD5 4ff0dd5cc1f8ca4af0ccb0b71306ce96
BLAKE2b-256 4c766983fd0e4e32b54fb8f704a75b2edb4905c140e22a851e9aa62c4b60f84f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gerda-0.2.0.tar.gz:

Publisher: publish.yml on hhilbig/gerda-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gerda-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: gerda-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for gerda-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2899e63f05a536cf4f1c896492f841868d92c0e1740ca8f0ce4c2ebcef707ede
MD5 9d0a693e3236844bbe6f5d4b5a3317ff
BLAKE2b-256 fb2d2133044ca5920d144ac8175111f7916d2c543f8075c14370eb28c7f0d367

See more details on using hashes here.

Provenance

The following attestation bundles were made for gerda-0.2.0-py3-none-any.whl:

Publisher: publish.yml on hhilbig/gerda-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page