Skip to content

Instantly share code, notes, and snippets.

@denis-bz
Last active September 9, 2020 09:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save denis-bz/8eb826cd3e7039a987e74620a41f049e to your computer and use it in GitHub Desktop.
Covid-19 % cases hospitalized in Germany up to 6 Sept 2020

Covid-19 cases hospitalized in Germany, March up to 6 September 2020

Keywords: Covid-19, hospitalized, Germany, plot, python

This plot shows the number of Covid-19 cases per week, the number hospitalized, and number of deaths, in Germany for weeks 10 to 36 2020:

9sep2020-Covid19-hospitalized-de-8sep

The data is taken from this report:
https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Situationsberichte/Sept_2020/2020-09-08-en.pdf from the Robert Koch Institute, a German federal agency responsible for disease control. Table 3 is extracted from the .pdf to the .csv table below, and plotted with the python program which is also below.

Track all cases, or the 5 % who are hospitalized ?

The RKI report says, "In most cases, the disease is mild." In weeks 31 - 36 (27 July - 6 September),

 9   7   6   5   5  5 %  of the cases were hospitalized
91  93  94  95  95 95 %  were not.

Seems to me that concentrating on the 5 % of the cases who enter hospital would be more meaningful (aussagekräftig) than looking at all cases, over 90 % of them mild.

What percentage of hospital beds are occupied by covid-19 patients ? Germany has a total of ~ 498,000 hospital beds, see statista .

The main goal is to identify hot spots and possible causes sooner. Hospitalization data per city and region (401 in Germany) would certainly help, but I see only totals for all Germany, from RKI on Tuesdays. Does anyone know of finer-grain data for other countries ?

Notes

"The purpose of statistics is insight, not numbers."
— paraphrasing R.W. Hamming.

Silly plots: the one on the front page of the Süddeutsche Zeitung from 22-23 August is particularly creative.

Comments welcome

cheers
— denis-bz-py t-online.de 9 September

#!/usr/bin/env/python
"""Covid-19 in Germany from week 10, March to week 36, 31 Aug - 6 Sept
from https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Situationsberichte/Sept_2020/2020-09-08-en.pdf
"In most cases, the disease is mild."
"""
import sys
import time
import numpy as np
import pandas as pd
from matplotlib import pyplot as pl
from matplotlib.ticker import MultipleLocator
import seaborn as sns
def ints( x ):
return np.round(x).astype(int)
__version__ = "2020-09-09 Sept denis-bz-py t-online.de"
np.set_printoptions( threshold=20, edgeitems=20, linewidth=140,
formatter = dict( float = lambda x: "%.2g" % x )) # float arrays %.2g
pd.set_option( "display.width", 120,
"display.max_rows", 10,
"display.precision", 0 )
print( 80 * "=" )
#...............................................................................
csv = "rki-8sep.csv"
save = "Covid19-hospitalized-de-8sep.png"
red = "#C40233" # NCS
alpha = 0.04 # fill
# to change these params, run this.py a=1 b=None 'c = "..."' ... in sh or ipython --
for arg in sys.argv[1:]:
exec( arg )
thispy = sys.argv[0]
print( thispy, csv, " run", time.strftime( "%d %b %Y" ))
print( __doc__ ) # at the top
#...............................................................................
df = pd.read_csv( csv, sep=r'\s+', comment='#' )
print( "-- %s --" % csv )
print( df )
Week = df.Week.values
Cases = df.Cases.values
Info = df.Info.values
Hosp = df.Hosp.values
Died = df.Deaths.values
print( "Cases / 100:", ints( Cases / 100 ))
print( "Hospitalized:", Hosp )
print( "Hosp * Cases / Info:", ints( Hosp * Cases / Info ))
print( "Info / Cases %:", ints( Info / Cases * 100 ))
print( "Died:", Died )
fig, axes = pl.subplots( nrows=3, figsize=[10, 6],
gridspec_kw = dict( height_ratios=[4,4,1] ))
pl.subplots_adjust( left=.08, bottom=.05, top=.88, right=1, hspace=.20 )
fig.suptitle( __doc__.strip(), multialignment="left" )
colors = ["green", red, "black"]
#...............................................................................
for nm, data, color, ax in zip(
["Covid-19 cases per week", "Hospitalized", "Deaths"],
[Cases, Hosp, Died],
colors,
axes ):
ax.set( ylabel=nm )
ax.xaxis.set_minor_locator( MultipleLocator() )
ax.xaxis.grid( True, which="minor" ) # SO [matplotlib] [grid]
if ax is not axes[-1]:
ax.set( xticklabels=[] )
sns.despine( fig=fig, ax=ax, top=True, right=True, left=True, bottom=True )
data = ints( data )
ax.plot( Week, data, color=color )
# numbers along the curve --
for week, val in zip( Week, data ):
ax.text( week, val, val, fontsize=8,
horizontalalignment="center", verticalalignment="bottom", color=color )
axes[0].plot( Week, Hosp, color=colors[1], lw=1 )
for ax in axes[[0,1]]:
ax.fill_between( Week, np.zeros_like(Hosp), Hosp,
facecolor=colors[1], alpha=alpha )
if save:
import numpyutil as nu
print( "\nwriting", save )
nu.savefig( save, thispy ) # pl.savefig + sign
pl.show()
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 3 columns, instead of 1. in line 1.
# Covid-19 in Germany from week 10, 2-8 March to week 36, 31 Aug - 6 Sept
# https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Situationsberichte/Sept_2020/2020-09-08-en.pdf
Week Cases Age M F Info Hosp Hosp% Deaths Deaths%
10 892 42 53 47 800 162 20 12 1.3
11 6428 45 56 44 5613 521 9 85 1.3
12 22439 45 55 45 19334 2198 11 474 2.1
13 34028 48 49 51 29424 5076 17 1447 4.3
14 36104 51 45 55 31484 6044 19 2246 6.2
15 27175 52 44 56 24024 4685 20 1862 6.9
16 17339 51 45 55 15462 3339 22 1207 7.0
17 12365 50 45 55 10905 2210 20 712 5.8
18 7443 48 48 52 6577 1350 21 374 5.0
19 6222 47 48 52 5589 1060 19 249 4.0
20 4721 45 49 51 4190 726 17 155 3.3
21 3612 43 50 50 3097 506 16 107 3.0
22 3196 42 51 49 2747 410 15 60 1.9
23 2350 39 51 49 2068 308 15 43 1.8
24 2338 37 54 46 2071 281 14 31 1.3
25 4086 36 59 41 3724 312 8 34 0.8
26 3195 37 55 45 2831 292 10 23 0.7
27 2692 36 52 48 2453 256 10 24 0.9
28 2414 36 56 44 2149 244 11 22 0.9
29 3013 36 52 48 2595 314 12 29 1.0
30 3924 36 52 48 3349 317 9 31 0.8
31 4812 36 50 50 3984 365 9 29 0.6
32 6033 34 54 46 5087 376 7 23 0.4
33 7912 32 53 47 6683 399 6 22 0.3
34 9542 32 55 45 7897 393 5 16 0.2
35 8746 32 53 47 6861 313 5 7 0.1
36 8346 33 54 46 5954 290 5 3 0.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment