Browse the project source code in my github repository: https://github.com/rnowotniak/covid19-analysis

covid19 global spread analysis

Coronavirus spread analysis

Contact: Robert Nowotniak «rnowotniak@gmail.com»

Last updated: Apr 5th, 2020


Data sources from John Hopkins University:

Tools to reproduce and to rerun this analysis:

import pandas as pd, numpy as np
import matplotlib.pyplot as plt, matplotlib as mpl
plt.rcParams['figure.figsize'] = [12,8]

List of countries to include in the analysis:

COUNTRIES = ['United Kingdom', 'Poland','China','US','Italy','Canada', 'Spain', 'Germany']

Load data from John Hopkins University:

CONFIRMED_URL='https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv'
DEATHS_URL='https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv'
RECOVERED_URL='https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv'
confirmed = pd.read_csv(CONFIRMED_URL)
deaths    = pd.read_csv(DEATHS_URL)
recovered = pd.read_csv(RECOVERED_URL)
confirmed = confirmed.groupby(by='Country/Region').sum().transpose()[2:].applymap(lambda x: int(x))
deaths    =    deaths.groupby(by='Country/Region').sum().transpose()[2:].applymap(lambda x: int(x))
recovered = recovered.groupby(by='Country/Region').sum().transpose()[2:].applymap(lambda x: int(x))
confirmed.tail(10)[COUNTRIES]
Country/RegionUnited KingdomPolandChinaUSItalyCanadaSpainGermany
3/26/2011812122181782838368058940425778643938
3/27/20147451389818971016578649846826571950871
3/28/20173121638819991214789247255767323557695
3/29/20197801862821221408869768962808011062095
3/30/202245320558219816180710173973988795666885
3/31/202548123118227918817210579285279592371808
4/1/2029865255482361213372110574956010411877872
4/2/20341732946824322434531152421128411206584794
4/3/20386893383825112755861198271243711919991159
4/4/20424773627825433088501246321297812616896092

Total confirmed cases (cumulative)

axs = confirmed[COUNTRIES].plot(subplots=True,layout=(4,2),figsize=(16,24),
                               title=COUNTRIES, sharex=False, rot=45, grid=True)
for row in axs:
    for ax in row:
        ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

png

Total confirmed cases (cumulative) - one chart

ax = confirmed[COUNTRIES].plot(grid=True)
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
plt.title('Total confirmed cases')
Text(0.5, 1.0, 'Total confirmed cases')

png

Active cases

axs = (confirmed[COUNTRIES] - (recovered[COUNTRIES] + deaths[COUNTRIES])).\
plot(subplots=True,layout=(4,2),figsize=(16,24), title=COUNTRIES, sharex=False, rot=45, grid=True)
for row in axs:
    for ax in row:
        ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

png

Active cases - one chart

ax = (confirmed[COUNTRIES] - (recovered[COUNTRIES] + deaths[COUNTRIES])).plot(grid=True)
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

png

Logarithmic scale charts

Total confirmed cases (cumulative) - log scale

axs = confirmed[COUNTRIES].plot(subplots=True,layout=(4,2),figsize=(16,24),
                               title=COUNTRIES, sharex=False, rot=45, grid=True, logy=True)
for row in axs:
    for ax in row:
        ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

png

Total confirmed cases (cumulative) - one chart, log scale

ax = confirmed[COUNTRIES].plot(grid=True,logy=True)
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
plt.title('Total confirmed cases')
Text(0.5, 1.0, 'Total confirmed cases')

png

Active cases - log scale

axs = (confirmed[COUNTRIES] - (recovered[COUNTRIES] + deaths[COUNTRIES])).\
plot(subplots=True,layout=(4,2),figsize=(16,24), title=COUNTRIES, sharex=False, rot=45, grid=True,logy=True)
for row in axs:
    for ax in row:
        ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

png

Active cases - one chart, log scale

ax = (confirmed[COUNTRIES] - (recovered[COUNTRIES] + deaths[COUNTRIES])).plot(grid=True,logy=True)
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

png