You are on page 1of 35

ID Sheet

Name : Manvesh Singh Sandhu

Class : XII B

Session : 2021-22

Board RollNo : 11647630

Subject : Informatics Practices

Topic : Corona Report on 2022


Acknowledgem
ent
I express my great sense of
gratitude indebtedness and
thanks from the core of my
heart to our principal Mrs.
Vibha Saxena mam and my
teacher Mrs.Geeta Jethwani for
their kind support, wholehearted
cooperation and pain taking
efforts at all stages of this
project. Once again thank you
very much.
Manvesh Singh Sandhu
XII Commerce

CSV FILE
CODING
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
def mainmenu():
print(" ")
print("A. Read data from CSV file in different
way")
print(" ")
print(" 1. Read complete CSV file")
print(" 2. Read complete CSV file without
Index")
print(" ")
print("B. Data Visualization")
print(" ")
print(" 3. Line Chart")
print(" 4. Bar Chart")
print(" ")
print("C. Apply Data Manipulation in the
records of
CSV file")
print(" ")
print(" 5. Sorting the Data as per choice")
print(" 6. Read Top or Bottom records from
CSV file
as per requirement")
print(" 7. Retrieve data from Specific
Columns")
print(" 8. Exchange Row Labels and Column
Labels")
print(" 9. Check Dimensionality of the data")
print(" ")

mainmenu()

def readcsv():
print("Reading data from CSV file")
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python
project.csv")
print(df)

def no_index():
print("Reading complete CSV file without
Index")
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python
project.csv",index_col=0)
print(df)

def line_chart():
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python
project.csv")
States=pd.Series(df["States"].values)
print("Enter a for the year Confirmed")
print("Enter b for the year Recovered")
print("Enter c for the year Deaths")
print("Enter d for all the years together")
ch=input("Enter Your Choice: ")
if ch=='a':

Confirmed=pd.Series(df["Confirmed"].values)
plt.plot(States,Confirmed,
color='b',marker='o')
plt.xlabel("States")
plt.ylabel("Covid Cases")
plt.title("State wise Confirmed Covid
cases")
plt.show()
elif ch=='b':
Recovered=pd.Series(df["Recovered"].values)
plt.plot(States,Recovered,
color='g',marker='o')
plt.xlabel("States")
plt.ylabel("Covid Cases")
plt.title("State wise recovered covid cases
")
plt.show()
elif ch=='c':
Deaths=pd.Series(df["Deaths"].values)
plt.plot(States,Deaths, color='r',marker='o')
plt.xlabel("States")
plt.ylabel("Covid cases")
plt.title("State wise deaths due to covid")
plt.show()
elif ch=='d':
Confirmed=pd.Series(df["Confirmed"].values)

Recovered=pd.Series(df["Recovered"].values)
Deaths=pd.Series(df["Deaths"].values)
plt.plot(States,Confirmed,
color='b',marker='o' ,label='Confirmed')

plt.plot(States,Recovered ,color='g',marker='o' ,
label='Recovered')
plt.plot(States,Deaths ,color='r',marker='o',
label='Deaths')
plt.xlabel("States")
plt.ylabel("Covid Cases")
plt.title("State wise Corona Cases")
plt.legend()
plt.show()
else:
print("Enter Valid Choice !!")
def bar_chart():
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python
project.csv")
States=pd.Series(df["States"].values)
print("Enter a for the Confirmed")
print("Enter b for the Recovered")
print("Enter c for the Deaths")
print("Enter d for all the years together")
ch=input("Enter Your Choice: ")
if ch=='a':

Confirmed=pd.Series(df["Confirmed"].values)
plt.bar(States,Confirmed,color='b')
plt.xlabel("States")
plt.ylabel("Covid Cases")
plt.title("States wise Covid cases")
plt.show()
elif ch=='b':

Recovered=pd.Series(df["Recovered"].values)
plt.bar(States,Recovered,color='g')
plt.xlabel("States")
plt.ylabel("Covid cases")
plt.title("State wise recovered covid cases")
plt.show()
elif ch=='c':
Deaths=pd.Series(df["Deaths"].values)
plt.bar(States,Deaths,color='r')
plt.xlabel("States")
plt.ylabel("Covid cases")
plt.title("State wise deaths due to covid")
plt.show()
elif ch=='d':

Confirmed=pd.Series(df["Confirmed"].values)

Recovered=pd.Series(df["Recovered"].values)
Deaths=pd.Series(df["Deaths"].values)
plt.bar
(States,Confirmed,color='b',label='Confirmed')

plt.bar(States,Recovered,color='g',label='Recov
ered')

plt.bar(States,Deaths,color='r',label='Deaths')
plt.xlabel("States")
plt.ylabel("Covid cases")
plt.title("State wise Covid cases")
plt.legend()
plt.show()
else:
print("Enter Valid Choice !!")

def data_sorting():
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python project.csv")
print(" Enter a to sort records on the basis of
States")
print(" Enter b to sort records on the basis of
Confirmed")
print(" Enter c to sort records on the basis of
Recovered")
print(" Enter d to sort records on the basis of
Deaths")
ch=input("Enter Your Choice: ")
if ch=='a':
df.sort_values(["States"],inplace=True)
print(df)
elif ch=='b':
df.sort_values(["Confirmed"],inplace=True)
print(df)
elif ch=='c':
df.sort_values(["Recovered"],inplace=True)
print(df)
elif ch=='d':
df.sort_values(["Deaths"],inplace=True)
print(df)
else:
print("Enter Valid Choice !!")
def topbottom_selected_records():
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python
project.csv",index_col=0)
print("Enter a to read Top records")
print("Enter b to read Bottom records")
ch=input("Enter Your Choice: ")
if ch=='a':
top=int(input("How many records you
want to
display from top: "))
print("First",top,"records")
print(df.head(top))
elif ch=='b':
bottom=int(input("How many records you
want to
display from bottom:"))
print("Bottom",bottom,"records")
print(df.tail(bottom))
else:
print("Enter Valid Choice !!")

def specific_column():
print(" Enter a to Retrieve the records of
Confirmed")
print(" Enter b to Retrieve the records of
Recovered")
print(" Enter c to Retrieve the records of
Deaths")
ch=input("Enter Your Choice: ")
if ch=='a':
df=pd.read_csv("C:\\Users\\dell\\
Desktop\\Python

project.csv",usecols=['States','Confirmed']
,index_col=0)
print(df)
elif ch=='b':
df=pd.read_csv("C:\\Users\\dell\\
Desktop\\Python
project.csv",usecols=['States','Recovered']
,index_col=0)
print(df)
elif ch=='c':
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python

project.csv",usecols=['States','Deaths']
,index_col=0)
print(df)
else:
print('Enter Valid Choice !!')
def transpose():
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python
project.csv",index_col=0)
print(df.T)
def dimensionality():
df=pd.read_csv("C:\\Users\\dell\\Desktop\\
Python project.csv")
print(df.shape)
print(df.size)
opt=int(input("Enter Your Choice: "))
if opt==1:
readcsv()
elif opt==2:
no_index()
elif opt==3:
line_chart()
elif opt==4:
bar_chart()
elif opt==5:
data_sorting()
elif opt==6:
topbottom_selected_records()
elif opt==7:
specific_column()
elif opt==8:
transpose()
elif opt==9:
dimensionality()
else:
print("Enter Valid Choice !!")
OUTPUT
A. Read data from CSV file in different
way
1. Read complete CSV File :

2. Read complete CSV File without :

B. Data Visualization
3. Line Chart :

Enter A for the year Confirmed

Enter B for the year Recovered


Enter C for the year Deaths

Enter D for all the years together


4. Bar Chart :

Enter A for the Confirmed


Enter B for the Recovered

Enter C for the Deaths


Enter D for all the years together
C. Apply Data Manipulation in the
records of CSV file :
5. Sorting the Data as per choice :

Enter A to sort records on the basis of States


Enter B to sort records on the basis of Confirmed

Enter C to sort records on the basis of Recovered


Enter D to sort records on the basis of Deaths

6. Read Top or Bottom records from CSV


file as per requirement :
Enter A to read Top records

Enter B to read Bottom records


7. Retrieve data from Specific Columns :

Enter A to Retrieve the records of Confirmed


Enter B to Retrieve the records of Recovered

Enter C to Retrieve the records of Deaths


8. Exchange Row Labels and Column
Labels :

9. Check Dimensionality of the data :

You might also like