Latest Code 2
Latest Code 2
file_name = "g:\\covid_19_india.csv"
while(True):
print("Main Menu")
print("1. Fetch data")
print("2. Dataframe Statistics")
print("3. Display Records")
print("4. Working on Records")
print("5. Working on Columns")
print("6. Data Visualization")
print("7. Exit")
ch=int(input("Enter your choice: "))
if ch==1:
human=pd.read_csv("covid_19_india.csv")
print("----------Data read from file {}
successful----------".format(file_name))
elif ch==2:
while (True):
print("Dataframe Statistics Menu")
print("1. Display the Transpose")
print("2. Display all column names")
print("3. Display the indexes")
print("4. Display the shape")
print("5. Display the dimension")
print("6. Display the data types of all columns")
print("7. Display the size")
print("8. Exit")
ch2=int(input("Enter choice: "))
if ch2==1:
print(human.T)
elif ch2==2:
print(human.columns)
elif ch2==3:
print(human.index)
elif ch2==4:
print(human.shape)
elif ch2==5:
print(human.ndim)
elif ch2==6:
print(human.dtypes)
elif ch2==7:
print(human.size)
elif ch2==8:
break
elif ch==3:
while(True):
print("Display Records Menu")
print("1. Top 5 Records")
print("2. Bottom 5 Records")
print("3. Specific number of records from the top")
print("4. Specific number of records from the bottom")
print("5. Details of a specific State")
print("6. Exit")
ch3=int(input("Enter choice: "))
if ch3==1:
print(human.head())
elif ch3==2:
print(human.tail())
elif ch3==3:
n=int(input("Enter how many records you want to display from the
top: "))
print(human.head(n))
elif ch3==4:
n=int(input("Enter how many records you want to display from the
bottom: "))
print(human.tail(n))
elif ch3==5:
st=input("Enter the state name for which you want to see the
details: ")
print(human.loc[human["State"]==st])
elif ch3==6:
break
elif ch==4:
while(True):
print("Working on Records Menu")
print("1. Insert a specific state Record")
print("2. Delete a specific state Record")
print("3. Update a specific state Record")
print("4. Exit")
ch4=int(input("Enter choice: "))
if ch4==1:
a=input("Enter state name: ")
d=int(input("Enter new number of cured patients: "))
e=int(input("Enter new number of death(s): "))
f=int(input("Enter new number of confirmed case(s): "))
human.loc['State'==a,['Cured']]=d
human.loc[human["State"]==a]['Deaths']=e
human.loc[human["State"]==a]['Confirmed']=f
#human.loc[human["State"]==a]=[d,e,f]
print("----------Data successfully inserted----------")
elif ch4==2:
a=input("Enter state name whose data needs to be deleted: ")
print(human.drop(a,inplace=False))
choi=input("Confirm")
if choi=="Y"or choi=="y":
human.drop(a,inplace=True)
print("----------Data successfully deleted----------")
elif ch4==3:
b=input("Enter new state name that needs to be updated: ")
e=int(input("Enter new number of cured case(s): "))
f=int(input("Enter new number of death(s): "))
g=int(input("Enter new number of confirmed case(s): "))
human.loc[human["State"]==b]['Cured']=e
human.loc[human["State"]==b]['Cured']=f
human.loc[human["State"]==b]['Cured']=g
#human.loc[human["State"]==b]=[e,f,g]
print("----------Data successfully updated----------")
elif ch4==4:
break
elif ch==5:
while(True):
print("Working on Columns Menu")
print("1. Insert a new column data")
print("2. Delete a specific column")
print("3. Exit")
print ("ADDITION AND DELETION ON COLUMNS NOT ALLOWED IN MY PROJECT")
elif ch==6:
while (True):
print("Data visualization Menu")
print("1. Line Plot")
print("2. Vertical Bar plot")
print("3. Horizontal Bar Plot")
print("4. Exit")
ch6=int(input("Enter choice"))
if ch6==1:
n=int(input("How many states from the top you want to plot?"))
df=human.head(n)
mb=df['Cured']
fb=df['Deaths']
ma=df['Confirmed']
s=df.index
plt.plot(s,mb,label="number of people cured")
plt.plot(s,fb,label="number of people died")
plt.plot(s,ma,label="total number of cases")
plt.title("Line Graph representing statewise numbers")
plt.xlabel("STATES")
plt.ylabel("COVID DATA")
plt.xticks(rotation=30)
plt.legend()
plt.grid(True)
plt.show()
elif ch6==2:
n=int(input("How many states from the top you want to plot?"))
df=human.head(n)
df.plot(kind="bar")
plt.title("Bar Graph representing statewise numbers")
plt.xlabel("STATES")
plt.ylabel("COVID DATA")
plt.show()
elif ch6==3:
n=int(input("How many states from the top you want to plot?"))
df=human.head(n)
df.plot(kind="barh")
plt.title("Horizontal Bar Graph representing statewise numbers")
plt.xlabel("COVID DATA")
plt.ylabel("STATES")
plt.show()
elif ch6==4:
break
elif ch==7:
break