In [1]:
#hide
print('''
Example of using jupyter notebook, pandas (data transformations), jinja2 (html, visual)
to create visual dashboards with fastpages
You see also the live version on https://gramener.com/enumter/covid19/united-states.html
''')
Example of using jupyter notebook, pandas (data transformations), jinja2 (html, visual)
to create visual dashboards with fastpages
You see also the live version on https://gramener.com/enumter/covid19/united-states.html
In [2]:
#hide
import numpy as np
import pandas as pd
from jinja2 import Template
from IPython.display import HTML
In [3]:
#hide
from pathlib import Path
if not Path('covid_overview.py').exists():
! wget https://raw.githubusercontent.com/pratapvardhan/notebooks/master/covid19/covid_overview.py
In [4]:
#hide
import covid_overview as covid
In [5]:
#hide
COL_REGION = 'Province/State'
kpis_info = [
{'title': 'New York', 'prefix': 'NY'},
{'title': 'Washington', 'prefix': 'WA'},
{'title': 'California', 'prefix': 'CA'}]
data = covid.gen_data_us(region=COL_REGION, kpis_info=kpis_info)
In [6]:
#hide
data['table'].head(5)
Out[6]:
Province/State
Cases
Deaths
casesAgo
deathsAgo
Cases (+)
Deaths (+)
Fatality Rate
33
New York
33066
325
7102
57
25964
268
1.0
31
New Jersey
4402
62
896
11
3506
51
1.4
4
California
3183
67
1283
24
1900
43
2.1
50
Washington
2585
130
1404
83
1181
47
5.0
23
Michigan
2294
43
548
4
1746
39
1.9
In [7]:
#hide_input
template = Template(covid.get_template(covid.paths['overview']))
html = template.render(
D=data['summary'], table=data['table'],
newcases=data['newcases'].iloc[:, -15:],
COL_REGION=COL_REGION,
KPI_CASE='US',
KPIS_INFO=kpis_info,
LEGEND_DOMAIN=[5, 50, 500, np.inf],
np=np, pd=pd, enumerate=enumerate)
HTML(f'<div>{html}</div>')
Out[7]:
US
Confirmed Cases
68,516
(+50,520)
Deaths
991
(+726)
Updated on March 25, 2020 ( +change since 5 days ago.)
New York
Cases
33,066
(+25,964)
Deaths
325
(+268)
Washington
Cases
2,585
(+1,181)
Deaths
130
(+47)
California
Cases
3,183
(+1,900)
Deaths
67
(+43)
In the last 5 days, 50,520 new Coronavirus cases have been reported in the US.
Of which 25,964 (51%) are from New York State.
Washington has reported 1,181 new cases in the last 5 days.
State
New Cases
Total Cases
Deaths
Fatality
Mar. 11
Mar. 25
(+NEW) since Mar, 20
New York
33,066
(+25,964)
325
(+268)
1.0%
New Jersey
4,402
(+3,506)
62
(+51)
1.4%
California
3,183
(+1,900)
67
(+43)
2.1%
Washington
2,585
(+1,181)
130
(+47)
5.0%
Michigan
2,294
(+1,746)
43
(+39)
1.9%
Florida
1,965
(+1,401)
23
(+14)
1.2%
Illinois
1,875
(+1,292)
21
(+16)
1.1%
Massachusetts
1,838
(+1,425)
15
(+14)
0.8%
Louisiana
1,795
(+1,258)
65
(+55)
3.6%
Georgia
1,387
(+905)
47
(+33)
3.4%
Pennsylvania
1,151
(+882)
11
(+10)
1.0%
Texas
1,119
(+742)
12
(+7)
1.1%
Colorado
1,086
(+722)
19
(+14)
1.7%
Connecticut
875
(+681)
19
(+15)
2.2%
Tennessee
784
(+547)
3
(+3)
0.4%
Ohio
706
(+537)
11
(+10)
1.6%
Wisconsin
623
(+407)
7
(+4)
1.1%
North Carolina
563
(+419)
1
(+1)
0.2%
Indiana
479
(+400)
14
(+11)
2.9%
South Carolina
424
(+298)
7
(+4)
1.7%
Maryland
423
(+273)
4
(+2)
0.9%
Nevada
405
(+240)
10
(+8)
2.5%
Arizona
402
(+332)
6
(+5)
1.5%
Virginia
391
(+276)
9
(+7)
2.3%
Alabama
386
(+280)
1
(+1)
0.3%
Mississippi
377
(+297)
5
(+4)
1.3%
Missouri
377
(+304)
8
(+5)
2.1%
Utah
346
(+234)
1
(+1)
0.3%
Arkansas
308
(+208)
2
(+2)
0.6%
Minnesota
287
(+172)
1
(+1)
0.3%
Oregon
266
(+152)
10
(+7)
3.8%
District of Columbia
231
(+154)
3
(+2)
1.3%
Kentucky
198
(+135)
5
(+3)
2.5%
Oklahoma
164
(+115)
5
(+4)
3.0%
Iowa
145
(+100)
1
(+1)
0.7%
Maine
142
(+85)
0
(+0)
0.0%
New Hampshire
137
(+82)
1
(+1)
0.7%
Rhode Island
132
(+88)
0
(+0)
0.0%
Kansas
132
(+83)
3
(+2)
2.3%
Idaho
123
(+92)
0
(+0)
0.0%
Vermont
123
(+94)
8
(+6)
6.5%
Delaware
119
(+80)
0
(+0)
0.0%
New Mexico
112
(+69)
1
(+1)
0.9%
Hawaii
95
(+58)
1
(+1)
1.1%
Nebraska
84
(+31)
0
(+0)
0.0%
Montana
65
(+46)
0
(+0)
0.0%
Alaska
59
(+45)
0
(+0)
0.0%
West Virginia
52
(+44)
0
(+0)
0.0%
Puerto Rico
51
(+37)
2
(+2)
3.9%
Wyoming
49
(+27)
0
(+0)
0.0%
North Dakota
45
(+18)
0
(+0)
0.0%
South Dakota
41
(+27)
1
(+0)
2.4%
Guam
32
(+18)
1
(+1)
3.1%
Virgin Islands
17
(+11)
0
(+0)
0.0%
Visualizations by Pratap Vardhan1
Source: "The New York Times". Link to notebook, orignal interactive↩
Content source: pratapvardhan/iPyNotebooks
Similar notebooks: