__STYLES__
Tools used in this project
Covid-19 Data Analysis

About this project

Import Libraries

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

## For better interactive visualization
import plotly.graph_objects as go
import plotly.express as px

import warnings
warnings.filterwarnings('ignore')
import os
files=os.listdir(r'C:\Users\Ravi Kumar\Downloads\Covid_19')
files

['country_wise_latest.csv', 'covid_19_clean_complete.csv', 'day_wise.csv', 'full_grouped.csv', 'usa_country_wise.csv', 'worldometer_data.csv']

## lets create a function to make our task simpler as we have to read data again & again 
def read_data(path, filename):
    return pd.read_csv(path+'/'+filename)
path=r'C:\Users\Ravi Kumar\Downloads\Covid_19'
world_data=read_data(path,'worldometer_data.csv')
world_data

undefined

day_wise=read_data(path,files[2])
day_wise

undefined

group_data=read_data(path,files[3])
group_data

undefined

province_data=read_data(path,files[1])
province_data

undefined

Which Country has the maximum Total cases, Deaths, Recovered & active cases?

Let's create a TreeMap Representation of our data.

world_data.columns

Index(['Country/Region', 'Continent', 'Population', 'TotalCases', 'NewCases', 'TotalDeaths', 'NewDeaths', 'TotalRecovered', 'NewRecovered', 'ActiveCases', 'Serious, Critical', 'Tot Cases/1M pop', 'Deaths/1M pop', 'TotalTests', 'Tests/1M pop', 'WHO Region'], dtype='object')

columns=['TotalCases', 'TotalDeaths', 'TotalRecovered',' ActiveCases']
for i in columns:
    fig=px.treemap(world_data[0:20],values=i,path=['Country/Region'],template="plotly_dark"
                   ,title="<b>TreeMap representation of different Countries w.r.t. their {}</b>".format(i))
    fig.show()

undefined

undefined

undefined

undefined

What is the trend of Confirmed Deaths and Recovered Active cases?

Let's create a Lineplot Representation of our data.

fig=px.line(day_wise,x="Date",y=["Confirmed","Deaths","Recovered","Active"],title="covid cases w.r.t. date"
            ,template="plotly_dark")
fig.show()

undefined

Find 20 most affected countries.

BarPlot Representation of Population to Tests Done Ratio.

pop_test_ratio=world_data.iloc[0:20]['Population']/world_data.iloc[0:20]['TotalTests']
pop_test_ratio

undefined

fig=px.bar(world_data.iloc[0:20],color='Country/Region',y=pop_test_ratio,x='Country/Region'
           ,template="plotly_dark",title="<b>population to tests done ratio</b>")
fig.show()

undefined

Find 20 that are badly affected by corona.

BarPlot Representation of CoronaViruses Cases w.r.t Time.

fig=px.bar(world_data.iloc[0:20],x='Country/Region'
           ,y=['Serious, Critical', 'TotalDeaths', 'TotalRecovered',' ActiveCases', 'TotalCases'],template="plotly_dark")
fig.update_layout({'title':"Top 20 Countries Badly affected by Corona"})
fig.show()

undefined

Top 20 countries of Total Confirmed cases

fig=px.bar(world_data.iloc[0:20],y='Country/Region',x='TotalCases',color='TotalCases',text="TotalCases")
fig.update_layout(template="plotly_dark",title_text="<b>Top 20 countries of Total confirmed cases</b>")
fig.show()

undefined

Top 20 countries of total death cases

fig=px.bar(world_sortdata.iloc[0:20],y='Country/Region',x='TotalDeaths',color='TotalDeaths',text='TotalDeaths')
fig.update_layout(template='plotly_dark',title='Top 20 countries of total Deaths cases')
fig.show()

undefined

Top 20 countries of total Active cases

fig=px.bar(world_data.sort_values(by='ActiveCases',ascending=False).iloc[0:20],y='Country/Region',x='ActiveCases',color='ActiveCases',text='ActiveCases')
fig.update_layout(template='plotly_dark',title='Top 20 countries of total Active cases')
fig.show()

undefined

Top 20 countries of total TotalRecovered Cases

fig=px.bar(world_data.sort_values(by='TotalRecovered',ascending=False).iloc[0:20],y='Country/Region',x='TotalRecovered',color='TotalRecovered',text='TotalRecovered')
fig.update_layout(template='plotly_dark',title='Top 20 countries of total TotalRecovered')
fig.show()

undefined

TotalCases, TotalDeaths, Total Recovered, and ActiveCases recorded w.r.t to WHO region of 15 worst affected countries

labels=world_data[0:15]['Country/Region'].values
cases=['TotalCases','TotalDeaths','TotalRecovered','ActiveCases']
for i in cases:
    fig=px.pie(world_data[0:15],values=i,names=labels,hole=0.3,title='{} recorded w.r.t to WHO region of 15 worst affected countries'.format(i))
    fig.show()

undefinedundefinedundefinedundefined

Death to confirmed ratio of worst affected countries

deaths_to_confirmed=world_data['TotalDeaths']/world_data['TotalCases']
deaths_to_confirmed

undefined

px.bar(world_data,x='Country/Region',y=deaths_to_confirmed,color='Country/Region',title='Deaths to confirmed ratio of worst affected countries')

undefined

Deaths to recovered ratio of worst affected countries

deaths_to_recovered=world_data['TotalDeaths']/world_data['TotalRecovered']
px.bar(world_data,x='Country/Region',y=deaths_to_recovered,color='Country/Region',title='Deaths to recovered ratio of worst affected countries')

undefined

Test to confirmed ratio of worst affected countries

test_to_confirmed=world_data['TotalTests']/world_data['TotalCases']
px.bar(world_data,x='Country/Region',y=test_to_confirmed,color='Country/Region',title='test to confirmed ratio of worst affected countries')

undefined

Serious to deaths ratio of the worst affected countries

serious_to_death=world_data['Serious,Critical']/world_data['TotalDeaths']
px.bar(world_data,x='Country/Region',y=serious_to_death,color='Country/Region',template='plotly_dark',title='serious to deaths ratio of worst affected countries')

undefined

Date vs recorded case of India

from plotly.subplots import make_subplots
import plotly.graph_objects as go
def country_visualization(group_data,country):
    data=group_data[group_data['Country/Region']==country]
    data2=data.loc[:,['Date','Confirmed','Deaths','Recovered','Active']]
    fig=make_subplots(rows=1,cols=4,subplot_titles=('Confirmed','Active','Recovered','Deaths'))
    
    fig.add_trace(
    go.Scatter(name='Confirmed',x=data2['Date'],y=data2['Confirmed']),row=1,col=1
    )
    
    fig.add_trace(
    go.Scatter(name='Active',x=data2['Date'],y=data2['Active']),row=1,col=2
    )
    
    fig.add_trace(
    go.Scatter(name='Recovered',x=data2['Date'],y=data2['Recovered']),row=1,col=3
    )
    
    fig.add_trace(
    go.Scatter(name='Deaths',x=data2['Date'],y=data2['Deaths']),row=1,col=4
    )
    
    fig.update_layout(height=600,width=1000,title_text='Date vs Recorded cases of      {}'.format(country),template='plotly_dark')
    fig.show()

country_visualization(group_data,'India')

undefined

Discussion and feedback(0 comments)
2000 characters remaining
Cookie SettingsWe use cookies to enhance your experience, analyze site traffic and deliver personalized content. Read our Privacy Policy.