Berlin
import os,sys
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(''), '../../Code')))
from hedera_covid import DataHandlerBerlin, smooth_data
# for plotly
from plotly.offline import iplot
from plotly.offline import init_notebook_mode, plot
from IPython.core.display import display, HTML
import plotly as py
import plotly.tools as tls
import datetime
import numpy as np
import pandas as pd
# load data
berlin = DataHandlerBerlin()
# intensive care
berlin_h = pd.read_excel('../../DE-Data/intensive-care-data.xlsx',sheet_name = 'berlin')
germany_h = pd.read_excel('../../DE-Data/intensive-care-data.xlsx',sheet_name = 'germany')
bayern_h = pd.read_excel('../../DE-Data/intensive-care-data.xlsx',sheet_name = 'bayern')
berlin_time = pd.read_excel('../../DE-Data/intensive-care-data.xlsx',sheet_name = 'berlin-timeseries')
import plotly.graph_objects as go
init_notebook_mode(connected=True)
home = berlin_time['Cases']-berlin_time['Recovered']-berlin_time['Hospital'] - berlin_time['Intensive'] - berlin_time['Death']
active = home + berlin_time['Hospital'] + berlin_time['Intensive']
fig = go.Figure(data=[
go.Bar(name='Deaths', x=berlin_time['Date'], y=berlin_time['Death']),
go.Bar(name='Intensive', x=berlin_time['Date'], y=berlin_time['Intensive']),
go.Bar(name='Hospital', x=berlin_time['Date'], y=berlin_time['Hospital']),
go.Bar(name='Quaranteen', x=berlin_time['Date'], y=home),
go.Bar(name='Recovered', x=berlin_time['Date'], y=berlin_time['Recovered']),
])
n_smooth = 7
fig.add_trace(go.Scatter(
x=berlin_time['Date'],
y=smooth_data(berlin_time['Cases'],n=n_smooth),
name='Total cases (averaged)'
))
fig.add_trace(go.Scatter(
x=berlin_time['Date'],
y=smooth_data(active,n=n_smooth),
name='Active cases (averaged)'
))
# Change the bar mode
fig.update_layout(barmode='stack')
fig.update_layout(xaxis_tickangle=-90)
fig.update_layout(legend=dict(x=0.1, y=1.2),legend_orientation="h",font_size=10)
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
import plotly.graph_objects as go
init_notebook_mode(connected=True)
daily = []
daily.append(0)
fig = go.Figure()
N = len(berlin_time['Cases'])
for k in range(1,len(berlin_time['Cases'])):
daily.append(berlin_time['Cases'][k]-berlin_time['Cases'][k-1])
fig.add_trace(go.Bar(
x=berlin_time['Date'],
y=daily,
name='Daily Reported Cases (Total = ' + str(berlin_time['Cases'][N-1]) + ')',
marker = {'color': "#117A65"}
))
n_smooth = 7
fig.add_trace(go.Scatter(
x=berlin_time['Date'],
y=smooth_data(daily,n=n_smooth),
name='Averaged over ' + str(n_smooth) + ' days',
marker = {'color': "#48C9B0"}
))
fig.update_layout(xaxis_tickangle=-90)
fig.update_layout(legend=dict(x=0.1, y=1.2),legend_orientation="h",font_size=10)
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
Notice that the reporting has an intrinsic periodicity (1 week), which might be due to the modality of reporting results of different testing units. On Sundays, reported cases are always much lower than on other days.
import plotly.graph_objects as go
init_notebook_mode(connected=True)
daily = []
fig = go.Figure()
N = len(berlin_time['Cases'])
for k in range(1,len(berlin_time['Cases'])):
daily.append(berlin_time['Death'][k]-berlin_time['Death'][k-1])
fig = go.Figure()
fig.add_trace(go.Bar(
x=berlin_time['Date'],
y=daily,
name='Daily Reported Deaths (Total = ' + str(berlin_time['Death'][N-1]) + ')',
marker = {'color':'#F7DC6F'}
))
n_smooth = 7
fig.add_trace(go.Scatter(
x=berlin_time['Date'],
y=smooth_data(daily,n=n_smooth),
name='Averaged over ' + str(n_smooth) + ' days',
marker = {'color': "#EB984E"}
))
fig.update_layout(xaxis_tickangle=-90)
fig.update_layout(legend=dict(x=0.1, y=1.2),legend_orientation="h",font_size=10)
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
import plotly.graph_objects as go
init_notebook_mode(connected=True)
fig = go.Figure()
fig.add_trace(go.Bar(
x=germany_h['Date'],
y=germany_h['Percentage'],
name='Germany',
marker = {'color': "#F7DC6F"}
))
fig.add_trace(go.Bar(
x=berlin_h['Date'],
y=berlin_h['Percentage'],
name='Berlin',
marker = {'color': "#117A65"}
))
fig.add_trace(go.Bar(
x=bayern_h['Date'],
y=bayern_h['Percentage'],
name='Bayern',
marker = {'color': "#48C9B0"}
))
fig.update_layout(xaxis_tickangle=-90)
fig.update_layout(title='Percentage of intensive beds free',
font_size=10)
#fig.show()
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
g=10
from IPython.display import display, Markdown
N = len(germany_h['Reporting'])
g= germany_h['Reporting'][N-1]
d = germany_h['Date'][N-1]
display(Markdown(f'**Note** The graphics take into account only the reporting entities ({g} on {d})'))