Table · county-president

County presidential election results, 2000-2024

Presidential votes by county for every election from 2000 to 2024: one row per county per candidate, from the MIT Election Data + Science Lab.

Updates
Every 4 years
Coverage
—
Current version
—
Last published
—
Validation
—
License
CC0 1.0
Commercial use
Allowed

Preview

Loading the preview…

Use the API

The examples follow the rows picked above. See the docs for versions, caching and errors.

curl

# All rows (.json or .csv)
curl -s "https://api.electiondata.dev/v1/county-president/table/all.json"

# The whole table in one file
curl -sO "https://api.electiondata.dev/v1/county-president/download/county-president.csv"

Python (polars)

import polars as pl

# All rows
df = pl.read_csv("https://api.electiondata.dev/v1/county-president/table/all.csv")

# The whole table
everything = pl.read_parquet("https://api.electiondata.dev/v1/county-president/download/county-president.parquet")

JavaScript

const res = await fetch("https://api.electiondata.dev/v1/county-president/table/all.json");
if (!res.ok) throw new Error((await res.json()).detail); // errors are problem+json
const { meta, rows } = await res.json();
console.log(meta.rows, rows[0]);

Downloads

The whole dataset in one file. Parquet keeps the column types and is much smaller.

Schema

Rows are identified by year, state_po, unit_id, candidate, party. The rows are also split into one file per value of year. Tables up to 50,000 rows also have a single table/all file.

Column Type Unit Can be empty Description
year key partition year (YYYY) — no Year of the election
state text — no State name in upper case
state_po key text — no USPS state code
state_id text — no Location id in the shared registry (us-<usps>)
county_name text — no County or other reporting unit as MEDSL names it, upper case
county_fips text — yes Five-digit county FIPS code; null for units that aren't counties
county_id text — yes Location id in the shared registry (us-county-<fips>); null where the county no longer exists
unit_id key text — no Identifies the reporting unit: county_fips, or <state>-<NAME> for a unit without one
office text — no Always US PRESIDENT
candidate key text — no Candidate as MEDSL spells it, upper case; OTHER for all other candidates
party key text — no DEMOCRAT, REPUBLICAN, LIBERTARIAN, GREEN or OTHER
candidatevotes integer votes yes The candidate's votes in the county; null where MEDSL has no count
totalvotes integer votes no Total presidential votes in the county as MEDSL reports it
from_modes true / false — no True where MEDSL reports the county only by vote mode and candidatevotes is the sum of the modes
version date (YYYY-MM-DD) — no Date MEDSL finalized the row

Source and license

Source
MIT Election Data and Science Lab, County Presidential Election Returns 2000-2024
Publisher
MIT Election Data and Science Lab (MEDSL)
License
CC0 1.0 (public domain dedication) (CC0-1.0)
Commercial use
Allowed

Credit the source with this exact text:

MIT Election Data and Science Lab, 2018, "County Presidential Election Returns 2000-2024", https://doi.org/10.7910/DVN/VOQCHQ, Harvard Dataverse, V20, UNF:6:xvsJJxrfXMIvzAuDYlfvVw== [fileUNF]

Checked every 7 days. If the source hasn't changed in 5 years, the status page flags it as stale.

Endpoints

Every URL for this dataset. To pin the current version, put it after the id: /v1/county-president@<version>. The API reference describes each response.

What URL
Metadata: version, coverage, downloads, validation /v1/county-president
Versions and monthly snapshots /v1/county-president/versions
Partitions /v1/county-president/locations
Rows for one year (JSON) /v1/county-president/table/{year}.json
Rows for one year (CSV) /v1/county-president/table/{year}.csv
All rows in one file (tables up to 50,000 rows) /v1/county-president/table/all.json
Whole dataset (CSV) /v1/county-president/download/county-president.csv
Whole dataset (Parquet) /v1/county-president/download/county-president.parquet