0% found this document useful (0 votes)
2 views8 pages

Merged Sample Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

Merged Sample Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

def display_menu():

print("Choose a number between 1 and 6 to see:")


print("1. Total Vaccine Administered Dose Wise and State
Wise")
print("2. Total Vaccine Administered Gender Wise and
State Wise")
print("3. Total of Each Type of Vaccine and State Wise")
print("4. Total of Individuals Vaccinated State Wise")
print("5. Average of Doses Administered, Each Type of
Vaccine, Genders Vaccinated")
print("6. Highest and Lowest Vaccinated State in India")
print("7. To see the plots for various categories ")
print("Enter '0' to exit.")

def execute_choice(choice):
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Load the dataset


Vdf =
pd.read_csv('/kaggle/input/vaccineindia2021/Vaacine.csv')

def display_menu():
print("Choose a number between 1 and 6 to see:")
print("1. Total Vaccine Administered Dose Wise and State
Wise")
print("2. Total Vaccine Administered Gender Wise and
State Wise")
print("3. Total of Each Type of Vaccine and State Wise")
print("4. Total of Individuals Vaccinated State Wise")
print("5. Average of Doses Administered, Each Type of
Vaccine, Genders Vaccinated")
print("6. Highest and Lowest Vaccinated State in India")
print("Enter '0' to exit.")

def execute_choice(choice):
if choice == '1':
print("Total Vaccine Administered Dose Wise and State
Wise")
a = Vdf.groupby('State')['First Dose
Administered'].sum()
b = Vdf.groupby('State')['Second Dose
Administered'].sum()
c = Vdf.groupby('State')['Total Doses
Administered'].sum()
print("\nState Wise - Total First Dose Administered\n",
a)
print("\nState Wise - Total Second Dose Administered\
n", b)
print("\nState Wise - Total Third Dose Administered\
n", c)
tot_first_doses = Vdf['First Dose Administered'].sum()
tot_second_doses = Vdf['Second Dose
Administered'].sum()
tot_doses = Vdf['Total Doses Administered'].sum()
print("\nTotal First Dose Administered in India =",
tot_first_doses)
print("Total Second Dose Administered in India =",
tot_second_doses)
print("Total Doses Administered in India =", tot_doses)
elif choice == '2':
print("Total Vaccine Administered Gender Wise and
State Wise")
d = Vdf.groupby('State')['Male (Doses
Administered)'].sum()
e = Vdf.groupby('State')['Female (Doses
Administered)'].sum()
f = Vdf.groupby('State')['Transgender (Doses
Administered)'].sum()
print("\nState Wise - Total Males Vaccinated\n", d)
print("\nState Wise - Total Females Vaccinated\n", e)
print("\nState Wise - Total Transgenders Vaccinated\
n", f)

elif choice == '3':


print("Total of Each Type of Vaccine and State Wise")
j = Vdf.groupby('State')['Covaxin (Doses
Administered)'].sum()
k = Vdf.groupby('State')['CoviShield (Doses
Administered)'].sum()
l = Vdf.groupby('State')['Sputnik V (Doses
Administered)'].sum()
print("\nState Wise - Total Covaxin Vaccinated\n", j)
print("\nState Wise - Total CoviShield Vaccinated\n", k)
print("\nState Wise - Total Sputnik Vaccinated\n", l)

elif choice == '4':


print("Total of Individuals Vaccinated State Wise")
g = Vdf.groupby('State')['Total Individuals
Vaccinated'].sum()
print("\nTotal of Individuals Vaccinated State Wise\n",
g)

elif choice == '5':


print("Average of Each Doses Administered, Each Type
of Vaccine, Genders Vaccinated")
h = Vdf[['First Dose Administered', 'Second Dose
Administered', 'Total Doses Administered']].mean()
print("\nAverage of Each Doses Administered\n", h)
i = Vdf[['Covaxin (Doses Administered)', 'CoviShield
(Doses Administered)', 'Sputnik V (Doses
Administered)']].mean()
print("\nAverage of Each Type of Vaccines
Administered\n", i)

elif choice == '6':


print("The Highest and the Lowest Vaccinated State in
India")
max_vaccinated = Vdf['Total Individuals
Vaccinated'].max()
min_vaccinated = Vdf['Total Individuals
Vaccinated'].min()
highest_state = Vdf[Vdf['Total Individuals Vaccinated']
== max_vaccinated]['State']
lowest_state = Vdf[Vdf['Total Individuals Vaccinated']
== min_vaccinated]['State']
print("State with Highest Vaccinated Population:",
highest_state.values[0])
print("State with Least Vaccinated Population:",
lowest_state.values[0])
elif choice == '7':
import matplotlib.pyplot as plt
def display_graph_menu():
print("\nPlease select one of the following options
for Graphical Comparison:")
print("1. Gender Wise Total and Average Vaccines
Administered")
print("2. Doses Wise Total and Average Vaccines
Administered")
print("3. Average and Total of Each Type of Vaccines
Administered")
print("4. Average and Total of Each State's Population
Vaccines Administered")
print("0. Exit")

def gender_wise_comparison(Vdf):
print("Displaying Line Graph for Gender Wise
Comparison of Total Vaccines Administered.\n")
a = Vdf['Male (Doses Administered)'].sum()
b = Vdf['Female (Doses Administered)'].sum()
c = Vdf['Transgender (Doses Administered)'].sum()
y = ['Male (Doses Administered)', 'Female (Doses
Administered)', 'Transgender (Doses Administered)']
plt.plot(y, [a, b, c])
plt.title('Comparison of Total Doses Administered
Gender Wise', color='red')
plt.xlabel("Gender", color='red', fontsize=11)
plt.ylabel("Total Doses", color='Green', fontsize=11)
plt.show()
def doses_wise_comparison(Vdf):
print("Displaying Bar Graph for Doses Wise Total
Vaccines Administered\n")
tot_first = Vdf['First Dose Administered'].sum()
tot_second = Vdf['Second Dose Administered'].sum()
tot_total = Vdf['Total Doses Administered'].sum()
plt.bar(['First Dose', 'Second Dose', 'Total Doses'],
[tot_first, tot_second, tot_total])
plt.title('Doses Wise Total Vaccines')
plt.xlabel("Dose Type", color='red', fontsize=11)
plt.ylabel("Total Doses", color='Green', fontsize=11)
plt.show()

def average_type_vaccine_comparison(Vdf):
print("Displaying Bar Graph for Average of Each Type
of Vaccines Administered\n")
covaxin_avg = Vdf['Covaxin (Doses
Administered)'].mean()
covishield_avg = Vdf['CoviShield (Doses
Administered)'].mean()
sputnik_avg = Vdf['Sputnik V (Doses
Administered)'].mean()
plt.bar(['Covaxin', 'CoviShield', 'Sputnik V'],
[covaxin_avg, covishield_avg, sputnik_avg])
plt.title('Average of Each Type of Vaccines
Administered')
plt.xlabel("Vaccine Type", color='blue', fontsize=11)
plt.ylabel("Average Doses", color='purple',
fontsize=11)
plt.show()
def state_population_vaccine_comparison(Vdf):
print("Displaying Bar Graph for Average of Each
State's Population Vaccines Administered\n")
avg_vaccine_per_state = Vdf.groupby('State')['Total
Individuals Vaccinated'].mean()
avg_vaccine_per_state.plot(kind='bar',
color='skyblue')
plt.title("Average of Each State's Population Vaccines
Administered")
plt.xlabel("State", color='blue', fontsize=11)
plt.ylabel("Average Doses", color='purple',
fontsize=11)
plt.xticks(rotation=90)
plt.show()

# Main interactive loop


while True:
display_graph_menu()
choice = input("Enter the number of your choice(1 to 4)
or '0' to exit: to see a plot ")

if choice == '0':
print("Exiting...")
break
elif choice == '1':
gender_wise_comparison(Vdf)
elif choice == '2':
doses_wise_comparison(Vdf)
elif choice == '3':
average_type_vaccine_comparison(Vdf)
elif choice == '4':
state_population_vaccine_comparison(Vdf)
else:
print("Invalid choice. Please enter a number between
1 and 4, or '0' to exit.")

while True:
display_menu()
choice = input("Enter the number of your choice (1 to 7)
or '0' to exit: ")

if choice == '0':
print("Exiting...")
break
elif choice in ['1', '2', '3', '4', '5', '6', '7']:
execute_choice(choice)
else:
print("Invalid choice. Please enter a number between 1
and 7, or '0' to exit.")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy