election-analysis

Overview of Election Audit

The Colorado Board of Elections commissioned an audit for a local congressional election. This project takes the votes and calculates the results to determine the winner, and breaks down voter percentages by county and by candidate. Results are output into a .txt file.

Resources

  • Data Source: election_results.csv
  • Software: Python 3.9.5, Visual Studio Code 1.56.2

Election-Audit Results

The analysis of the election were output into the file election_analysis.txt. The results are as follows:

  • Total votes cast: 369711

  • Votes by County:

    • Jefferson:

      • 38,855 votes in total
      • 10.51% of all votes
    • Denver:

      • 306,055 votes in total
      • 82.78% of all votes
    • Arapahoe:

      • 24,801 votes in total
      • 6.71% of all votes
    • Largest County Turnout: Denver

  • Results for Each Candidate:

    • Casper Stockham:
      • 85,213 votes in total
      • 23.05% of all votes
    • Diana DeGette:
      • 272,892 votes in total
      • 73.81% of all votes
    • Raymon Anthony Doane:
      • 11,606 votes in total
      • 3.14% of all votes
  • Winner of the Election:

    • Winner: Diana DeGette
    • Winning Vote Count: 272,892 votes
    • Winning Percentage: 73.81%

Election-Audit Summary

This script can easily be used for other election audits, so long as the input file follows a particular format. It should be a .csv file type, with the name "election_results.csv", and placed in a folder named "Resources" . Within the file, the header line should say, "Ballot ID, County, Candidate". The voter data that follows should be organized so that each new line contains the information for one vote that was cast with the information in the same order as the header: Ballot ID, County, Candidate. An example snippet is shown below.

Ballot ID, County, Candidate

ID#1, County1, Candidate1

ID#2, County2, Candidate2

Potential Improvements

One very useful modification to the script that would improve its functionality would be to launch a file-selection window that would enable the user to choose which file (set of voter data) to use upon starting the program. Then the user would not need to follow a specific naming format or file path. Another improvement could be to allow the voter data columns within the election results file to be ordered in any way, so long as the headers line up correctly with the voter data. This way, if the data collection method outputs the results in a different order, the program can still work.