Data Gathering & Preparing

In [1]:
# https://pomber.github.io/covid19/timeseries.json
import pandas as pd
from pandas import json_normalize
%matplotlib inline
df = pd.read_json("https://pomber.github.io/covid19/timeseries.json")
df_time = pd.DataFrame(columns=["date", "confirmed", "deaths", "recovered", "country"])
for c in df.columns.unique().tolist():
    tmp =  json_normalize(df[c]).set_index("date").reset_index()
    tmp["country"] = c
    df_time = pd.concat([df_time, tmp])

df_time.reset_index(drop=True, inplace=True)
df_time["date"] = pd.to_datetime(df_time["date"])
df_time.columns = ['Date', 'Confirmed', 'Deaths', 'Recovered', 'Country']

Daily Graphs for Turkey

In [2]:
turkey = df_time[df_time.Country == "Turkey"].reset_index(drop = True).drop("Country", 1)
In [3]:
turkey["Confirmed"].plot(logy=True)
Out[3]:
<matplotlib.axes._subplots.AxesSubplot at 0x19d1da5b848>
In [4]:
turkey["Confirmed"].plot()
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x19d1e9d2548>
In [5]:
turkey[turkey.Deaths > 0]
Out[5]:
Date Confirmed Deaths Recovered
55 2020-03-17 47 1 0
56 2020-03-18 98 1 0
57 2020-03-19 192 3 0
58 2020-03-20 359 4 0
59 2020-03-21 670 9 0
... ... ... ... ...
145 2020-06-15 179831 4825 152364
146 2020-06-16 181298 4842 153379
147 2020-06-17 182727 4861 154640
148 2020-06-18 184031 4882 156022
149 2020-06-19 185245 4905 157516

95 rows × 4 columns

In [6]:
turkey_diff = turkey[turkey.Deaths > 0].set_index('Date').diff()
turkey_diff
Out[6]:
Confirmed Deaths Recovered
Date
2020-03-17 NaN NaN NaN
2020-03-18 51 0 0
2020-03-19 94 2 0
2020-03-20 167 1 0
2020-03-21 311 5 0
... ... ... ...
2020-06-15 1592 18 947
2020-06-16 1467 17 1015
2020-06-17 1429 19 1261
2020-06-18 1304 21 1382
2020-06-19 1214 23 1494

95 rows × 3 columns

In [7]:
turkey[turkey.Deaths > 0].set_index("Date").Confirmed.plot()
Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x19d1e608e48>
In [8]:
turkey_diff.Confirmed.plot()
Out[8]:
<matplotlib.axes._subplots.AxesSubplot at 0x19d1ec81908>
In [9]:
ax = turkey[turkey.Deaths > 0].set_index("Date").Confirmed.plot()
turkey_diff.Confirmed.plot(ax=ax, figsize = [10,6], title = "Confirmed Cases with Daily Changes")
Out[9]:
<matplotlib.axes._subplots.AxesSubplot at 0x19d1e98df48>
In [10]:
ax = turkey[turkey.Deaths > 0].set_index("Date").Deaths.plot()
turkey_diff.Deaths.plot(ax=ax, figsize = [10,6], title = "Deaths with Daily Changes")
Out[10]:
<matplotlib.axes._subplots.AxesSubplot at 0x19d22c50788>
In [11]:
ax = turkey[turkey.Deaths > 0].set_index("Date").Recovered.plot()
turkey_diff.Recovered.plot(ax=ax, figsize = [10,6], title = "Recovered Cases with Daily Changes")
Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x19d1ed58988>