From bac8cac1b70b0a5fe0bd2edb9314f7f9236d4b71 Mon Sep 17 00:00:00 2001 From: Benedikt Bastin Date: Sun, 17 Jan 2021 19:56:30 +0100 Subject: [PATCH] feat: Added parsing of details and table with details to dashboard --- dashboard_template.xhtml | 59 ++++++++++++++++++++++++++++++++++++++++ plot.py | 53 ++++++++++++++++++++++++++++++++++-- site/rki-dashboard.css | 29 ++++++++++++++++++++ 3 files changed, 138 insertions(+), 3 deletions(-) diff --git a/dashboard_template.xhtml b/dashboard_template.xhtml index cd5f63c..d506e49 100644 --- a/dashboard_template.xhtml +++ b/dashboard_template.xhtml @@ -31,6 +31,64 @@ Mit dieser Rate dauert es bis zum {{ mean_vaccinations_last_seven_days_herd_immunity }} für {{ herd_immunity }} % und bis zum {{ mean_vaccinations_last_seven_days_done }} für 100 %.

+
+

Details

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + {% for land in details_per_land %} + + + + + + + + + + + + + + {% endfor %} + +
Land + Impfungen
+ gesamt +
Impfung wegen6
AlterBerufGesundheitPflegeheim
Anzahl%Anzahl%Anzahl%Anzahl%Anzahl%
{{ land }}{{ details_per_land[land].total_vaccinations }}{{ details_per_land[land].total_vaccinations_percentage }} %{{ details_per_land[land].vaccination_reason_age }}{{ details_per_land[land].vaccination_reason_age_percentage }} %{{ details_per_land[land].vaccination_reason_job }}{{ details_per_land[land].vaccination_reason_job_percentage }} %{{ details_per_land[land].vaccination_reason_medical }}{{ details_per_land[land].vaccination_reason_medical_percentage }} %{{ details_per_land[land].vaccination_reason_oldhome }}{{ details_per_land[land].vaccination_reason_oldhome_percentage }} %
+
+ Tabelle 1: + Details der Impfungen, aufgeschlüsselt nach Ländern
+ Der Prozentwert bezieht sich bei den Gründen auf die in dem jeweiligen Land insgesamt vorgenommenen Impfungen, nicht auf die Größe der jeweiligen Gruppe. + Eine Impfung kann mehrere der genannten Gründe haben oder bei keinen der Gründen genannt werden, daher stimmen die Summe der Gründe und die Gesamtzahl der Impfungen nicht überein. +
+
+

Fragen und Antworten

@@ -138,6 +196,7 @@
  • Bevölkerungsstand vom 31. Dezember 2019: {{ einwohner_deutschland }}.
  • {{ herd_immunity }} % ist der Wert, bei dem aktuell von einer Herdenimmunität ausgegangen wird.
  • Die täglichen Impfraten unterliegen starken Schwankungen und sind daher wenig aussagekräftig.
  • +
  • Nicht alle Länder veröffentlichen alle in der Aufschlüsselung aufgelisteten Daten.
  • diff --git a/plot.py b/plot.py index 559a938..14212f9 100644 --- a/plot.py +++ b/plot.py @@ -40,8 +40,6 @@ with open(data_filename, 'wb') as outfile: - - rki_file = pd.read_excel(data_filename, sheet_name=None, engine='openpyxl') raw_data = rki_file['Impfungen_proTag'] @@ -113,6 +111,54 @@ print_stand = stand_date.isoformat() filename_stand = stand_date.strftime("%Y%m%d%H%M%S") +# Infos der einzelnen Länder +details_sheet_name = (set(rki_file.keys()) - {'Erläuterung', 'Impfungen_proTag'}).pop() + +details_sheet = rki_file[details_sheet_name] + +land_names = details_sheet['Bundesland'].iloc[0:17] + +total_vaccinations_by_land = details_sheet['Impfungen kumulativ'].iloc[0:17] +vaccination_per_mille_by_land = details_sheet['Impfungen pro 1.000 Einwohner'].iloc[0:17] + +vaccination_reason_age_by_land = details_sheet['Indikation nach Alter*'].iloc[0:17] +vaccination_reason_job_by_land = details_sheet['Berufliche Indikation*'].iloc[0:17] +vaccination_reason_medical_by_land = details_sheet['Medizinische Indikation*'].iloc[0:17] +vaccination_reason_oldhome_by_land = details_sheet['Pflegeheim-bewohnerIn*'].iloc[0:17] + +details_per_land = {} +details_per_land_formatted = {} +for i in range(len(land_names)): + + details_per_land[land_names[i]] = { + 'total_vaccinations': int(total_vaccinations_by_land[i]), + 'total_vaccinations_percentage': vaccination_per_mille_by_land[i] / 10, + 'vaccination_reason_age': int(vaccination_reason_age_by_land[i]), + 'vaccination_reason_age_percentage': np.round(vaccination_reason_age_by_land[i] / total_vaccinations_by_land[i] * 100), + 'vaccination_reason_job': int(vaccination_reason_job_by_land[i]), + 'vaccination_reason_job_percentage': np.round(vaccination_reason_job_by_land[i] / total_vaccinations_by_land[i] * 100), + 'vaccination_reason_medical': int(vaccination_reason_medical_by_land[i]), + 'vaccination_reason_medical_percentage': np.round(vaccination_reason_medical_by_land[i] / total_vaccinations_by_land[i] * 100), + 'vaccination_reason_oldhome': int(vaccination_reason_oldhome_by_land[i]), + 'vaccination_reason_oldhome_percentage': np.round(vaccination_reason_oldhome_by_land[i] / total_vaccinations_by_land[i] * 100), + + } + details_per_land_formatted[land_names[i]] = { + 'total_vaccinations': '{:n}'.format(int(total_vaccinations_by_land[i])).replace('.', ' '), + 'total_vaccinations_percentage': '{:.3n}'.format(np.round(vaccination_per_mille_by_land[i] / 10, 2)), + 'vaccination_reason_age': '{:n}'.format(int(vaccination_reason_age_by_land[i])).replace('.', ' '), + 'vaccination_reason_age_percentage': '{:n}'.format(np.round(vaccination_reason_age_by_land[i] / total_vaccinations_by_land[i] * 100)), + 'vaccination_reason_job': '{:n}'.format(int(vaccination_reason_job_by_land[i])).replace('.', ' '), + 'vaccination_reason_job_percentage': '{:n}'.format(np.round(vaccination_reason_job_by_land[i] / total_vaccinations_by_land[i] * 100)), + 'vaccination_reason_medical': '{:n}'.format(int(vaccination_reason_medical_by_land[i])).replace('.', ' '), + 'vaccination_reason_medical_percentage': '{:n}'.format(np.round(vaccination_reason_medical_by_land[i] / total_vaccinations_by_land[i] * 100)), + 'vaccination_reason_oldhome': '{:n}'.format(int(vaccination_reason_oldhome_by_land[i])).replace('.', ' '), + 'vaccination_reason_oldhome_percentage': '{:n}'.format(np.round(vaccination_reason_oldhome_by_land[i] / total_vaccinations_by_land[i] * 100)), + + } + + + archive_folder = site_folder + 'archive/' + filename_stand if os.path.isdir(archive_folder): @@ -227,7 +273,8 @@ def render_dashboard(): last_date_day_rate_done = last_date_day_rate_done.strftime(df), mean_vaccinations_last_seven_days = '{:n}'.format(mean_vaccinations_last_seven_days_int).replace('.', ' '), mean_vaccinations_last_seven_days_herd_immunity = mean_vaccinations_last_seven_days_herd_immunity.strftime(df), - mean_vaccinations_last_seven_days_done = mean_vaccinations_last_seven_days_done.strftime(df) + mean_vaccinations_last_seven_days_done = mean_vaccinations_last_seven_days_done.strftime(df), + details_per_land = details_per_land_formatted ).dump('site/index.xhtml') shutil.copyfile(dashboard_filename, dashboard_archive_filename) diff --git a/site/rki-dashboard.css b/site/rki-dashboard.css index a66504a..52cd444 100644 --- a/site/rki-dashboard.css +++ b/site/rki-dashboard.css @@ -45,6 +45,10 @@ sup { +figure { + max-width: 100%; +} + figure img { width: 90%; height: auto; @@ -57,3 +61,28 @@ figure figcaption { figure figcaption .ref { font-weight: bolder; } + +figure { + overflow-y: auto; +} + +table { + border-collapse: collapse; +} + +table td, table th { + padding: .2em .5em; + border: 1px solid #333333; +} + +table th { + background: #BADBFF; +} + +table tbody th { + text-align: left; +} + +table td.number { + text-align: right; +}