An employee from the Colorado Board of Elections has given me the following tasks to complete for the election audit of a recent local congressional election.
- Calculate the total number of votes cast.
- Get a complete list of candidates who received votes.
- Calculate the total number of votes each candidate received.
- Calculate the percentage of votes each candidate won.
- Determine the winner of the election based on popular vote.
- Data Source: election_results.csv
- Software: Python 3.7.6, PyCharm 2020.2.3 (Professional Edition) Build #PY-202.7660.27, built on October 6, 2020
The analysis of the election shows the following:
- There were "x" votes cast in the election.
- The candidates were: Charles Casper Stockham (Candidate 1) Diana DeGette (Candidate 2) Raymon Anthony Doane (Candidate 3)
- The candidate results were:
- Charles Casper Stockham received 23.0% of the votes or 85,213 of the total votes.
- Diana DeGette received 73.8% of the votes or 272,892 of the total votes.
- Raymon Anthony Doane received 3.1% of the votes or 11,606 of the total votes.
- The winner of the election was:
- Candidate 2, Diana DeGette, was the winner with 73.8% of the popular vote received. Her total vote count was 272,892.
This challenge was tough at first but makes a lot of sense retrospectively. I believe this has to do with the structure of Python and its syntax. At first, I was writing many lines of code. Then, with the help of the notebook, I learned techniques to set variables and loop the same structure of code again and again. As long as the data required the same output, it was easy to organize it so it would deliver the same code. For example, each candidate falls into a candidate category. They have different names which allows the code to indentify and count for that candidate given a certain command. This can be structured so that it follows a line of path for each candidate in the category and deliver the results for each of them respectively.
My learning curve came when I had to enlargen my vision of the data to see the bigger picture. I looked at the data and saw how extensive it was. By understanding which variables were needed and what the desired outcome was, I wrote code that could do it all quickly and efficiently.
The title of my week's journey with this challenge is "Wrestling and wrangling a Python." I finally delivered on the desired outcomes of the audit after a long time of coding and pseudocoding. It helped me write out the steps I wanted to accomplish and then consolidate with a more efficent line of code. I started to see the world differently, is that normal?
Furthermore, I studied Political Philosophy at Utah Valley University before pursuing Data Science with Columbia University in New York City. From my studies, I learned about the formation of government and its effects on the governed. To end this Election Analysis of a few candidates running for a congressional district nomination in Colorado, I'll quote Alexander Hamilton who said in Federalist Paper number 1 that:
"Vigor of government is essential to the security of liberty; that, in the contemplation of a sound and well-informed judgment, their interest can never be separated; and that a dangerous ambition more often lurks behind the specious mask of zeal for the rights of the people than under the forbidden appearance of zeal for the firmness and efficiency of government”
By helping with this analysis, I played a role in the government to audit an election and determine the will of the people. Although the perfect candidate may or may not have been chose, the popular candidate should represent the will of the people and their desire for a certain candidate in their district.