IP Project Complete Color Coded Justification-Aligned Outputs Changed
IP Project Complete Color Coded Justification-Aligned Outputs Changed
VACCINATION ANALYSIS
SOFTWARE
SUBMITTED TO:- SUBMITTED BY:-
Mrs. Neelam Mr. Lovisht Chawla
(PGT Computer Science) XII - Science
CERTIFICATE
Mrs.Neelam
(Internal Examiner) (External Examiner)
Table of content
S. Pg.
No.
Content No.
1. Acknowledgement 4
2. Objective 5
3. Python 6-7
5. Pandas 10
14. Bibliography 55
Acknowledgement
Seaborn
Seaborn is a Python data visualization library
based on matplotlib. It provides a high-level
interface for drawing attractive and informative
statistical graphics.
Importlib- Module
The purpose of the importlib package is two-
fold. One is to provide the implementation of
the import statement in Python source code.
Two, the components to implement import are
exposed in this package, making it easier for
users to create their own custom objects.
Sys- Module
This module provides access to some variables
used or maintained by the interpreter and to
functions that interact strongly with the
interpreter. It is always available.
COVID-19
Vaccination Analysis
It includes overseeing the total no. of doses
administered in a day, the no. of first and
second doses, which type of vaccine was
administered in which quantity, how many
individuals have been vaccinated, how many
of them were in the age group of 18-44,45-60
or 60+,how many individuals were male,
female, transgenders etc.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import importlib as imp
import sys
import Analysis
df= pd.read_csv('Analysis.csv')
dataframe=pd.DataFrame(df, columns=['Index',
'DOU', 'Total_Doses(in Cr)', 'First_Dose(in Cr)',
'Second_Dose(in Cr)', 'CoviShield(in Cr)',
'Covaxin(in Cr)', 'Sputnik_V(in Lakhs)', '18-
44_Years(in Cr)', '45-60_Years(in Cr)',
'60+Years(in Cr)', 'Males(in Cr)', 'Females(in Cr)',
'Transgender(in Lakhs)', 'Total_Individuals(in Cr)'
])
def MainPage():
Y=0
print(" ")
print(" Welcome to Vaccination Analysis
Program ")
print(" ")
print("1. To See the Complete Dataset")
print("2. To See Graphs on the Basis of Type of
Vaccine")
print("3. To See Graphs on the Basis of Age
Group")
print("4. To See Graphs on the Basis of Gender")
print("5. To Enter New Records in the File")
print("6. To Modify/Update Records in the File")
print("7. To Delete Records in the File")
print("8. To Exit the Program")
print(" ")
Y=int(input("Enter your choice:"))
if Y==1:
showdata()
elif Y==2:
barplot()
elif Y==3:
lineplot()
elif Y==4:
piechart()
elif Y==5:
insert()
elif Y==6:
modify()
elif Y==7:
delete()
elif Y==8:
exit_program()
else:
MainPage_invalid()
def MainPage_invalid():
print(" ")
print("Invalid Value.....")
print("Please select again")
print(" ")
MainPage()
def showdata():
print(" ")
print(dataframe)
print(" ")
input("Press any key to return to main
menu....")
print(" ")
MainPage()
def barplot():
Y=0
print(" ")
print(" Types Of Vaccines Given to
Individuals ")
print(" ")
print("1. Covishield Doses Administered")
print("2. Covaxin Doses Administered")
print("3. Sputnik_V Doses Administered")
print("4. Go back to Main Menu")
print(" ")
Y=int(input("Enter your choice to get the
barplot: "))
if Y==1:
barplot_covishield()
elif Y==2:
barplot_covaxin()
elif Y==3:
barplot_sputnik_v()
elif Y==4:
MainPage()
else:
barplot_invalid()
def barplot_covishield():
CoviShield=df["CoviShield(in Cr)"]
DOU=df["DOU"]
sns.barplot(x=DOU,y='CoviShield(in Cr)',data=
df, palette="magma")
df, palette="magma")
plt.title("No. Of CoviShield Administered")
plt.show()
print(" ")
barplot()
def barplot_covaxin():
Covaxin=df["Covaxin(in Cr)"]
DOU=df["DOU"]
sns.barplot(x=DOU,y='Covaxin(in Cr)',data=
df, palette="mako")
df, palette="mako")
plt.title("No. Of Covaxin Administered")
plt.show()
print(" ")
barplot()
def barplot_sputnik_v():
Sputnik_V=df["Sputnik_V(in Lakhs)"]
DOU=df["DOU"]
sns.barplot(x=DOU,y='Sputnik_V(in Lakhs)',
data=
data= df,palette="viridis")
df,palette="viridis")
plt.title("No. Of Sputnik_V Administered")
plt.show()
print(" ")
barplot()
def barplot_invalid():
print(" ")
print("Invalid Value.....")
print("Please select again")
print(" ")
barplot()
def lineplot():
print(" ")
print(" Vaccination Analysis by Age Group ")
print(" ")
print("1. Line Graph for 18-44 Years")
print("2. Line Graph for 45-60 Years")
print("3. Line Graph for 60+ Years")
print("4. Line Graph for all the Three Age
Groups")
print("5. Go back to Main Menu")
print(" ")
Y=int(input("Enter your choice to get the
lineplot:"))
if Y==1:
lineplot_18_44()
elif Y==2:
lineplot_44_60()
elif Y==3:
lineplot_60_above()
elif Y==4:
lineplot_all()
elif Y==5:
MainPage()
else:
lineplot_invalid()
def lineplot_18_44():
dataframe.plot(x='DOU', y="18-44_Years(in
Cr)",
Cr)", kind="line",
kind="line", figsize=(9,9),xlabel='By
figsize=(9,9),xlabel='By the
theylabel='No
Date', Date',ylabel='No ofAdministered
of Doses Doses Administered
in Age
in AgeCr)',title="18-44
Group(in Group(in Cr)',title="18-44
Years") Years")
plt.show()
print(" ")
lineplot()
def lineplot_44_60():
dataframe.plot(x='DOU', y="45-60_Years(in
Cr)", kind="line",
Cr)", figsize=(9,9),xlabel='By
kind="line", the
figsize=(9,9),xlabel='By
Date',
theylabel='No of Doses
Date',ylabel='No ofAdministered in Age
Doses Administered
Group(in
in Age Cr)',title="45-60 Years",
Group(in Cr)',title="45-60 Years",
color="orange")
color="orange"))
plt.show()
print(" ")
lineplot()
def lineplot_60_above():
dataframe.plot(x='DOU', y="60+Years(in Cr)",
kind="line",figsize=(9,9),xlabel='By
kind="line", figsize=(9,9),xlabel='By the the Date',
Date',
ylabel='No
ylabel='No of Doses
of Doses Administered
Administered in Age
in Age Group(in
Group(in
Cr)', Cr)',title="60+
title="60+ Years", color="green")
Years", color="green")
plt.show()
print(" ")
lineplot()
def lineplot_all():
dataframe.plot(x='DOU', y=['18-44_Years(in
Cr)','45-60_Years(in
Cr)' , '45-60_Years(inCr)','60+Years(in Cr)'], Cr)'],
Cr)' , '60+Years(in
kind="line",figsize=(9,9),xlabel='By
kind="line" ,figsize=(9,9),xlabel='By the Date',
the Date'
ylabel='No of Doses
, ylabel='No of Administered in Age Group(in
Doses Administered in Age
Cr)', title="All
Group(in age
Cr)' groups") age groups")
, title="All
plt.show()
print(" ")
lineplot()
def lineplot_invalid():
print(" ")
print("Invalid Value.....")
print("Please select again")
print(" ")
lineplot()
def piechart():
print(" ")
print(" Vaccination Analysis by Gender ")
print(" ")
print("1. Pie Chart for Males")
print("2. Pie Chart for Females")
print("3. Pie Chart for Transgender")
print("4. Go back to Main Menu")
print(" ")
Y=int(input("Enter your choice to get the
barplot:"))
pie-chart:")
if Y==1:
piechart_male()
elif Y==2:
piechart_female()
elif Y==3:
piechart_transgender()
elif Y==4:
MainPage()
else:
piechart_invalid()
def piechart_male():
x=dataframe["Males(in Cr)"]
y=dataframe["DOU"]
plt.pie(x,labels=y, shadow=False,
wedgeprops = { 'linewidth'
wedgeprops : 1, 'edgecolor'
= { 'linewidth' : 'white' :
: 1, 'edgecolor'
}, autopct='%.2f')
'white' }, autopct='%.2f')
plt.title("No. of Doses Administered on
Males")
Males")
plt.legend(title='Dates')
plt.show()
print(" ")
piechart()
def piechart_female():
x=dataframe["Females(in Cr)"]
y=dataframe["DOU"]
plt.pie(x,labels=y,shadow=False,
wedgeprops
wedgeprops= { 'linewidth' : 1, 'edgecolor'
= { 'linewidth' : 'white' :
: 1, 'edgecolor'
},autopct='%.2f')
'white' }, autopct='%.2f')
plt.title("No. of Doses Administered on
Females")
Females")
plt.legend(title='Dates')
plt.show()
print(" ")
piechart()
def piechart_transgender():
x=dataframe["Transgender(in Lakhs)"]
y=dataframe["DOU"]
plt.pie(x,labels=y, shadow=False,
wedgeprops
wedgeprops = { 'linewidth'
= { 'linewidth' : 1, 'edgecolor'
: 1, 'edgecolor' : 'white' :
'white' }, autopct='%.2f')
},autopct='%.2f')
plt.title("No. of Doses Administered on
Transgenders")
Transgenders")
plt.legend(title='Dates')
plt.show()
print(" ")
piechart()
def piechart_invalid():
print(" ")
print("Invalid Value.....")
print("Please select again")
print(" ")
piechart()
def reload():
imp.reload(Analysis)
def insert():
print(" ")
print("Insert data of particular dates:")
print(" ")
idx=int(input("Enter Indexing No.: "))
du=input("Enter Date of Updation: ")
total_doses=float(input("Enter Total Doses(in
Cr): "))
f_doses=float(input("Enter No. of First
Doses(in Cr): "))
s_doses=float(input("Enter No. of Second
Doses(in Cr): "))
Covi=float(input("Enter Total No. of
Covishield(in Cr): "))
Cova=float(input("Enter Total No. of Covaxin(in
Cr): "))
Sput=float(input("Enter Total No. of
Sputnik_V(in Lakhs): "))
firstage=float(input("Enter Total No. of Doses
in 18-44 Years Age Group(in Cr): "))
secondage=float(input("Enter Total No. of
Doses in 45-60 Years Age Group(in Cr): "))
thirdage=float(input("Enter Total No. of Doses
in 60+ Years Age Group(in Cr): "))
M=float(input("Enter Total No. of Doses
Administered on Males(in Cr): "))
F=float(input("Enter Total No. of Doses
Administered on Females(in Cr): "))
T=float(input("Enter Total No. of Doses
Administered on Transgenders Vaccinated(in
Lakhs): "))
Total=float(input("Enter Total Individuals
Vaccinated(in Cr): "))
d={'DOU':du,'Total_Doses(in Cr)' :total_doses,
'First_Dose(in Cr)':f_doses,'Second_Dose(in
Cr)': s_doses, 'CoviShield(in Cr)':Covi,
'Covaxin(in Cr)': Cova, 'Sputnik_V(in
Lakhs)':Sput, '18-44_Years(in Cr)':firstage,
'45-60_Years(in Cr)': secondage, '60+Years(in
Cr)': thirdage,'Males(in Cr)': M, 'Females(in
Cr)':F, 'Transgender(in Lakhs)':T,
'Total_Individuals(in Cr)':Total}
df=pd.DataFrame(d,index=[idx])
df.to_csv('Analysis.csv',mode='a',header=False)
print(" ")
print("Data has been added.")
print("Returning to Main Menu...")
print(" ")
reload()
def modify():
df=pd.read_csv("Analysis.csv")
print(" ")
idx=int(input("Enter index number to edit:"))
col=input("Enter column name to update:")
val=input("Enter new value:")
df.loc[df[df['Index']==idx].index.values,col]=val
df.to_csv("Analysis.csv",index=False)
print(" ")
print("Record has been updated...")
print("Returning to Main Menu...")
print(" ")
reload()
def delete():
print(" ")
idx=int(input("Enter index number to delete
data:"))
df=pd.read_csv("Analysis.csv")
if idx<=15:
df=df[df.Index!=idx]
df.to_csv('Analysis.csv',index=False)
print(" ")
print("Record deleted...")
print("Returning to Main Menu...")
print(" ")
reload()
def exit_program():
print(" ")
print("Thank you for using Vaccination Analysis
Program")
print("We hope that this program was helpful to
you")
print(" ")
sys.exit()
MainPage()
Outputs
CSV File- "Analysis.csv"
Outputs
Python File- "Analysis.py"
#On pressing the key F5 in "Analysis.py" in Python Script mode, the
welcome screen appears with a list of options.
Welcome Screen:-
#The user can give his choice as an input in the "Enter you choice:"
field.
int() function has been used such that the user can only give an
integer as his choice. Integers other than the provided numbers
(i.e. 1-8), strings, boolean, any other value will result into an error
and a message will be printed stating the error as "Invalid value"
input() function has been used to provide the user with an area to
give his/her choice as a command.
Condition statements (i.e. if, elif, else) have been used to identify
the choice provided by the user and generate the results
accordingly.
# On giving the value 1 as your input, the complete data from the csv
file is printed as a dataframe (dataframe is an attribute of Pandas
library in Python). It gives the data an index starting from zero to n
index value.
Choice as 1:-
Choice as 2:-
# We have defined each choice as one function which plots the graph,
by taking the values from csv file, once called. Each function is given
under if or elif condition. Under else condition the defined function
barplot_invalid() is called.
Choice 2-Barplot() Function
Choosing the values under the function barplot(), we get the bar
graph with x-axis as Date of Updation and y-axis as the type of
vaccine. The plotting of graph is done using the seaborn.barplot()
function of seaborn library in Python.
Choice as 1:-
Choice as 3:-
Choice as 3:-
Choosing the values under the function lineplot(), we get the line
graph with x-axis as Date of Updation and y-axis as the doses
administered in a specific age group. The plotting of graph is done
using the dataframe.plot() function of Python.
The various attributes of used are:-
1. kind which defines the type of graph(i.e. bar, line, histo);
2. xlabel which defines the label of x-axis;
3. ylabel which defines the label of y-axis;
4. title which defines the title of the graph.
Choice as 1:-
Choice as 2:-
Choice as 3:-
Choice as 4:-
Choice as 4:-
Choosing the values under the function piechart(), we get the pie
chart with the labels as the Date of Updation and percentage
showing the percent of vaccines administered. The plotting of pie
chart is done using the plt.pie() function of Matplotlib library
from Python.
The various attributes of matplotlib.pyplot used are:-
1. labels which define the label of the pie chart;
2. shadow which defines the shadow value for wedges of pie chart;
3. wedgeprops which defines the properties of the wedge like line-
width, color etc.;
4. legend which is used to place a legend on the axes;
5. autopct which defines the percent value using Python string
formatting
Choice as 1:-
Choice as 2:-
Choice as 3:-
Choice as 5:-
# Now back on the Main Menu, if you select the value as 6, an option
appears to type in the Index value of the record that you want to
update. After entering the Index value, the column name needs to be
entered and then type in the new value for the specific index of a
specific column. The details are updated into the csv file.
Choice as 6:-
Updated Values:-
# Now looking at the updated graphs:-
Bar Graphs:-
Bar Graph 1
Bar Graph 2
Bar Graph 3
Line Graphs:-
Line Graph 1
Line Graph 2
Line Graph 3
Line Graph 4
Pie Charts:-
Pie Chart 1
Pie Chart 2
Pie Chart 3
# Now back on the Main Menu, if you select the value as 7, an option
appears to type in the Index value of the record that you want to
delete. After entering the Index value, the column get deleted. The
MainPage() is reloaded and the values are updated.
Choice as 7:-
Choice as 8:-
Software
Requirements
Python 3 Compiler
Spreadsheet software like excel,
calc etc.
Snipping tool
Bibliography
For source code completion
Preeti Arora IPP book(XI & XII)
https://www.javatpoint.com/python-sys-module
https://www.geeksforgeeks.org/python-
programming-language/?ref=shm
https://stackoverflow.com/questions/tagged/python
https://www.w3schools.com/python/python_function
s.asp
https://www.python-graph-gallery.com/pie-plot-
matplotlib-basic
For images:-
Canva Image & Graphics library
https://commons.wikimedia.org/wiki/File:Matplotlib_i
con.svg
https://seaborn.pydata.org/citing.html
For Content:-
Wikipedia
Preeti Arora IPP book(XI & XII)
https://seaborn.pydata.org/index.html
https://matplotlib.org/
https://docs.python.org/3/library/sys.html
https://docs.python.org/3/library/importlib.html
For Creating the Project Report:-
https://www.canva.com/