Covid-19 Analysis

Analysis on Covid-19 in India with Python

Get csv and file here

#Importing libraries
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
df = pd.read_csv("Covid cases in India.csv")
print(df.head())

#Output
 S.No. Name of State / UT … Cured Death
0 1    Andhra Pradesh     …    2   4
1 2    Chhattisgarh       …    2   3
2 3    Delhi              …   50 104
3 4    Gujarat            …   25  8
4 5    Haryana            …   11  3
# removing 'S.No' column
df.drop(['S. No.'], axis=1, inplace=True)
print(df.head())

#Output
df['Total Cases'] = df['Total Confirmed cases (Indian National)']+df['Total Confirmed cases ( Foreign National )']
print(df.head())

#Output
total_cases_overall = df['Total Cases'].sum()
print('Total number cases in India are',total_cases_overall)

#Output
Total number cases in India are 20873
df['Active Cases']= df['Total Cases']-(df['Death']+df['Cured'])
print(df.head())

#Output
Total_Active_Cases = df.groupby('Name of State / UT')['Total Cases'].sum().sort_values(ascending=False).to_frame()
Total_Active_Cases.style.background_gradient(cmap='Reds')
print(Total_Active_Cases)

#Output
df.plot(kind='bar', x='Name of State / UT', y='Total Cases')
plt.show()

#Output

4 Comments

Leave a Reply