Merged Sample Code
Merged Sample Code
def execute_choice(choice):
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
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)
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()
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.")