election_night.py
is a quick script to translate the data from 538's 2022 election model into various csv files using pandas
, to help me more easily follow the most competitve house, senate, and gubernatorial races on election night.
Input csv files, located in the input
directory, are downloaded directly from 538.
https://projects.fivethirtyeight.com/2022-election-forecast/
Output csv files are located in the output
directory. Here is the data each output csv file contains:
gov_all.csv
: all gubernatoral elections, sorted by expected margingov_competitve.csv
: all gubernatorial elections expected to be within 10 points, sorted by expected marginhouse_all.csv
: all house elections, sorted by expected marginhouse_by_state_all.csv
: all house elections, sorted by statehouse_by_state_competitive.csv
: all house elections expected to be within 10 points, sorted by statehouse_competitve.csv
: all house elections expected to be within 10 points, sorted by expected marginsenate_all.csv
: all senate elections, sorted by expected marginsenate_competitve.csv
: all senate elections expected to be within 10 points, sorted by expected margin
Each output csv file only includes the most relevant information about each election:
district
: name of the contested seatnet
: the expected margin, where-10
means an expected 10 point R win, and10
means an expected 10 point D winD
: name of the Democratic candidateD vote
: expected vote share of the Democratic candidateR
: name of the Republican candidateR vote
: and expected vote share of the Republican candidate