Skip to content

Instantly share code, notes, and snippets.

@mashhadazam
Last active March 15, 2020 09:39
Show Gist options
  • Save mashhadazam/c7f64dd49dd36b164986c99ee8e47b92 to your computer and use it in GitHub Desktop.
Save mashhadazam/c7f64dd49dd36b164986c99ee8e47b92 to your computer and use it in GitHub Desktop.
## Get totals for all metrics
GlobalTotals=CountryConsolidated.reset_index().groupby('Date').sum()
GlobalTotals['Share of Recoveries - Closed Cases']=np.round(GlobalTotals['Total Recoveries']/(GlobalTotals['Total Recoveries']+GlobalTotals['Total Deaths']),2)
GlobalTotals['Death to Cases Ratio']=np.round(GlobalTotals['Total Deaths']/GlobalTotals['Total Confirmed Cases'],3)
GlobalTotals.tail(2)
# Create Plots that show Key Metrics For the Covid-19
chartcol='red'
fig = make_subplots(rows=3, cols=2,shared_xaxes=True,
specs=[[{}, {}],[{},{}],
[{"colspan": 2}, None]],
subplot_titles=('Total Confirmed Cases','Active Cases','Deaths','Recoveries','Death to Cases Ratio'))
fig.add_trace(go.Scatter(x=GlobalTotals.index,y=GlobalTotals['Total Confirmed Cases'],
mode='lines+markers',
name='Confirmed Cases',
line=dict(color=chartcol,width=2)),
row=1,col=1)
fig.add_trace(go.Scatter(x=GlobalTotals.index,y=GlobalTotals['Active Cases'],
mode='lines+markers',
name='Active Cases',
line=dict(color=chartcol,width=2)),
row=1,col=2)
fig.add_trace(go.Scatter(x=GlobalTotals.index,y=GlobalTotals['Total Deaths'],
mode='lines+markers',
name='Deaths',
line=dict(color=chartcol,width=2)),
row=2,col=1)
fig.add_trace(go.Scatter(x=GlobalTotals.index,y=GlobalTotals['Total Recoveries'],
mode='lines+markers',
name='Recoveries',
line=dict(color=chartcol,width=2)),
row=2,col=2)
fig.add_trace(go.Scatter(x=GlobalTotals.index,y=GlobalTotals['Death to Cases Ratio'],
mode='lines+markers',
line=dict(color=chartcol,width=2)),
row=3,col=1)
fig.update_layout(showlegend=False)
@mashhadazam
Copy link
Author

Thanks for pointing out. I have updated it now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment