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 bywkr_nrand 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 byags, election date, and round.landrat_candidatesadds person-level candidates.county_council_seats: annual county seat composition on fixed current county boundaries, identified by county and year.federal_cty_unharm: usecounty_codeandelection_year. The legacy aliasesagsandyearremain 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb46991dde5ad77fc8d1f8ef5a74b3f05b6a17f8708bc57e258df4f7a708bc25
|
|
| MD5 |
4ff0dd5cc1f8ca4af0ccb0b71306ce96
|
|
| BLAKE2b-256 |
4c766983fd0e4e32b54fb8f704a75b2edb4905c140e22a851e9aa62c4b60f84f
|
Provenance
The following attestation bundles were made for gerda-0.2.0.tar.gz:
Publisher:
publish.yml on hhilbig/gerda-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gerda-0.2.0.tar.gz -
Subject digest:
bb46991dde5ad77fc8d1f8ef5a74b3f05b6a17f8708bc57e258df4f7a708bc25 - Sigstore transparency entry: 2270728845
- Sigstore integration time:
-
Permalink:
hhilbig/gerda-py@1d74b9ef74335cfd73212c0605865bd66ff3d114 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hhilbig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1d74b9ef74335cfd73212c0605865bd66ff3d114 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2899e63f05a536cf4f1c896492f841868d92c0e1740ca8f0ce4c2ebcef707ede
|
|
| MD5 |
9d0a693e3236844bbe6f5d4b5a3317ff
|
|
| BLAKE2b-256 |
fb2d2133044ca5920d144ac8175111f7916d2c543f8075c14370eb28c7f0d367
|
Provenance
The following attestation bundles were made for gerda-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on hhilbig/gerda-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gerda-0.2.0-py3-none-any.whl -
Subject digest:
2899e63f05a536cf4f1c896492f841868d92c0e1740ca8f0ce4c2ebcef707ede - Sigstore transparency entry: 2270728882
- Sigstore integration time:
-
Permalink:
hhilbig/gerda-py@1d74b9ef74335cfd73212c0605865bd66ff3d114 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hhilbig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1d74b9ef74335cfd73212c0605865bd66ff3d114 -
Trigger Event:
workflow_dispatch
-
Statement type: