Python-Based Financial and Election Analyses: A Case Study

Resources


Project Objectives


PyBank

Use the budget data provided to analyze the financial records of a company.

The task is to create a Python script that analyzes the records and:

  1. Calculates the total number of months included in the dataset
  2. Calculates the net total amount of “Profit/Losses” over the entire period
  3. Calculates the changes in “Profit/Losses” over the entire period, and then the average of those changes
  4. Calculates the greatest increase in profits (date and amount) over the entire period
  5. Calculates the greatest decrease in profits (date and amount) over the entire period
  6. Exports the results to a text file in the analysis folder

PyPoll

Use the election results provided to complete the audit of a recent local congressional election.

The task is to create a Python script that analyzes the records and:

  1. Calculates the total number of votes cast
  2. Retrieves the counties where the votes were collected
  3. Calculates the voting results from each county
  4. Determines the county with the largest number of votes
  5. Retrieves a complete list of candidates who received votes
  6. Calculates the total number and percentage of votes each candidate received
  7. Determines the winner of the election based on the amount of votes received
  8. Exports the results to a text file in the analysis folder

Results & Analysis


PyBank

Screenshot

There were 86 total months included in the dataset. The net total amount was $22,564,198 and the average change on a month-to-month basis was $-8,311.11. The greatest increase in profits was $1,862,002 which occurred in August 2016 and the greatest decrease in profits was $-1,825,558 which occurred in February 2014.

PyPoll

Screenshot

There were 369,711 total votes cast in the election. The counties where the votes were collected were Jefferson County, Denver County, and Arapahoe County.

Screenshot

The county with the largest number of votes was Denver County with 306,055 votes or 82.8% of the total votes.

Screenshot

Based on the candidate results above, the winner of the election is Diana DeGette, who received 272,892 votes or 73.8% of the total votes.

Drawing Insights


PyBank

This script can be used to analyze any financial data. It was able to determine on its own how many months there were, calculate the net total amount, the average change, the greatest increase in profit and corresponding month, and the greatest decrease in profit and corresponding month. Some modifications that can be made to the script are:

PyPoll

This script can be used to analyze any election. It was able to determine on its own how many different candidates and counties were in the results. It also tallied the votes for each candidate, determined the winning candidate from the total votes, and found which county had the most effect on the outcome of the election. Some modifications that can be made to the script are:


Return to the Homepage