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 50 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 2021 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).

Parties that ParlGov does not cover, including BSW and WerteUnion, return their names but missing values for party family, ideology scales, and 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

Metadata

Release files for gerda 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gerda 0.2.2
File Size Uploaded Provenance Actions
gerda-0.2.2.tar.gz 16.7 kB With provenance Details for gerda-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gerda 0.2.2
File Interpreter ABI Platform Actions
gerda-0.2.2-py3-none-any.whl Python 3 none any Details for gerda-0.2.2-py3-none-any.whl

Total release size: 34.8 kB

Release files / gerda-0.2.2.tar.gz

Download URL gerda-0.2.2.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
451ef0ba81778a3137f857c09318f2520fd51056b5afcdd20f6246791eac8df7
BLAKE2b-256 checksum
How to use checksums
3a4bdb8f417e11d209ee089e58bd583107841216eaf86c6c0eb00a4fd1003a0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / gerda-0.2.2-py3-none-any.whl

Download URL gerda-0.2.2-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcd67b27c3b2395ffd752b41ca6e4283064751e413756f87a0e3718a6c7b0355
BLAKE2b-256 checksum
How to use checksums
8e5e6faa59d4ec46811d2f02ceebfd620b79f02e4a5bc3ea266e808c3d7a7fda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for gerda 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gerda-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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