PyBank and PyPoll , both read an individual csv file, analyze data, perform calculations, print summary of analysis to screen and also create an output text file and write summary of analysis to it.
- Used Lists, Dictonaries, Tuples and Sets in both projects. Also used Functions and Error Handling with 'try..except..else..'
- In PyBank, used TUPLE where required and datetime module , lamda function and sort() method to sort data.
- In PyPoll, used SET where required. Used lambda funtion along with python sorted() function.
- Instead of checking candidates name in a for loop to create a unique list of candidates, i used a set.
-
Created a Python script for analyzing the financial records of a company from a set of financial data 'budget_data.csv' that is composed of two columns: Date and Profit/Losses.The script analyzes the records to calculate each of the following:
- The total number of months included in the dataset
- The net total amount of "Profit/Losses" over the entire period
- Calculate the changes in "Profit/Losses" over the entire period, then find the average of those changes
- The greatest increase in profits (date and amount) over the entire period
- The greatest decrease in losses (date and amount) over the entire period
- Analysis looks similar to the one below:
- Folder PyBank : This folder contains two folders
- 'Resources': Contains the financial data 'budget_data.csv'
- 'analysis' : Folder to which the output text file with analysis, will be written.
- Python file 'main.py' that has python script for analyzing the financial data stored in 'Resources/budget_data.csv'
- Used csv.DictReader that reads the data from csv file and creates a dictonary preserving the header with each header field as a key.
- Used 'from datetime import datetime' that imports a module 'datetime' to work with dates as date objects.
- Used tuples to work with data for further analysis.
- Used sort() method to sort and rearrange the list of tuples in order of date
- Used lamda function to sort
- The script is in the file main.py which can be located in the folder PyBank.
- Using PyBank as the working folder, run 'main.py'.
- It has 2 functions readFromCsv(), and analyzeAndWrite()
- The file has detailed comments explaining these functions and code outside the scope of functions
- The following analysis is printed to the terminal and the same result is written to output text file 'analysis/budget_analysis.txt'
- Handled 'Filenotfound' errors in case the script cannot find the source or destination folders/file
- Made sure 'ZeroDivisionError' doesn't occur
- REST ASSURED, The code runs error free. Just Follow these detailed instructions ....
-
Created a Python script for helping a small, rural town modernize its vote counting process by analyzing poll data in 'election_data.csv' that is composed of three columns: Voter ID, County, and Candidate.This script analyzes the votes and calculates each of the following:
- Folder PyPoll : This folder contains two folders
- 'Resources': Contains poll data 'election_data.csv'
- 'analysis' : Folder to which the output text file with analysis, will be written.
- Python file 'main.py' that has python script for analyzing the election_data data stored in 'Resources/election_data.csv'
- Used csv.DictReader that reads the data from csv file and creates a dictonary preserving the header with each header field as a key.
- Used SET to create a unique list of candidates.
- Used lamda function
- Used sorted() function to sort and rearrange the date
- The script is in the file main.py which can be located in the folder PyPoll.
- Using PyPoll as the working folder, run 'main.py'.
- It has 2 functions readFromCsv(), and analyzeAndWrite()
- The file has detailed comments explaining these functions and code outside the scope of functions
- The following analysis is printed to the terminal and the same result is written to output text file 'analysis/election_results.txt'
- Handled 'Filenotfound' errors in case the script cannot find the source or destination folders/file
- Made sure 'ZeroDivisionError' doesn't occur
- REST ASSURED, The code runs error free. Just Follow these detailed instructions ....