data_visualization_python_code
data_visualization_python_code
import pandas as pd
import numpy as np
def generate_random_data():
districts = ['EKM', 'PTA', 'KTM', 'TSR', 'KKD', 'MPM', 'KLM', 'PKD', 'ALP', 'KNR', 'TVM', 'IDK',
'WYD', 'KGD']
data = {
'Districts': districts,
return pd.DataFrame(data)
def Fun():
print(":)")
print("===================")
print(" ")
print(" Press 1 to print the data for Confirmed cases as per Districts.")
print(" Press 2 to print the data for Recovered cases as per Districts.")
print(" Press 3 to print the data for Death cases as per Districts.")
print(" Press 4 to print the data for Active cases as per Districts.")
print(" ")
print(" Press 1 to print the data for Confirmed cases as per Districts.")
print(" Press 2 to print the data for Recovered cases as per Districts.")
print(" Press 3 to print the data for Death cases as per Districts.")
print(" Press 4 to print the data for Active cases as per Districts.")
print(" ")
print(" ")
print("#6. Exit")
print("===============")
def line_plot(df):
Data Visualization on COVID - Python Code
District = df["Districts"]
Confirmed = df["Confirmed"]
Recovered = df["Recovered"]
Deaths = df["Deaths"]
Active = df["Active"]
plt.xlabel("Districts")
YC = int(input("Enter the number representing your preferred line chart from the above choices:
"))
if YC == 1:
plt.ylabel("Confirmed Cases")
plt.show()
elif YC == 2:
plt.ylabel("Recovered Cases")
plt.show()
elif YC == 3:
plt.ylabel("Death Cases")
plt.show()
Data Visualization on COVID - Python Code
elif YC == 4:
plt.ylabel("Active Cases")
plt.show()
elif YC == 5:
plt.ylabel("Number of cases")
plt.legend()
plt.show()
else:
def bar_plot(df):
District = df["Districts"]
Confirmed = df["Confirmed"]
Recovered = df["Recovered"]
Deaths = df["Deaths"]
Active = df["Active"]
plt.xlabel("Districts")
Data Visualization on COVID - Python Code
YC = int(input("Enter the number representing your preferred bar graph from the above
choices:"))
if YC == 1:
plt.ylabel("Confirmed Cases")
plt.show()
elif YC == 2:
plt.ylabel("Recovered Cases")
plt.show()
elif YC == 3:
plt.ylabel("Death Cases")
plt.show()
elif YC == 4:
plt.ylabel("Active Cases")
plt.show()
elif YC == 5:
plt.legend()
plt.show()
elif YC == 6:
D = np.arange(len(District))
width = 0.25
plt.legend()
plt.show()
else:
def scatter_chart(df):
District = df["Districts"]
Confirmed = df["Confirmed"]
Recovered = df["Recovered"]
Deaths = df["Deaths"]
Active = df["Active"]
Data Visualization on COVID - Python Code
plt.xlabel("District")
plt.legend()
plt.show()
def main_menu():
df = generate_random_data()
Fun()
while True:
try:
except ValueError:
continue
if YC == 1:
print(df)
elif YC == 3:
line_plot(df)
elif YC == 4:
Data Visualization on COVID - Python Code
bar_plot(df)
elif YC == 5:
scatter_chart(df)
elif YC == 6:
break
else:
main_menu()