U.S. County-Level Presidential Election Results (2004–2024)

Dataset Documentation

County-level Democratic and Republican vote counts and percentages for the six presidential elections of 2004, 2008, 2012, 2016, 2020, and 2024, for every U.S. county / county-equivalent. Produced by build_county_presidential_2004_2024.py. The USA Presidential Election Data explorer (usa_presidential_election_data.html) maps counties and states by election year and metric, with SQL summarization and trend charts.

Property Value
Geographic unit U.S. county / county-equivalent (FIPS)
Elections 2004, 2008, 2012, 2016, 2020, 2024
Counties ~3,154 per year (2004–2020), 3,160 (2024); 3,172 unique across years
Primary metric dem_pct, rep_pct — share of total county votes
Files long + wide CSV (parquet when rebuilt)
Rows long: 18,929 · wide: 3,172
Atlas build script scripts/build_presidential_election_data.py
Source builder data/presidential_election_data/build_county_presidential_2004_2024.py

Rebuild atlas assets:

python3 scripts/build_presidential_election_data.py
python3 scripts/build_presidential_election_documentation.py

Percentages are of total county votes (all candidates), so dem_pct + rep_pct + other ≈ 100.


What this dataset is

Real, published county returns — no modeling or synthesis. Two authoritative sources are combined, split at the last year the official academic file covers:

  • 2004–2020 — MIT Election Data & Science Lab (MEDSL). The official County Presidential Election Returns 2000–2020 file (long format, per candidate/ party, with FIPS). For 2020, returns are reported by vote mode (election-day, absentee, early, etc.); this build prefers the TOTAL mode where present and otherwise sums the mode rows, so each county has one figure per party.
  • 2024 — tonmcg/US_County_Level_Election_Results_08-24. Compiled from AP / network feeds (Fox News, Politico, NYT). The MEDSL reachable file stops at 2020, and MEDSL’s certified 2024 county file was not yet available from the mirror used; when it is, the builder can swap 2024 to MEDSL. This source is described by its author as extensive but not the authoritative certified record.

The source column records which provider each row came from (MEDSL or tonmcg).


Validation

County-summed national vote share reproduces the official national popular vote almost exactly, which is the main evidence the returns and processing are correct:

Year Dem % (dataset / actual) Rep % (dataset / actual)
2004 48.2 / 48.3 50.6 / 50.7
2008 52.9 / 52.9 45.7 / 45.7
2012 51.0 / 51.1 47.0 / 47.2
2016 48.2 / 48.2 46.1 / 46.1
2020 51.2 / 51.3 46.9 / 46.8
2024 48.4 / 48.3 49.9 / 49.8

County-level spot checks also behave as expected — e.g., Harris County, TX shifting from 44.6 D / 54.8 R (2004) to 54.0 D / 41.6 R (2016); Manhattan (New York County) 79–87% Democratic throughout.


Schema — long file

One row per county × election year.

Column Type Description
year int Election year
fips string(5) County FIPS, zero-padded
county string County name
state string State (postal abbr. for 2004–2020; full name for 2024)
dem_votes int Democratic candidate votes
rep_votes int Republican candidate votes
other_votes int All other votes (total − dem − rep)
total_votes int Total votes cast for president in the county
dem_pct float dem_votes / total_votes × 100
rep_pct float rep_votes / total_votes × 100
margin_pct float dem_pct − rep_pct (positive = Democratic margin)
source string MEDSL (2004–2020) or tonmcg (2024)

Schema — wide file

One row per county; percentages spread across years — the direct “Dem & Rep % per county over time” view.

fips, county, state, then for each year Y in {2004, 2008, 2012, 2016, 2020, 2024}: dem_pct_Y, rep_pct_Y. A missing pair means that county has no return for that year (see coverage notes).


Coverage notes and caveats

  • Connecticut (2024). Connecticut replaced counties with planning regions in 2022; the 2024 returns use the new planning-region FIPS (091xx), which do not match CT’s 2004–2020 county FIPS (090xx). CT rows therefore do not line up across the 2020→2024 boundary — in the wide file, one side of that split is blank for CT.
  • Alaska. Alaska does not report presidential results by borough/county in these sources (it uses house districts / statewide reporting), so Alaska “county” rows are atypical and FIPS may not be standard borough codes.
  • Percentages are of total votes, not of the two-party vote. For a two-party share, compute dem_votes / (dem_votes + rep_votes).
  • 2024 provenance. 2024 comes from a compiled, non-certified source; treat it as provisional relative to the MEDSL 2004–2020 records, and expect minor revisions when certified data is substituted.
  • County counts change over time (merges, independent cities, CT), so the set of FIPS is not identical across all six years; ~3,172 unique FIPS appear in at least one year.

Usage

import pandas as pd

long = pd.read_parquet("us_county_presidential_2004_2024_long.parquet")
wide = pd.read_parquet("us_county_presidential_2004_2024_wide.parquet")

# 1. One county's Democratic trajectory
harris = long[long.fips == "48201"][["year", "dem_pct", "rep_pct", "margin_pct"]]

# 2. Two-party Democratic share for a year
d = long[long.year == 2024].copy()
d["dem_two_party"] = d.dem_votes / (d.dem_votes + d.rep_votes) * 100

# 3. Counties that flipped R->D between 2004 and 2020 (by margin sign)
piv = long.pivot_table(index="fips", columns="year", values="margin_pct")
flipped = piv[(piv[2004] < 0) & (piv[2020] > 0)]

# 4. Change in Democratic share, 2012 -> 2024, straight from the wide file
wide["dem_shift_12_24"] = wide.dem_pct_2024 - wide.dem_pct_2012

To rebuild (both sources are on GitHub):

from build_county_presidential_2004_2024 import build
long, wide = build()

File manifest

File Description
us_county_presidential_2004_2024_wide.parquet Wide panel (recommended)
us_county_presidential_2004_2024_wide.csv Wide panel, CSV
us_county_presidential_2004_2024_long.parquet Tidy long panel
us_county_presidential_2004_2024_long.csv Tidy long panel, CSV
build_county_presidential_2004_2024.py Builder (MEDSL + tonmcg)
US_County_Presidential_Election_Data.md This document
usa_presidential_election_data.html Atlas explorer (map + SQL + trends)
presidential_election_documentation.html Generated documentation page

References

  • MIT Election Data & Science Lab. County Presidential Election Returns 2000–2020. Harvard Dataverse, doi:10.7910/DVN/VOQCHQ. https://electionlab.mit.edu · https://github.com/MEDSL
  • T. McGovern. US County Level Election Results 08–24. https://github.com/tonmcg/US_County_Level_Election_Results_08-24 (2024 data compiled from AP / network feeds.)

The 2004–2020 returns are the official MEDSL academic dataset; 2024 is a compiled, non-certified source. Percentages are of total county votes.