Jovian
⭐️
Sign In

COVID-19 in India

Introduction to COVID-19

A novel Corona virus is a category of pathogens, which mostly attacks on the respiratory system of human beings. Corona virus outbreaks are emerging earlier also in the form of Severe Acute Respiratory Syndrome (SARS) and Middle East Respiratory Syndrome (MERS).Now, in the present times, it emerges as a COVID-19, which is caused by the SARS2 Coronavirus and poses a significant risk to the human race.

In December 2019, a number of patients with pneumonia symptoms were reported in Wuhan and Hubei Province of China and later identified as symptoms caused due to the spread of corona virus. Epidemiologically, these patients were later on found to be linked to an animal and seafood market of Wuhan. Later on, the Wuhan city of China was recognized as the epicentre of the COVID-19 disease and claimed for spreading the disease across the world. Around 41 lab confirmed COVID-19 patients reported and admitted to hospital up to January 2, 2020 in China. These patients have symptoms of coughing, sneezing, breathing problems, chest pain, indigestion, and respiratory illness. It was also observed that most of these patients are already suffering from varied diseases such as hypertension, diabetes and cardiovascular.

According to China National Health Commission, 17 deaths reported in China with COVID-19 up to January 22, 2020 and within four days death rate raised to triple with 5502 confirmed cases. By the end of January 2020, 7734 confirmed cases have been reported in China along with 90 cases in other countries such as Thailand, Japan, Malaysia, Iran, Italy, India, USA, Canada, Taiwan, Vietnam, France, Nepal, Cambodia, Germany, Singapore, Korea, United Arab Emirates, Sri Lanka, The Philippines, Australia and Finland.

Furthermore, WHO on 30 Jan declares Public health emergency of international concern due to the severity of the disease. The International Committee on Taxonomy of Viruses named this corona virus as a Severe Acute Respiratory Syndrome Coronavirus-2 (SARS-CoV-2) and the disease caused by the virus designated as Coronavirus Disease-19 (COVID-19) by WHO. The COVID-19 has strewed in more than 114 countries with 118,326 active cases and 4292 deaths on March 11, 2020 and declared as pandemic by WHO. The situation becomes worse within a week after the pandemic declaration and Italy become the second most affected country after china.

Presently, about 216 countries are affected by COVID-19 across the globe and shattered the economic growth of developed as well as developing countries. The WHO report documented on 05 October 2020 claimed 7,637,066 cases United States of America, 6,626,291 cases in India, 4,915,289 in Brazil, 1,225,889 in Russia, 855,052 cases in Colombia, much higher cases in comparison to China from where the disease actually originated (85,470)

How it started in India?

The first COVID-19 case was reported on 30th January 2020 when a student arrived Kerala from Wuhan. Just in next 2 days, Kerela reported 2 more cases. For almost a month, no new cases were reported in India, however, on 2nd March 2020, five new cases of corona virus were reported in Kerala again and since then the cases have been rising affecting 25 states.

Corona Virus Explained in Simple Terms:

  • Let's say Raj got infected yesterday, but he won't know it untill next 14 days
  • Raj thinks he is healthy but he is infecting 10 persons per day
  • Now these 10 persons think they are completely healthy, they travel, go out and infect 100 others
  • These 100 persons think they are healthy but they have already infected 1000 persons
  • No one knows who is healthy or who can infect you
  • All you can do is be responsible, stay in quarentine

alt text

How to run the code

This is an executable Jupyter notebook hosted on Jovian.ml, a platform for sharing data science projects. You can run and experiment with the code in a couple of ways: using free online resources (recommended) or on your own computer.

Option 1: Running using free online resources (1-click, recommended)

The easiest way to start executing this notebook is to click the "Run" button at the top of this page, and select "Run on Binder". This will run the notebook on mybinder.org, a free online service for running Jupyter notebooks. You can also select "Run on Colab" or "Run on Kaggle".

Option 2: Running on your computer locally
  1. Install Conda by following these instructions. Add Conda binaries to your system PATH, so you can use the conda command on your terminal.

  2. Create a Conda environment and install the required libraries by running these commands on the terminal:

conda create -n zerotopandas -y python=3.8 
conda activate zerotopandas
pip install jovian jupyter numpy pandas matplotlib seaborn opendatasets --upgrade
  1. Press the "Clone" button above to copy the command for downloading the notebook, and run it on the terminal. This will create a new directory and download the notebook. The command will look something like this:
jovian clone notebook-owner/notebook-id
  1. Enter the newly created directory using cd directory-name and start the Jupyter notebook.
jupyter notebook

You can now access Jupyter's web interface by clicking the link that shows up on the terminal or by visiting http://localhost:8888 on your browser. Click on the notebook file (it has a .ipynb extension) to open it.

Downloading the Dataset

In [1]:
!pip install jovian opendatasets --upgrade --quiet

Let's begin by downloading the data, and listing the files within the dataset.

In [2]:
# Change this
dataset_url = 'https://www.kaggle.com/sudalairajkumar/covid19-in-india' 
In [3]:
import opendatasets as od
od.download(dataset_url)
Please provide your Kaggle credentials to download this dataset. Learn more: http://bit.ly/kaggle-creds Your Kaggle username: abhijeetraj22 Your Kaggle Key: ········
100%|██████████| 147k/147k [00:00<00:00, 37.2MB/s]
Downloading covid19-in-india.zip to ./covid19-in-india

The dataset has been downloaded and extracted.

In [4]:
# Change this
data_dir = './covid19-in-india'
In [5]:
import os
os.listdir(data_dir)
Out[5]:
['covid_19_india.csv', 'StatewiseTestingDetails.csv']

Let us save and upload our work to Jovian before continuing.

In [6]:
project_name = "zerotopandas-course-project-covid19-in-india" # change this (use lowercase letters and hyphens only)
In [7]:
!pip install jovian --upgrade -q
In [8]:
import jovian
In [ ]:
jovian.commit(project=project_name)
[jovian] Attempting to save notebook..

Data Preparation and Cleaning

  • Load the dataset into a data frame using Pandas
  • Explore the number of rows & columns, ranges of values etc.
  • Handle missing, incorrect and invalid data
In [12]:
import pandas as pd
import numpy as np
#import datetime
In [47]:
covid_india_df = pd.read_csv(data_dir + '/covid_19_india.csv')
In [48]:
covid_india_df
Out[48]:
In [49]:
covid_india_df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 7086 entries, 0 to 7085 Data columns (total 9 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Sno 7086 non-null int64 1 Date 7086 non-null object 2 Time 7086 non-null object 3 State/UnionTerritory 7086 non-null object 4 ConfirmedIndianNational 7086 non-null object 5 ConfirmedForeignNational 7086 non-null object 6 Cured 7086 non-null int64 7 Deaths 7086 non-null int64 8 Confirmed 7086 non-null int64 dtypes: int64(4), object(5) memory usage: 498.4+ KB
In [50]:
covid_india_df.describe()
Out[50]:
In [51]:
#Drop Lat & Long
covid_india_df.drop(['ConfirmedIndianNational', 'ConfirmedForeignNational','Sno'], inplace=True, axis=1)

#Rename Cured to Recovered
covid_india_df.rename(columns = {'Cured':'Recovered'}, inplace = True) 
#Rename State/UnionTerritory to Province_State
covid_india_df.rename(columns = {'State/UnionTerritory':'Province_State'}, inplace = True) 

#Date format change
covid_india_df['Date'] = pd.to_datetime(covid_india_df['Date'],format='%d/%m/%y').dt.date
In [52]:
#Add New Cases
covid_india_df['Prev_Confirmed'] = covid_india_df.groupby('Province_State')['Confirmed'].shift(1)
covid_india_df['New Cases'] = covid_india_df['Confirmed'] - covid_india_df['Prev_Confirmed']
covid_india_df.drop('Prev_Confirmed',inplace = True,axis=1)

#Add New Recovered Cases
covid_india_df['Prev_Recovered'] = covid_india_df.groupby('Province_State')['Recovered'].shift(1)
covid_india_df['New Recovered'] = covid_india_df['Recovered'] - covid_india_df['Prev_Recovered']
covid_india_df.drop('Prev_Recovered',inplace = True,axis=1)

#Add New Deaths Cases
covid_india_df['Prev_Deaths'] = covid_india_df.groupby('Province_State')['Deaths'].shift(1)
covid_india_df['New Deaths'] = covid_india_df['Deaths'] - covid_india_df['Prev_Deaths']
covid_india_df.drop('Prev_Deaths',inplace = True,axis=1)


In [53]:
#check Null
covid_india_df.isnull().sum()
Out[53]:
Date               0
Time               0
Province_State     0
Recovered          0
Deaths             0
Confirmed          0
New Cases         42
New Recovered     42
New Deaths        42
dtype: int64
In [54]:
#few Null data So, Remove it
covid_india_df['New Cases'].fillna(0, inplace=True)
covid_india_df['New Recovered'].fillna(0, inplace=True)
covid_india_df['New Deaths'].fillna(0, inplace=True)
In [55]:
#Type Check
covid_india_df['New Deaths'].dtypes
Out[55]:
dtype('float64')
In [56]:
#Type Change into integer
covid_india_df['New Deaths'] = covid_india_df['New Deaths'].astype(int)
covid_india_df['New Cases'] = covid_india_df['New Cases'].astype(int)
covid_india_df['New Recovered'] = covid_india_df['New Recovered'].astype(int)
In [57]:
covid_india_df['Province_State'].unique()
Out[57]:
array(['Kerala', 'Telengana', 'Delhi', 'Rajasthan', 'Uttar Pradesh',
       'Haryana', 'Ladakh', 'Tamil Nadu', 'Karnataka', 'Maharashtra',
       'Punjab', 'Jammu and Kashmir', 'Andhra Pradesh', 'Uttarakhand',
       'Odisha', 'Puducherry', 'West Bengal', 'Chhattisgarh',
       'Chandigarh', 'Gujarat', 'Himachal Pradesh', 'Madhya Pradesh',
       'Bihar', 'Manipur', 'Mizoram', 'Andaman and Nicobar Islands',
       'Goa', 'Unassigned', 'Assam', 'Jharkhand', 'Arunachal Pradesh',
       'Tripura', 'Nagaland', 'Meghalaya', 'Dadar Nagar Haveli',
       'Cases being reassigned to states', 'Sikkim', 'Daman & Diu',
       'Dadra and Nagar Haveli and Daman and Diu', 'Telangana',
       'Telangana***', 'Telengana***'], dtype=object)
In [58]:
#Remove non State data
#Drop 'Cases being reassigned to states' &  'Unassigned'
df_dump = covid_india_df['Province_State']=='Unassigned'
covid_india_df.drop(covid_india_df[df_dump].index,inplace=True)
df_dump = covid_india_df['Province_State']=='Cases being reassigned to states'
covid_india_df.drop(covid_india_df[df_dump].index,inplace=True)

In [59]:
def change_state_name(state):
    if state == 'Odisha':
        return 'Orissa'
    elif state == 'Telengana':
        return 'Telangana'
    return state

covid_india_df['Province_State'] = covid_india_df.apply(lambda x: change_state_name(x['Province_State']), axis=1)

In [60]:
last_date = covid_india_df.Date.max()
state_cases = covid_india_df.copy()
state_cases = state_cases[state_cases['Date']==last_date]
state_cases.drop(['Date','Time', 'New Cases','New Recovered','New Deaths'],inplace = True,axis=1)
In [61]:
#Add Active, Deaths/Recovered, Mortality & Recovered Rate(per 100)
state_cases['Active'] = state_cases['Confirmed'] - (state_cases['Deaths']+state_cases['Recovered'])
state_cases['Active'] = state_cases['Active'].astype(int)
state_cases["Mortality Rate(per 100)"] = np.round(100*state_cases["Deaths"]/state_cases["Confirmed"],2)
state_cases["Recovered Rate(per 100)"] = np.round(100*state_cases["Recovered"]/state_cases["Confirmed"],2)
In [62]:
state_cases.reset_index(drop=True,inplace=True)
state_cases.head()
Out[62]:
In [63]:
#Day wise Copy Data
covid_india_dayswise_df =  covid_india_df.groupby('Date').sum().reset_index() 
covid_india_dayswise_df.head()
Out[63]:
In [64]:
#check Null
covid_india_dayswise_df.isnull().sum()
Out[64]:
Date             0
Recovered        0
Deaths           0
Confirmed        0
New Cases        0
New Recovered    0
New Deaths       0
dtype: int64
In [65]:
#Add Deaths/Recovered, Mortality & Recovered Rate(per 100)
covid_india_df["Mortality Rate(per 100)"] = np.round(100*covid_india_df["Deaths"]/covid_india_df["Confirmed"],2)
covid_india_df["Recovered Rate(per 100)"] = np.round(100*covid_india_df["Recovered"]/covid_india_df["Confirmed"],2)
In [66]:
#check Null
covid_india_df.isnull().sum()
Out[66]:
Date                       0
Time                       0
Province_State             0
Recovered                  0
Deaths                     0
Confirmed                  0
New Cases                  0
New Recovered              0
New Deaths                 0
Mortality Rate(per 100)    7
Recovered Rate(per 100)    7
dtype: int64
In [67]:
#few Null data So, Remove it
covid_india_df['Mortality Rate(per 100)'] = covid_india_df['Mortality Rate(per 100)'].replace(np.nan, 0)
covid_india_df['Recovered Rate(per 100)'] = covid_india_df['Recovered Rate(per 100)'].replace(np.nan, 0)
In [68]:
#check Null
covid_india_df.isnull().sum()
Out[68]:
Date                       0
Time                       0
Province_State             0
Recovered                  0
Deaths                     0
Confirmed                  0
New Cases                  0
New Recovered              0
New Deaths                 0
Mortality Rate(per 100)    0
Recovered Rate(per 100)    0
dtype: int64
In [69]:
import jovian
In [70]:
jovian.commit()
[jovian] Attempting to save notebook.. [jovian] Updating notebook "abhijeetraj22/zerotopandas-course-project-covid19-in-india" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/abhijeetraj22/zerotopandas-course-project-covid19-in-india

Exploratory Analysis and Visualization

  • Matplotlib - for visualization (Platting graphas)
  • Seaborn - for visualization (Platting beautiful graphas)
  • Plotly - for interative plots
  • Explore distributions of numeric columns using histograms etc.
  • Explore relationship between columns using scatter plots, bar charts etc.

Install plotly-express

In [71]:
!pip install plotly-express
Requirement already satisfied: plotly-express in /srv/conda/envs/notebook/lib/python3.8/site-packages (0.4.1) Requirement already satisfied: statsmodels>=0.9.0 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from plotly-express) (0.12.0) Requirement already satisfied: numpy>=1.11 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from plotly-express) (1.19.1) Requirement already satisfied: plotly>=4.1.0 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from plotly-express) (4.11.0) Requirement already satisfied: patsy>=0.5 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from plotly-express) (0.5.1) Requirement already satisfied: pandas>=0.20.0 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from plotly-express) (1.1.2) Requirement already satisfied: scipy>=0.18 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from plotly-express) (1.5.2) Requirement already satisfied: six in /srv/conda/envs/notebook/lib/python3.8/site-packages (from plotly>=4.1.0->plotly-express) (1.15.0) Requirement already satisfied: retrying>=1.3.3 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from plotly>=4.1.0->plotly-express) (1.3.3) Requirement already satisfied: pytz>=2017.2 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from pandas>=0.20.0->plotly-express) (2020.1) Requirement already satisfied: python-dateutil>=2.7.3 in /srv/conda/envs/notebook/lib/python3.8/site-packages (from pandas>=0.20.0->plotly-express) (2.8.1)

Let's begin by importingmatplotlib.pyplot and seaborn.

In [72]:
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
import plotly_express as px
%matplotlib inline

sns.set_style('darkgrid')
matplotlib.rcParams['font.size'] = 14
matplotlib.rcParams['figure.figsize'] = (9, 5)
matplotlib.rcParams['figure.facecolor'] = '#00000000'

Total Reported Cases

In [73]:
total_cases = state_cases.copy()
total_cases.drop(['Province_State','Mortality Rate(per 100)','Recovered Rate(per 100)'],inplace = True,axis=1)
total = total_cases.sum()
total.name = "Total"
df_t = pd.DataFrame(total,dtype=float).transpose()
df_t["Mortality Rate(per 100)"] = np.round(100*df_t["Deaths"]/df_t["Confirmed"],2)
df_t.style.background_gradient(cmap='Purples',axis=1).format("{:.2f}").format("{:.0f}",subset=["Confirmed","Deaths","Recovered","Active"])
Out[73]:
In [74]:
india_confirmed = total.Confirmed
india_active = total.Active
india_recovered = total.Recovered
india_deaths = total.Deaths
labels = ['Active','Recovered','Deaths']
sizes = [india_active,india_recovered,india_deaths]
color= ['#66b3ff','green','red']
explode = []

for i in labels:
    explode.append(0.02)

plt.figure(figsize= (15,5))
plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=9, explode =explode,colors = color)
centre_circle = plt.Circle((0,0),0.30,fc='white')

fig = plt.gcf()
fig.gca().add_artist(centre_circle)
plt.title('India COVID-19 Cases',fontsize = 20)
plt.axis('equal')  
plt.tight_layout()
A total of 6757131 COVID-19 confirmed cases have been reported in Indian as from 07. October 2020 with 907883 active cases (13.4%),5744693 cured/discharged (85.0%),and 104555 deaths (1.5%).

Statewise Insights

In [76]:
state_cases_df = state_cases.copy()
state_cases_df = state_cases_df.set_index("Province_State")
state_cases_df.sort_values('Confirmed', ascending= False).fillna(0).style.background_gradient(cmap='Blues',subset=["Confirmed"])\
                        .background_gradient(cmap='Reds',subset=["Deaths"])\
                        .background_gradient(cmap='Greens',subset=["Recovered"])\
                        .background_gradient(cmap='Purples',subset=["Active"])\
                        .background_gradient(cmap='YlOrBr',subset=["Mortality Rate(per 100)"])\
                        .background_gradient(cmap='Greens_r',subset=["Recovered Rate(per 100)"])
Out[76]:
Maharashtra state is the most recent with COVID-19 cases 1179726

India COVID19 Cases growth (Day Wise)

In [77]:
fig, ax = plt.subplots(figsize=(15, 10))
ax.clear()
#fig = sns.lineplot(x="Date",y="Active",data = covid_india_dayswise_df ,color="y",label="Active")
fig = sns.lineplot(x="Date",y="Recovered",data = covid_india_dayswise_df ,color="green",label="Recovered")
fig = sns.lineplot(x="Date",y="Deaths",data = covid_india_dayswise_df ,color="r",label="Deaths")
fig = sns.lineplot(x="Date",y="Confirmed",data = covid_india_dayswise_df ,color="c",label="Confirmed")
fig.set_xlabel('Date\n',size=15,color='#4bb4f2') 
fig.set_ylabel('Number of Cases\n',size=15,color='#4bb4f2') 
fig.set_title('India Covid-19 Cases',size=25,color='navy')
fig.ticklabel_format(style='plain', axis='y',useOffset=False)
In [78]:
df1 = covid_india_dayswise_df.melt(id_vars='Date', value_vars=['New Cases','New Deaths','New Recovered'], 
                 var_name='Cases', value_name='Cases Count')
fig = px.line(df1, x="Date", y="Cases Count",color='Cases')
fig.update_layout(title="India Covid-19 Daily Cases", xaxis_title="", yaxis_title="")
fig.show()
From the above line plots:
  • Our estimation show that the COVID-19 epidemic trend in India will rise from Feb 28, 2020 and will peak during May 15 to June 30.

Covid19 State Wise

In [94]:
fig = px.line(covid_india_df,x='Date', y='Confirmed', color='Province_State',title='India growth COVID19 Cases ')
fig.show()
From the above line plots for the states:
  • The cases and deaths are monotonically increasing(almost exponentially) for rest of the states.
  • Maharashtra & Andhra Pradesh states has shown the greatest rise in the number of Confirmed Cases. Karnataka states on the other hand having the 3rd highest rise in Confirmed Cases.

Top 10 States

Bar Plot Analysis

In [82]:
def plot_hbar(df, col, n, hover_data=[]):
    fig = px.bar(df.sort_values(col).tail(n), 
                 x=col, y="Province_State", color='Province_State',  
                 text=col, orientation='h', width=700, hover_data=hover_data,
                 color_discrete_sequence = px.colors.qualitative.Dark24)
    fig.update_layout(title=col, xaxis_title="", yaxis_title="", 
                      yaxis_categoryorder = 'total ascending',
                      uniformtext_minsize=8, uniformtext_mode='hide')
    fig.show()

In [85]:
plot_hbar(state_cases, 'Confirmed', 10)
From the above bar plots for the states:
  • Maharashtra & Andhra Pradesh states has shown the greatest rise in the number of Confirmed Cases. Karnataka states on the other hand having the 3rd highest rise in Confirmed Cases.
In [88]:
plot_hbar(state_cases, 'Deaths', 10)
From the above bar plots for the states:
  • Maharashtra & Tamil Nadu states has shown the greatest rise in the number of Deaths Cases. Karnataka states on the other hand having the 3rd highest rise in Deaths Cases.
In [89]:
plot_hbar(state_cases, 'Recovered', 10)
From the above bar plots for the states:
  • Maharashtra & Andhra Pradesh states has shown the greatest rise in the number of Recovered Cases. Tamil Nadu states on the other hand having the 3rd highest rise in Recovered Cases.
In [90]:
plot_hbar(state_cases, 'Active', 10)
From the above bar plots for the states:
  • Maharashtra & Karnataka states has shown the greatest rise in the number of Active Cases. Kerala states on the other hand having the 3rd highest rise in Active Cases.

Mortality Rate

For any epidemic the one of the most important evaluation is Mortality Rate. It is the measure of number of deaths in a particular population during a specific interval.
In [86]:
plot_hbar(state_cases, 'Mortality Rate(per 100)', 10)
From the above bar plots for the states:
  • Punjab & Maharashtra states has shown the greatest rise in the number of Mortality Rate. Gujarat states on the other hand having the 3rd highest rise in Mortality Rate.

Recovered Rate

It is the measure of number of recovered in a particular population during a specific interval.
In [87]:
plot_hbar(state_cases, 'Recovered Rate(per 100)', 10)
From the above bar plots for the states:
  • Dadra and Nagar Haveli & Andaman and Nicobar Islands states has shown the greatest rise in the number of Recovered Rate. Bihar states on the other hand having the 3rd highest rise in Recovered Rate.

India Confirmed vs Deaths (Scale in log10)

In [91]:
fig = px.scatter(state_cases.sort_values('Deaths', ascending=False).iloc[:20, :], 
                 x='Confirmed', y='Deaths', color='Province_State', size='Confirmed', 
                 height=700, text='Province_State', log_x=True, log_y=True, 
                 title='Confirmed vs Deaths (Scale in log10)')
fig.update_traces(textposition='top center')
fig.update_layout(showlegend=False)
fig.update_layout(xaxis_rangeslider_visible=True)
fig.show()
From the above scatter plots for the states:
  • We can see that the vast majority of the cases fall into these groups: Maharashtra, Tamil Nadu, Karnataka, Andhra Pradesh.

Let us save and upload our work to Jovian before continuing

In [103]:
import jovian
In [104]:
jovian.commit()
[jovian] Attempting to save notebook.. [jovian] Updating notebook "abhijeetraj22/zerotopandas-course-project-covid19-in-india" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/abhijeetraj22/zerotopandas-course-project-covid19-in-india

Asking and Answering Questions

  • Ask at least 5 interesting questions about your dataset
  • Answer the questions either by computing the results using Numpy/Pandas or by plotting graphs using Matplotlib/Seaborn
Q1: What is the total number of COVID-19 cases in India?
In [106]:
total_cases = state_cases.copy()
total_cases.drop(['Province_State','Mortality Rate(per 100)','Recovered Rate(per 100)'],inplace = True,axis=1)
total = total_cases.sum()
total.name = "Total"
df_t = pd.DataFrame(total,dtype=float).transpose()
df_t["Mortality Rate(per 100)"] = np.round(100*df_t["Deaths"]/df_t["Confirmed"],2)
df_t.style.background_gradient(cmap='Purples',axis=1).format("{:.2f}").format("{:.0f}",subset=["Confirmed","Deaths","Recovered","Active"])
Out[106]:
In [105]:
print("A total of {a} COVID-19 confirmed cases have been reported in Indian \
as from {date} with {b} active cases ({ap:.1f}%),{c} cured/discharged ({rp:.1f}%),\
and {d} deaths ({dp:.1f}%).".format(a = india_confirmed,date = last_date.strftime("%d. %B %Y"),b = india_active,ap=(india_active/india_confirmed)*100 \
                                    ,c = india_recovered,rp=(india_recovered/india_confirmed)*100 \
                                    ,d = india_deaths,dp=(india_deaths/india_confirmed)*100))

A total of 6757131 COVID-19 confirmed cases have been reported in Indian as from 07. October 2020 with 907883 active cases (13.4%),5744693 cured/discharged (85.0%),and 104555 deaths (1.5%).
Q2. Which state is the most recent with COVID-19 Deaths case?
In [119]:
top_state = state_cases.sort_values('Deaths', ascending= False).head(5)
#top_state
top_state.reset_index(drop=True,inplace=True)
top_state.style.background_gradient(cmap='Blues',subset=["Confirmed"])\
                        .background_gradient(cmap='Reds',subset=["Deaths"])\
                        .background_gradient(cmap='Greens',subset=["Recovered"])\
                        .background_gradient(cmap='Purples',subset=["Active"])\
                        .background_gradient(cmap='YlOrBr',subset=["Mortality Rate(per 100)"])\
                        .background_gradient(cmap='Greens_r',subset=["Recovered Rate(per 100)"])

Out[119]:
In [125]:
print("{state_name[0]} state is the most recent with COVID-19 Deaths cases {num_cases[0]}".format(state_name = top_state['Province_State'],num_cases=top_state['Deaths']))
Maharashtra state is the most recent with COVID-19 Deaths cases 38717
Q3: Which state is the High Mortality Rate(per 100) in COVID-19 ?
In [126]:
top_state = state_cases.sort_values('Mortality Rate(per 100)', ascending= False).head(5)
#top_state
top_state.reset_index(drop=True,inplace=True)
top_state.style.background_gradient(cmap='Blues',subset=["Confirmed"])\
                        .background_gradient(cmap='Reds',subset=["Deaths"])\
                        .background_gradient(cmap='Greens',subset=["Recovered"])\
                        .background_gradient(cmap='Purples',subset=["Active"])\
                        .background_gradient(cmap='YlOrBr',subset=["Mortality Rate(per 100)"])\
                        .background_gradient(cmap='Greens_r',subset=["Recovered Rate(per 100)"])

Out[126]:
In [128]:
print("{state_name[0]} state is the High Mortality Rate(per 100) {num_cases[0]} in COVID-19 ".format(state_name = top_state['Province_State'],num_cases=top_state['Mortality Rate(per 100)']))
Punjab state is the High Mortality Rate(per 100) 3.07 in COVID-19
Q4: Which state is the High Recovered Rate(per 100) in COVID-19 ?
In [129]:
top_state = state_cases.sort_values('Recovered Rate(per 100)', ascending= False).head(5)
#top_state
top_state.reset_index(drop=True,inplace=True)
top_state.style.background_gradient(cmap='Blues',subset=["Confirmed"])\
                        .background_gradient(cmap='Reds',subset=["Deaths"])\
                        .background_gradient(cmap='Greens',subset=["Recovered"])\
                        .background_gradient(cmap='Purples',subset=["Active"])\
                        .background_gradient(cmap='YlOrBr',subset=["Mortality Rate(per 100)"])\
                        .background_gradient(cmap='Greens_r',subset=["Recovered Rate(per 100)"])

Out[129]:
In [131]:
print("{state_name[0]} state is the High Recovered Rate(per 100) {num_cases[0]} in COVID-19 ".format(state_name = top_state['Province_State'],num_cases=top_state['Recovered Rate(per 100)']))
Dadra and Nagar Haveli and Daman and Diu state is the High Recovered Rate(per 100) 96.68 in COVID-19
Q5: Find the Daily Covid-19 Mortality Rates (per 100) in india
In [134]:
covid_india_dayswise_df["Mortality Rate(per 100)"] = np.round(100*covid_india_dayswise_df["Deaths"]/covid_india_dayswise_df["Confirmed"],2)
covid_india_dayswise_df[["Date","Mortality Rate(per 100)"]]
Out[134]:
In [137]:
fig = px.line(covid_india_dayswise_df, x="Date", y="Mortality Rate(per 100)", color_discrete_sequence=['lightcoral'],height=600)
fig.update_layout(title="India Covid-19 Mortality Rate (per 100)", xaxis_title="", yaxis_title="")
fig.show()
Q6: Find the Daily Covid-19 Recovered Rate(per 100) in india
In [138]:
covid_india_dayswise_df["Recovered Rate(per 100)"] = np.round(100*covid_india_dayswise_df["Recovered"]/covid_india_dayswise_df["Confirmed"],2)
covid_india_dayswise_df[["Date","Recovered Rate(per 100)"]]
Out[138]:
In [139]:
fig = px.line(covid_india_dayswise_df, x="Date", y="Recovered Rate(per 100)", color_discrete_sequence=['darkseagreen'],height=600)
fig.update_layout(title="India Covid-19 Recovered Rate(per 100)", xaxis_title="", yaxis_title="")
fig.show()
Q7: Find the Daily Covid-19 Incidence Rate(per 100) in india
In [144]:
covid_india_dayswise_df["Incidence Rate(per 100)"] = np.round(100*covid_india_dayswise_df["New Cases"]/covid_india_dayswise_df["Confirmed"],2)
covid_india_dayswise_df[["Date","Incidence Rate(per 100)"]]
Out[144]:
In [146]:
fig = px.line(covid_india_dayswise_df, x="Date", y="Incidence Rate(per 100)", color_discrete_sequence=['red'],height=600)
fig.update_layout(title="India Covid-19 Incidence Rate(per 100)", xaxis_title="", yaxis_title="")
fig.show()

Let us save and upload our work to Jovian before continuing.

In [148]:
import jovian
In [149]:
jovian.commit()
[jovian] Attempting to save notebook.. [jovian] Updating notebook "abhijeetraj22/zerotopandas-course-project-covid19-in-india" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/abhijeetraj22/zerotopandas-course-project-covid19-in-india

Inferences and Conclusion

  • Our estimation show that the COVID-19 epidemic trend in India will rise from Feb 28, 2020 and will peak during May 15 to June 15.
  • Under such circumstances, two types of hypotheses can be considered for the adequacy of the current measures and as to whether the epidemic peak will occur during June 15-31, 2020.
  • Assuming that the current measures are inefficient and inadequate, the number of estimated cases will continue to increase by the end of Oct.
  • The current control measures are effective and sufficient and the number of cases estimated after the epidemic peak will go down.
  • At the time of the outbreak of COVID-19, the best and most urgent steps must be taken to overcome the coronavirus epidemic. The fight against coronavirus infection should be an emergency.
In [150]:
import jovian
In [151]:
jovian.commit()
[jovian] Attempting to save notebook.. [jovian] Updating notebook "abhijeetraj22/zerotopandas-course-project-covid19-in-india" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/abhijeetraj22/zerotopandas-course-project-covid19-in-india
In [152]:
import jovian
In [153]:
jovian.commit()
[jovian] Attempting to save notebook.. [jovian] Updating notebook "abhijeetraj22/zerotopandas-course-project-covid19-in-india" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/abhijeetraj22/zerotopandas-course-project-covid19-in-india
In [ ]: