In [1]:
import pandas as pd
import arrow
import cufflinks as cf
from scipy.optimize import curve_fit
import numpy as np
import plotly.graph_objs as go
import requests
import seaborn as sns
import plotly.express as px
from plotly.subplots import make_subplots
from plotly.offline import iplot
from IPython.core.display import display, HTML
import numpy as np


cf.go_offline()
pd.set_option('display.max_columns', None)  
pd.set_option('display.max_rows', None)  
In [2]:
data = requests.get('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv').text
date = arrow.now().format('MM-DD')
filename = f"coronavirus-{date}.csv"
open(filename, 'w').write(data)
Out[2]:
78271
In [3]:
data = pd.read_csv(filename)
In [4]:
data = data.iloc[:, :-1]  # last day information is incomplete
last = data.keys()[-1]
In [5]:
# group countries together
data = (data
        .drop(['Lat', 'Long'], axis=1)
        .groupby('Country/Region')
        .sum()
        .sort_values(last, ascending=False))
In [6]:
change_df = data.pct_change(axis=1).fillna(0)
In [7]:
def colors(val):
    if val == 0 or val == float('inf'):
        return 'background-color: white; color: black'
    text_color = 'white' if val > 0.4 else 'black'
    return f'background-color: hsl(0, 80%, {100 - (val * 100)}%); color: {text_color}'
In [8]:
%%html
<style>
/* css hacks */
.row_heading {
    position: sticky;
    left: 0;
    background: white;
}
tr:hover {
    border: 1px solid #2795ee;
}
</style>

Percent change day over day

In [9]:
s = change_df.style.applymap(colors) \
    .format("{:.1%}")
s
Out[9]: