COVID-19 Ländervergleich
Ingo Dahn (dahn@dahn-research.eu)
Mit diesem Notebook kann man die Entwicklung der wöchentlichen COVID-19-Daten seit Anfang 2020 (Infizierte und Verstorbene) in zwei Ländern vergleichen. Diese Seite wird unter der Creative Commons Lizenz CC BY-NC-SA 4.0 veröffentlicht.
Die Daten werden von https://opendata.ecdc.europa.eu/covid19/casedistribution/csv geladen und sind so stets aktuell.
import pandas as pd
url="https://opendata.ecdc.europa.eu/covid19/casedistribution/csv"
data=pd.read_csv(url)
data=data.sort_values(by=['countriesAndTerritories','year_week'])
dataV=data.values
dataT=data.T
dataTV=dataT.values
regions=sorted(set(dataTV[8]))
dataD={}
for n in range(0,len(dataV)):
line=dataV[n]
region=line[8];country=line[4];date=line[0]; cases=line[2]; deaths=line[3]; population=line[7]
if country == 'Cura\xc3\xa7ao':
country='Curacao'
if region == 'Other' or population == 'nan':
next
if not region in dataD.keys():
dataD[region]={}
if not country in dataD[region].keys():
dataD[region][country]={'population': population, 'dates':[], 'cases':[],'deaths':[]}
dataD[region][country]['dates'].append(date)
dataD[region][country]['cases'].append(cases)
dataD[region][country]['deaths'].append(deaths)
defaultCountries={'Europe': 'Germany', 'America': 'United_States_of_America','Asia': 'China', 'Africa':'South_Africa', 'Oceania': 'Australia'}
datesAll=dataD['Europe']['Germany']['dates']
dataNr=len(datesAll)
datesMap={}
for n in range(0,dataNr):
datesMap[datesAll[n]]=n
regions=sorted(defaultCountries.keys())
def setDates(Dates,Data):
LL=[0 for n in range(0,dataNr)]
for i in range(0,len(Dates)):
LL[datesMap[Dates[i]]]=Data[i]
return LL
def cumulateList(L):
LL=[];s=0;
for i in range(0,len(L)):
s += L[i]
LL.append(s)
return LL
def normListPer(L,Ord,Pop):
po=Ord/Pop
return [n*po for n in L]
def cumulatedNormed(L,c,n,P):
casePlotData0=L
if c:
casePlotData1=cumulateList(L)
else:
casePlotData1=casePlotData0
if n:
casePlotData=normListPer(casePlotData1,10^5,P)
else:
casePlotData=casePlotData1
return casePlotData
region_1='Europe';country_1='Germany'
region_2='America'; country_2='United_States_of_America'
style = """
<style type="text/css">
.sagecell_interactContainer{border: none; margin: 0px; padding: 0px}
.sagecell_interactControlLabel{min-width: 8ex; text-align: left !important}
.sagecell_interactOutput{padding: 0px}
</style>
"""
show(html(style))
show(html(u"Daten von %s bis %s geladen"%(datesAll[0],datesAll[dataNr-1])))
@interact
def panel_11(region_1s=selector(regions,default=region_1,buttons=True,label="Region 1:")):
@interact
def panel_12(country_1s=selector(sorted(dataD[region_1s].keys()),default=defaultCountries[region_1s], label="Land 1:")):
global region_1
region_1=region_1s
global country_1
country_1=country_1s
@interact
def panel_21(region_2s=selector(regions,default=region_2,buttons=True,label="Region 2:")):
@interact
def panel_22(country_2s=selector(sorted(dataD[region_2s].keys()),default=defaultCountries[region_2s], label="Land 2:")):
global region_2
region_2=region_2s
global country_2
country_2=country_2s
@interact
def _(cumulate1=checkbox(False,label='Werte kumulieren'), norm1=checkbox(True,label="Werte normieren")):
global cumulate
cumulate=cumulate1
global norm
norm=norm1
C1=setDates(dataD[region_1][country_1]['dates'],dataD[region_1][country_1]['cases'])
C2=setDates(dataD[region_2][country_2]['dates'],dataD[region_2][country_2]['cases'])
D1=setDates(dataD[region_1][country_1]['dates'],dataD[region_1][country_1]['deaths'])
D2=setDates(dataD[region_2][country_2]['dates'],dataD[region_2][country_2]['deaths'])
DataCasePlot1=cumulatedNormed(C1,cumulate1,norm1,dataD[region_1][country_1]['population'])
DataCasePlot2=cumulatedNormed(C2,cumulate1,norm1,dataD[region_2][country_2]['population'])
DataDeathPlot1=cumulatedNormed(D1,cumulate1,norm1,dataD[region_1][country_1]['population'])
DataDeathPlot2=cumulatedNormed(D2,cumulate1,norm1,dataD[region_2][country_2]['population'])
labelCase1="COVID-19-Infektionen in "+country_1
labelCase2="COVID-19-Infektionen in "+country_2
labelDeath1="COVID-19-Tote in "+country_1
labelDeath2="COVID-19-Tote in "+country_2
if cumulate:
labelCase1 += " kumuliert";labelCase2 += " kumuliert";
#labelDeath1 += " kumuliert";labelDeath2 += " kumuliert";
if norm:
labelCase1 += ", pro 100 000 Einwohner";labelCase2 += ", pro 100 000 Einwohner";
#labelDeath1 += ", pro 100 000 Einwohner";labelDeath2 += ", pro 100 000 Einwohner";
show(list_plot(DataCasePlot1, color='blue',legend_label=labelCase1)+list_plot(DataCasePlot2, color='red',legend_label=labelCase2))
show(list_plot(DataDeathPlot1, color='blue',legend_label=labelDeath1)+list_plot(DataDeathPlot2, color='red',legend_label=labelDeath2))Daten von 06/01/2020 bis 14/12/2020 geladen
SW50ZXJhY3RpdmUgZnVuY3Rpb24gPGZ1bmN0aW9uIHBhbmVsXzExIGF0IDB4N2Y4NzJjNTQyNTc4PiB3aXRoIDEgd2lkZ2V0CiAgcmVnaW9uXzFzOiBUb2dnbGVCdXR0b25zKGRlc2NyaXB0aW/igKY=
Accepted: {"data":{"text/plain":"text/image-filename file","text/image-filename":"tmp_ipxpy2t1.png?m=1608304552.3353267"},"source":"sagecell"}
Accepted: {"data":{"text/plain":"text/image-filename file","text/image-filename":"tmp_e8so94bz.png?m=1608304551.907289"},"source":"sagecell"}
Accepted: {"data":{"application/sage-clear":{"changed":["cumulate1","norm1"]},"text/plain":"Clear display"},"source":"sagecell"}
Accepted: {"data":{"application/sage-interact":{"new_interact_id":"82a0181d-2691-4940-bdf8-32b3451ef18b","controls":{"cumulate1":{"control_type":"checkbox","default":false,"raw":true,"label":"Werte kumulieren","update":true},"norm1":{"control_type":"checkbox","default":true,"raw":true,"label":"Werte normieren","update":true}},"layout":[[["cumulate1",1]],[["norm1",1]],[["_output",1]]],"locations":null,"readonly":false},"text/plain":"Sage Interact"},"source":"sagecell"}
Accepted: {"data":{"application/sage-clear":{"changed":["country_2s"]},"text/plain":"Clear display"},"source":"sagecell"}
Accepted: {"data":{"application/sage-interact":{"new_interact_id":"0978b21c-6d50-445c-8536-ac75d565623b","controls":{"country_2s":{"control_type":"selector","subtype":"list","values":49,"value_labels":["Anguilla","Antigua_and_Barbuda","Argentina","Aruba","Bahamas","Barbados","Belize","Bermuda","Bolivia","Bonaire, Saint Eustatius and Saba","Brazil","British_Virgin_Islands","Canada","Cayman_Islands","Chile","Colombia","Costa_Rica","Cuba","Curaçao","Dominica","Dominican_Republic","Ecuador","El_Salvador","Falkland_Islands_(Malvinas)","Greenland","Grenada","Guatemala","Guyana","Haiti","Honduras","Jamaica","Mexico","Montserrat","Nicaragua","Panama","Paraguay","Peru","Puerto_Rico","Saint_Kitts_and_Nevis","Saint_Lucia","Saint_Vincent_and_the_Grenadines","Sint_Maarten","Suriname","Trinidad_and_Tobago","Turks_and_Caicos_islands","United_States_Virgin_Islands","United_States_of_America","Uruguay","Venezuela"],"default":46,"nrows":null,"ncols":null,"raw":true,"width":"None","label":"Land 2:","update":true}},"layout":[[["country_2s",1]],[["_output",1]]],"locations":null,"readonly":false},"text/plain":"Sage Interact"},"source":"sagecell"}
Accepted: {"data":{"application/sage-clear":{"changed":["region_2s"]},"text/plain":"Clear display"},"source":"sagecell"}
Accepted: {"data":{"application/sage-interact":{"new_interact_id":"aa8b93ef-13f0-4858-9160-3471c4f84309","controls":{"region_2s":{"control_type":"selector","subtype":"button","values":5,"value_labels":["Africa","America","Asia","Europe","Oceania"],"default":1,"nrows":1,"ncols":5,"raw":true,"width":"None","label":"Region 2:","update":true}},"layout":[[["region_2s",1]],[["_output",1]]],"locations":null,"readonly":false},"text/plain":"Sage Interact"},"source":"sagecell"}
Accepted: {"data":{"application/sage-clear":{"changed":["country_1s"]},"text/plain":"Clear display"},"source":"sagecell"}
Accepted: {"data":{"application/sage-interact":{"new_interact_id":"bef47a92-595d-42d2-9994-a5093c7add0d","controls":{"country_1s":{"control_type":"selector","subtype":"list","values":55,"value_labels":["Albania","Andorra","Armenia","Austria","Azerbaijan","Belarus","Belgium","Bosnia_and_Herzegovina","Bulgaria","Croatia","Cyprus","Czechia","Denmark","Estonia","Faroe_Islands","Finland","France","Georgia","Germany","Gibraltar","Greece","Guernsey","Holy_See","Hungary","Iceland","Ireland","Isle_of_Man","Italy","Jersey","Kosovo","Latvia","Liechtenstein","Lithuania","Luxembourg","Malta","Moldova","Monaco","Montenegro","Netherlands","North_Macedonia","Norway","Poland","Portugal","Romania","Russia","San_Marino","Serbia","Slovakia","Slovenia","Spain","Sweden","Switzerland","Turkey","Ukraine","United_Kingdom"],"default":18,"nrows":null,"ncols":null,"raw":true,"width":"None","label":"Land 1:","update":true}},"layout":[[["country_1s",1]],[["_output",1]]],"locations":null,"readonly":false},"text/plain":"Sage Interact"},"source":"sagecell"}
Accepted: {"data":{"application/sage-clear":{"changed":["region_1s"]},"text/plain":"Clear display"},"source":"sagecell"}
Accepted: {"data":{"application/sage-interact":{"new_interact_id":"66935b44-d0a3-420b-b5d1-c483093ca34b","controls":{"region_1s":{"control_type":"selector","subtype":"button","values":5,"value_labels":["Africa","America","Asia","Europe","Oceania"],"default":3,"nrows":1,"ncols":5,"raw":true,"width":"None","label":"Region 1:","update":true}},"layout":[[["region_1s",1]],[["_output",1]]],"locations":null,"readonly":false},"text/plain":"Sage Interact"},"source":"sagecell"}
Accepted: {"data":{"text/plain":"html","text/html":"Daten von 06/01/2020 bis 14/12/2020 geladen"},"source":"sagecell"}
Accepted: {"data":{"text/plain":"html","text/html":"\n<style type=\"text/css\">\n.sagecell_interactContainer{border: none; margin: 0px; padding: 0px}\n.sagecell_interactControlLabel{min-width: 8ex; text-align: left !important}\n.sagecell_interactOutput{padding: 0px}\n</style>\n"},"source":"sagecell"}
Messages