Covid-19 Analysis and Prediction

Covid-19 data science Analysis

What is Data Science?


Data Science is a multi-desciplinary field that uses scientific methods, processes, algorithms and systems to extract knowledge and insights from structured and unstructured data.

COVID-19 - Analysis, Viz, Prediction & Comparisons


Corona Virus
Coronaviruses are zoonotic viruses (means transmitted between animals and people).

Symptoms include from fever, cough, respiratory symptoms, and breathing difficulties.
In severe cases, it can cause pneumonia, severe acute respiratory syndrome (SARS), kidney failure and even death. Coronaviruses are also asymptomatic, means a person can be a carrier for the infection but experiences no symptoms

Novel coronavirus (nCoV)

A novel coronavirus (nCoV) is a new strain that has not been previously identified in humans.

COVID-19 (Corona Virus Disease 2019)

Caused by a SARS-COV-2 corona virus.

First identified in Wuhan, Hubei, China. Earliest reported symptoms reported in November 2019.
First cases were linked to contact with the Huanan Seafood Wholesale Market, which sold live animals.

On 30 January the WHO declared the outbreak to be a Public Health Emergency of International Concern

Libraries
to install for require to run data science analytics

Install

# install calmap
! pip install calmap

#requre libraries we are going user for this program import

# essential libraries
import json
import random
from urllib.request import urlopen

# storing and anaysis
import numpy as np
import pandas as pd

# visualization
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import plotly.graph_objs as go
import plotly.figure_factory as ff
import calmap
import folium

# color pallette
cnf = '#393e46' # confirmed - grey
dth = '#ff2e63' # death - red
rec = '#21bf73' # recovered - cyan
act = '#fe9801' # active case - yellow

# converter
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()

# hide warnings
import warnings
warnings.filterwarnings('ignore')

# html embedding
from IPython.display import Javascript
from IPython.core.display import display
from IPython.core.display import HTML

Dataset

# list files
# !ls ../input/corona-virus-report

# importing datasets
full_table = pd.read_csv('../input/corona-virus-report/covid_19_clean_complete.csv', parse_dates=['Date'])
full_table.head()

Processing

Cleaning Data

# cases
cases = ['Confirmed', 'Deaths', 'Recovered', 'Active']

# Active Case = confirmed - deaths - recovered
full_table['Active'] = full_table['Confirmed'] - full_table['Deaths'] - full_table['Recovered']

# replacing Mainland china with just China
full_table['Country/Region'] = full_table['Country/Region'].replace('Mainland China', 'China')

# filling missing values
full_table[['Province/State']] = full_table[['Province/State']].fillna('')
full_table[cases] = full_table[cases].fillna(0)

Derived Tables

# cases in the ships
ship = full_table[full_table['Province/State'].str.contains('Grand Princess')|full_table['Country/Region'].str.contains('Cruise Ship')]

# china and the row
china = full_table[full_table['Country/Region']=='China']
row = full_table[full_table['Country/Region']!='China']

# latest
full_latest = full_table[full_table['Date'] == max(full_table['Date'])].reset_index()

china_latest = full_latest[full_latest['Country/Region']=='China']
row_latest = full_latest[full_latest['Country/Region']!='China']
# latest condensed
full_latest_grouped = full_latest.groupby('Country/Region')['Confirmed', 'Deaths', 'Recovered', 'Active'].sum().reset_index()
china_latest_grouped = china_latest.groupby('Province/State')['Confirmed', 'Deaths', 'Recovered', 'Active'].sum().reset_index()
row_latest_grouped = row_latest.groupby('Country/Region')['Confirmed', 'Deaths', 'Recovered', 'Active'].sum().reset_index()

Latest Data

Latest Complete Data

temp = full_table.groupby(['Country/Region', 'Province/State'])['Confirmed', 'Deaths', 'Recovered', 'Active'].max()
# temp.style.background_gradient(cmap='Reds')

Latest Condensed Data

temp = full_table.groupby('Date')['Confirmed', 'Deaths', 'Recovered', 'Active'].sum().reset_index()
temp = temp[temp['Date']==max(temp['Date'])].reset_index(drop=True)
temp.style.background_gradient(cmap='Pastel1')

tm = temp.melt(id_vars="Date", value_vars=['Active', 'Deaths', 'Recovered'])
fig = px.treemap(tm, path=["variable"], values="value", height=400, width=600, color_discrete_sequence=[rec, act, dth])
fig.show()

Country wise Data

In each country

temp_f = full_latest_grouped.sort_values(by='Confirmed', ascending=False)
temp_f = temp_f.reset_index(drop=True)
temp_f.style.background_gradient(cmap='Reds')
Countries with deaths reported

temp_flg = temp_f[temp_f['Deaths']>0][['Country/Region', 'Deaths']]
temp_flg.sort_values('Deaths', ascending=False).reset_index(drop=True).style.background_gradient(cmap='Reds')
Countries with no cases recovered

temp = temp_f[temp_f['Recovered']==0][['Country/Region', 'Confirmed', 'Deaths', 'Recovered']]
temp.reset_index(drop=True).style.background_gradient(cmap='Reds')
Countries with all cases died

temp = row_latest_grouped[row_latest_grouped['Confirmed']== row_latest_grouped['Deaths']]
temp = temp[['Country/Region', 'Confirmed', 'Deaths']]
temp = temp.sort_values('Confirmed', ascending=False)
temp = temp.reset_index(drop=True)
temp.style.background_gradient(cmap='Reds')

Maps

Across the world

# World wide

m = folium.Map(location=[0, 0], tiles='cartodbpositron', min_zoom=1, max_zoom=4, zoom_start=1)
for i in range(0, len(full_latest)):
folium.Circle(
location=[full_latest.iloc[i]['Lat'], full_latest.iloc[i]['Long']],
color='crimson',
tooltip = '
  • Country : '+str(full_latest.iloc[i]['Country/Region'])+
    '
  • Province : '+str(full_latest.iloc[i]['Province/State'])+
    '
  • Confirmed : '+str(full_latest.iloc[i]['Confirmed'])+
    '
  • Deaths : '+str(full_latest.iloc[i]['Deaths'])+
    '
  • Recovered : '+str(full_latest.iloc[i]['Recovered']),
    radius=int(full_latest.iloc[i]['Confirmed'])**1.1).add_to(m)
    # Confirmed

    fig = px.choropleth(full_latest_grouped, locations="Country/Region",
    locationmode='country names', color="Confirmed",
    hover_name="Country/Region", range_color=[1,7000],
    color_continuous_scale="aggrnyl",
    title='Countries with Confirmed Cases')
    fig.update(layout_coloraxis_showscale=False)
    fig.show()

    data science
    data science interview questions and answers python is a high-level programming language using Data Science programs these days

  • Data Science

    Harisystems is optimized for learning, testing and training. courses are designed to be simplified to improve reading and basic understanding for beginners to expert level. Tutorials and examples are constantly reviewed to avoid errors, however we cannot warrant full correctness of all content. if any found need to correct write us at info@harisystems.com. we Harisystems is not responsible for any with this tutorials, While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2007-2023 by Harisystems. All Rights Reserved.
    Copyright © Harisystems 2023