# 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']
turkey = df_time[df_time.Country == "Turkey"].reset_index(drop = True).drop("Country", 1)
turkey["Confirmed"].plot(logy=True)
turkey["Confirmed"].plot()
turkey[turkey.Deaths > 0]
turkey_diff = turkey[turkey.Deaths > 0].set_index('Date').diff()
turkey_diff
turkey[turkey.Deaths > 0].set_index("Date").Confirmed.plot()
turkey_diff.Confirmed.plot()
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")
ax = turkey[turkey.Deaths > 0].set_index("Date").Deaths.plot()
turkey_diff.Deaths.plot(ax=ax, figsize = [10,6], title = "Deaths with Daily Changes")
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")