Skip to content

pycensus.census.countries.usa.elections_precinct.unofficial.fec

Statewide calibration of an unofficial precinct file to the FEC's official 2024 state totals (verification/fec_2024_state_totals.json).

Compilations differ from the official canvass by a fraction of a percent (late ballots, overvotes, summary rows). When the file is within MAX_DEV of the official total and Democratic count, the three vote columns are multiplied by one statewide factor each so the state matches the official result exactly; a larger gap means missing precincts, and the source is refused (ValueError) instead of being stretched.

calibrate(gdf, state_abbr, max_dev=MAX_DEV)

Scale a state's precinct votes to the FEC official totals, refusing files that deviate by more than max_dev.

Parameters:

Name Type Description Default
gdf

Precincts with votes_* columns.

required
state_abbr str

State abbreviation.

required
max_dev float

Largest accepted deviation.

MAX_DEV

Returns:

Type Description

The scaled precincts.

Raises:

Type Description
ValueError

If the file deviates too much.