Files
HowBadIsMyBatch/src/intensivstationen/Intensivstationen.ipynb
2022-03-31 08:52:11 +02:00

5110 lines
113 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "9de5907f-18f5-4cb1-903e-26028ff1fa03",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from urllib import request\n",
"\n",
"pd.set_option('display.max_rows', 100)\n",
"pd.set_option('display.max_columns', None)\n",
"pd.set_option('mode.chained_assignment', 'raise')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e40d4c8d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"31.03.2022, 08:46:18 Uhr\n"
]
}
],
"source": [
"from datetime import datetime\n",
"\n",
"print(datetime.now().strftime(\"%d.%m.%Y, %H:%M:%S Uhr\"))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "579c0911",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch-pages/src/intensivstationen\n"
]
}
],
"source": [
"! pwd"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "dfa836ec",
"metadata": {},
"outputs": [],
"source": [
"needsUpdate = False"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "79de4057",
"metadata": {},
"outputs": [],
"source": [
"from bs4 import BeautifulSoup\n",
"import requests\n",
"from datetime import datetime\n",
"from time import sleep\n",
"from selenium import webdriver\n",
"from selenium.webdriver.firefox.options import Options\n",
"\n",
"class DateProvider:\n",
" \n",
" INTENSIVSTATIONEN_DATE_FORMAT = \"%d.%m.%Y, %H:%M Uhr\"\n",
"\n",
" def __init__(self):\n",
" self.lastUpdated = None\n",
" self.lastUpdatedDataSource = None\n",
"\n",
" def needsUpdate(self):\n",
" return self.getLastUpdated() < self.getLastUpdatedDataSource()\n",
" \n",
" def getLastUpdated(self):\n",
" if self.lastUpdated is None:\n",
" htmlContent = requests.get(\"https://knollfrank.github.io/HowBadIsMyBatch/intensivstationen.html\").text\n",
" soup = BeautifulSoup(htmlContent, \"lxml\")\n",
" dateStr = soup.find(id = \"Datenstand\").text\n",
" self.lastUpdated = datetime.strptime(dateStr, DateProvider.INTENSIVSTATIONEN_DATE_FORMAT)\n",
" \n",
" return self.lastUpdated\n",
"\n",
" def getLastUpdatedDataSource(self):\n",
" if self.lastUpdatedDataSource is None:\n",
" html = self._getOriginalHtml()\n",
" lastUpdatedColumn = 'Letzte Änderung'\n",
" dataFrame = self._asDataFrame(html, lastUpdatedColumn)\n",
" self.lastUpdatedDataSource = dataFrame.loc['Landkreis-Daten', lastUpdatedColumn].to_pydatetime()\n",
"\n",
" return self.lastUpdatedDataSource\n",
"\n",
" def _getOriginalHtml(self):\n",
" options = Options()\n",
" options.headless = True\n",
" driver = webdriver.Firefox(options = options)\n",
" driver.get('https://www.intensivregister.de/#/aktuelle-lage/downloads')\n",
" sleep(10)\n",
" innerHTML = driver.execute_script(\"return document.body.innerHTML\")\n",
" driver.quit()\n",
" return innerHTML\n",
"\n",
" def _asDataFrame(self, html, lastUpdatedColumn):\n",
" dataFrame = pd.read_html(html, parse_dates = [lastUpdatedColumn])[0]\n",
" dataFrame[lastUpdatedColumn] = pd.to_datetime(dataFrame[lastUpdatedColumn], format = \"%d.%m.%Y %H:%M Uhr\")\n",
" dataFrame.set_index('Name', inplace = True)\n",
" return dataFrame\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "336f56e6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" lastUpdated: 2022-03-29 13:32:00\n",
"lastUpdatedDataSource: 2022-03-30 13:32:00\n",
"needsUpdate: True\n"
]
}
],
"source": [
"dateProvider = DateProvider()\n",
"print(' lastUpdated:', dateProvider.getLastUpdated())\n",
"print('lastUpdatedDataSource:', dateProvider.getLastUpdatedDataSource()) \n",
"needsUpdate = dateProvider.needsUpdate()\n",
"print('needsUpdate:', needsUpdate)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "03784154",
"metadata": {},
"outputs": [],
"source": [
"from bs4 import BeautifulSoup\n",
"\n",
"class HtmlTransformerUtil:\n",
" \n",
" def applySoupTransformerToFile(self, file, soupTransformer):\n",
" self._writeSoup(soupTransformer(self._readSoup(file)), file)\n",
"\n",
" def _readSoup(self, file):\n",
" with open(file) as fp:\n",
" soup = BeautifulSoup(fp, 'lxml')\n",
" return soup\n",
"\n",
" def _writeSoup(self, soup, file):\n",
" with open(file, \"w\") as fp:\n",
" fp.write(str(soup)) \n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "af101279",
"metadata": {},
"outputs": [],
"source": [
"def saveLastUpdatedIntensivstationen(lastUpdated):\n",
" def setLastUpdated(soup):\n",
" soup.find(id = \"Datenstand\").string.replace_with(lastUpdated.strftime(DateProvider.INTENSIVSTATIONEN_DATE_FORMAT))\n",
" return soup\n",
"\n",
" HtmlTransformerUtil().applySoupTransformerToFile(\n",
" file = \"../../docs/intensivstationen.html\",\n",
" soupTransformer = setLastUpdated)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "63be303c",
"metadata": {},
"outputs": [],
"source": [
"saveLastUpdatedIntensivstationen(dateProvider.getLastUpdatedDataSource())"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "d021de84",
"metadata": {},
"outputs": [],
"source": [
"def readTimeseries(download = False):\n",
" timeSeriesFile = 'zeitreihe-tagesdaten.csv'\n",
" if download:\n",
" _downloadTimeseries(timeSeriesFile)\n",
"\n",
" timeseries = pd.read_csv(\n",
" timeSeriesFile,\n",
" low_memory = False,\n",
" usecols = ['date', 'bundesland', 'gemeindeschluessel', 'betten_belegt', 'betten_frei'],\n",
" parse_dates = ['date'],\n",
" date_parser = lambda dateStr: pd.to_datetime(dateStr, format = \"%Y-%m-%d\"),\n",
" dtype = {\n",
" 'gemeindeschluessel': 'string',\n",
" 'bundesland': 'string'\n",
" })\n",
" return timeseries.sort_values(by = 'date', ascending = True)\n",
"\n",
"# download https://diviexchange.blob.core.windows.net/%24web/zeitreihe-tagesdaten.csv or https://www.intensivregister.de/#/aktuelle-lage/downloads\n",
"def _downloadTimeseries(timeSeriesFile):\n",
" request.urlretrieve(\n",
" 'https://diviexchange.blob.core.windows.net/%24web/zeitreihe-tagesdaten.csv',\n",
" timeSeriesFile)\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "3f992231",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>bundesland</th>\n",
" <th>gemeindeschluessel</th>\n",
" <th>betten_frei</th>\n",
" <th>betten_belegt</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2020-04-24</td>\n",
" <td>01</td>\n",
" <td>01001</td>\n",
" <td>40</td>\n",
" <td>38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>267</th>\n",
" <td>2020-04-24</td>\n",
" <td>09</td>\n",
" <td>09471</td>\n",
" <td>9</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>266</th>\n",
" <td>2020-04-24</td>\n",
" <td>09</td>\n",
" <td>09464</td>\n",
" <td>17</td>\n",
" <td>23</td>\n",
" </tr>\n",
" <tr>\n",
" <th>265</th>\n",
" <td>2020-04-24</td>\n",
" <td>09</td>\n",
" <td>09463</td>\n",
" <td>9</td>\n",
" <td>25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>264</th>\n",
" <td>2020-04-24</td>\n",
" <td>09</td>\n",
" <td>09462</td>\n",
" <td>12</td>\n",
" <td>51</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279131</th>\n",
" <td>2022-03-30</td>\n",
" <td>06</td>\n",
" <td>06437</td>\n",
" <td>7</td>\n",
" <td>119</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279130</th>\n",
" <td>2022-03-30</td>\n",
" <td>06</td>\n",
" <td>06436</td>\n",
" <td>1</td>\n",
" <td>23</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279129</th>\n",
" <td>2022-03-30</td>\n",
" <td>06</td>\n",
" <td>06435</td>\n",
" <td>11</td>\n",
" <td>70</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279127</th>\n",
" <td>2022-03-30</td>\n",
" <td>06</td>\n",
" <td>06433</td>\n",
" <td>2</td>\n",
" <td>19</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279400</th>\n",
" <td>2022-03-30</td>\n",
" <td>16</td>\n",
" <td>16077</td>\n",
" <td>5</td>\n",
" <td>27</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>279401 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" date bundesland gemeindeschluessel betten_frei betten_belegt\n",
"0 2020-04-24 01 01001 40 38\n",
"267 2020-04-24 09 09471 9 9\n",
"266 2020-04-24 09 09464 17 23\n",
"265 2020-04-24 09 09463 9 25\n",
"264 2020-04-24 09 09462 12 51\n",
"... ... ... ... ... ...\n",
"279131 2022-03-30 06 06437 7 119\n",
"279130 2022-03-30 06 06436 1 23\n",
"279129 2022-03-30 06 06435 11 70\n",
"279127 2022-03-30 06 06433 2 19\n",
"279400 2022-03-30 16 16077 5 27\n",
"\n",
"[279401 rows x 5 columns]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"timeSeries = readTimeseries(download = needsUpdate)\n",
"timeSeries"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "2d34c6a4",
"metadata": {},
"outputs": [],
"source": [
"def readKreise(download = False):\n",
" kreiseFile = '04-kreise.xlsx'\n",
" if download:\n",
" _downloadKreise(kreiseFile)\n",
" \n",
" kreise = pd.read_excel(\n",
" kreiseFile,\n",
" sheet_name = 'Kreisfreie Städte u. Landkreise',\n",
" header = 5,\n",
" index_col = 0)\n",
" kreise = kreise.rename(columns = {'2': 'Bundesland', 3: 'Kreis', 6: 'Einwohnerzahl'})[['Bundesland', 'Kreis', 'Einwohnerzahl']]\n",
" kreise.index.set_names(\"Key\", inplace = True)\n",
" return kreise\n",
"\n",
"# download https://www.destatis.de/DE/Themen/Laender-Regionen/Regionales/Gemeindeverzeichnis/Administrativ/04-kreise.xlsx?__blob=publicationFile or https://www.destatis.de/DE/Themen/Laender-Regionen/Regionales/Gemeindeverzeichnis/Administrativ/04-kreise.html\n",
"def _downloadKreise(kreiseFile):\n",
" request.urlretrieve(\n",
" 'https://www.destatis.de/DE/Themen/Laender-Regionen/Regionales/Gemeindeverzeichnis/Administrativ/04-kreise.xlsx?__blob=publicationFile',\n",
" kreiseFile)\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "74ea4d55",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Bundesland</th>\n",
" <th>Kreis</th>\n",
" <th>Einwohnerzahl</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Key</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>NaN</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>01</th>\n",
" <td>Schleswig-Holstein</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>01001</th>\n",
" <td>Kreisfreie Stadt</td>\n",
" <td>Flensburg, Stadt</td>\n",
" <td>89934.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>01002</th>\n",
" <td>Kreisfreie Stadt</td>\n",
" <td>Kiel, Landeshauptstadt</td>\n",
" <td>246601.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>01003</th>\n",
" <td>Kreisfreie Stadt</td>\n",
" <td>Lübeck, Hansestadt</td>\n",
" <td>215846.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2) Die Ergebnisse ab Berichtsjahr 2016 sind aufgrund methodischer Änderungen und technischer Weiterentwicklung\\n nur bedingt mit den Vorjahreswerten vegleichbar. Erläuterungen dazu finden Sie unter www.destatis.de beim Bevölkerungsstand.</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>NaN</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>© Daten (im Auftrag der Herausgebergemeinschaft Statistische Ämter des Bundes und der Länder)</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Statistisches Bundesamt (Destatis), 2021</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vervielfältigung und Verbreitung, auch auszugsweise, mit Quellenangabe gestattet.</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>488 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" Bundesland \\\n",
"Key \n",
"NaN NaN \n",
"01 Schleswig-Holstein \n",
"01001 Kreisfreie Stadt \n",
"01002 Kreisfreie Stadt \n",
"01003 Kreisfreie Stadt \n",
"... ... \n",
"2) Die Ergebnisse ab Berichtsjahr 2016 sind auf... NaN \n",
"NaN NaN \n",
"© Daten (im Auftrag der Herausgebergemeinschaft... NaN \n",
" Statistisches Bundesamt (Destatis), 2021 NaN \n",
" Vervielfältigung und Verbreitung, auch aus... NaN \n",
"\n",
" Kreis \\\n",
"Key \n",
"NaN NaN \n",
"01 NaN \n",
"01001 Flensburg, Stadt \n",
"01002 Kiel, Landeshauptstadt \n",
"01003 Lübeck, Hansestadt \n",
"... ... \n",
"2) Die Ergebnisse ab Berichtsjahr 2016 sind auf... NaN \n",
"NaN NaN \n",
"© Daten (im Auftrag der Herausgebergemeinschaft... NaN \n",
" Statistisches Bundesamt (Destatis), 2021 NaN \n",
" Vervielfältigung und Verbreitung, auch aus... NaN \n",
"\n",
" Einwohnerzahl \n",
"Key \n",
"NaN NaN \n",
"01 NaN \n",
"01001 89934.0 \n",
"01002 246601.0 \n",
"01003 215846.0 \n",
"... ... \n",
"2) Die Ergebnisse ab Berichtsjahr 2016 sind auf... NaN \n",
"NaN NaN \n",
"© Daten (im Auftrag der Herausgebergemeinschaft... NaN \n",
" Statistisches Bundesamt (Destatis), 2021 NaN \n",
" Vervielfältigung und Verbreitung, auch aus... NaN \n",
"\n",
"[488 rows x 3 columns]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"kreise = readKreise(download = False)\n",
"kreise"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "af96fb11",
"metadata": {},
"outputs": [],
"source": [
"class ColumnsAdder:\n",
"\n",
" def __init__(self, kreise):\n",
" self.kreise = kreise\n",
"\n",
" def addKreisAndBundeslandAndEinwohnerzahlColumns(self, dataFrame):\n",
" dataFrame = self.addKreisAndEinwohnerzahlColumns(dataFrame)\n",
" return self._addBundeslandColumn(dataFrame)\n",
" \n",
" def addKreisAndEinwohnerzahlColumns(self, dataFrame):\n",
" dataFrame_kreise = pd.merge(dataFrame, self.kreise, how = 'left', left_on = 'gemeindeschluessel', right_index = True)\n",
" dataFrame['Kreis'] = dataFrame_kreise['Kreis']\n",
" dataFrame['Einwohnerzahl'] = dataFrame_kreise['Einwohnerzahl']\n",
" return dataFrame\n",
"\n",
" def _addBundeslandColumn(self, dataFrame):\n",
" return pd.merge(\n",
" dataFrame,\n",
" self._createBundeslandByKeyTable(),\n",
" how = 'left',\n",
" left_on = 'bundesland',\n",
" right_index = True)\n",
"\n",
" def _createBundeslandByKeyTable(self):\n",
" return self.kreise[self.kreise.index.str.len() == 2][['Bundesland']]\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "62a20115",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>bundesland</th>\n",
" <th>gemeindeschluessel</th>\n",
" <th>betten_frei</th>\n",
" <th>betten_belegt</th>\n",
" <th>Kreis</th>\n",
" <th>Einwohnerzahl</th>\n",
" <th>Bundesland</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2020-04-24</td>\n",
" <td>01</td>\n",
" <td>01001</td>\n",
" <td>40</td>\n",
" <td>38</td>\n",
" <td>Flensburg, Stadt</td>\n",
" <td>89934.0</td>\n",
" <td>Schleswig-Holstein</td>\n",
" </tr>\n",
" <tr>\n",
" <th>267</th>\n",
" <td>2020-04-24</td>\n",
" <td>09</td>\n",
" <td>09471</td>\n",
" <td>9</td>\n",
" <td>9</td>\n",
" <td>Bamberg</td>\n",
" <td>147497.0</td>\n",
" <td>Bayern</td>\n",
" </tr>\n",
" <tr>\n",
" <th>266</th>\n",
" <td>2020-04-24</td>\n",
" <td>09</td>\n",
" <td>09464</td>\n",
" <td>17</td>\n",
" <td>23</td>\n",
" <td>Hof</td>\n",
" <td>45173.0</td>\n",
" <td>Bayern</td>\n",
" </tr>\n",
" <tr>\n",
" <th>265</th>\n",
" <td>2020-04-24</td>\n",
" <td>09</td>\n",
" <td>09463</td>\n",
" <td>9</td>\n",
" <td>25</td>\n",
" <td>Coburg</td>\n",
" <td>40842.0</td>\n",
" <td>Bayern</td>\n",
" </tr>\n",
" <tr>\n",
" <th>264</th>\n",
" <td>2020-04-24</td>\n",
" <td>09</td>\n",
" <td>09462</td>\n",
" <td>12</td>\n",
" <td>51</td>\n",
" <td>Bayreuth</td>\n",
" <td>74048.0</td>\n",
" <td>Bayern</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279131</th>\n",
" <td>2022-03-30</td>\n",
" <td>06</td>\n",
" <td>06437</td>\n",
" <td>7</td>\n",
" <td>119</td>\n",
" <td>Odenwaldkreis</td>\n",
" <td>96754.0</td>\n",
" <td>Hessen</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279130</th>\n",
" <td>2022-03-30</td>\n",
" <td>06</td>\n",
" <td>06436</td>\n",
" <td>1</td>\n",
" <td>23</td>\n",
" <td>Main-Taunus-Kreis</td>\n",
" <td>239264.0</td>\n",
" <td>Hessen</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279129</th>\n",
" <td>2022-03-30</td>\n",
" <td>06</td>\n",
" <td>06435</td>\n",
" <td>11</td>\n",
" <td>70</td>\n",
" <td>Main-Kinzig-Kreis</td>\n",
" <td>421689.0</td>\n",
" <td>Hessen</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279127</th>\n",
" <td>2022-03-30</td>\n",
" <td>06</td>\n",
" <td>06433</td>\n",
" <td>2</td>\n",
" <td>19</td>\n",
" <td>Groß-Gerau</td>\n",
" <td>275807.0</td>\n",
" <td>Hessen</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279400</th>\n",
" <td>2022-03-30</td>\n",
" <td>16</td>\n",
" <td>16077</td>\n",
" <td>5</td>\n",
" <td>27</td>\n",
" <td>Altenburger Land</td>\n",
" <td>88356.0</td>\n",
" <td>Thüringen</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>279401 rows × 8 columns</p>\n",
"</div>"
],
"text/plain": [
" date bundesland gemeindeschluessel betten_frei betten_belegt \\\n",
"0 2020-04-24 01 01001 40 38 \n",
"267 2020-04-24 09 09471 9 9 \n",
"266 2020-04-24 09 09464 17 23 \n",
"265 2020-04-24 09 09463 9 25 \n",
"264 2020-04-24 09 09462 12 51 \n",
"... ... ... ... ... ... \n",
"279131 2022-03-30 06 06437 7 119 \n",
"279130 2022-03-30 06 06436 1 23 \n",
"279129 2022-03-30 06 06435 11 70 \n",
"279127 2022-03-30 06 06433 2 19 \n",
"279400 2022-03-30 16 16077 5 27 \n",
"\n",
" Kreis Einwohnerzahl Bundesland \n",
"0 Flensburg, Stadt 89934.0 Schleswig-Holstein \n",
"267 Bamberg 147497.0 Bayern \n",
"266 Hof 45173.0 Bayern \n",
"265 Coburg 40842.0 Bayern \n",
"264 Bayreuth 74048.0 Bayern \n",
"... ... ... ... \n",
"279131 Odenwaldkreis 96754.0 Hessen \n",
"279130 Main-Taunus-Kreis 239264.0 Hessen \n",
"279129 Main-Kinzig-Kreis 421689.0 Hessen \n",
"279127 Groß-Gerau 275807.0 Hessen \n",
"279400 Altenburger Land 88356.0 Thüringen \n",
"\n",
"[279401 rows x 8 columns]"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"timeSeries = ColumnsAdder(kreise).addKreisAndBundeslandAndEinwohnerzahlColumns(timeSeries)\n",
"timeSeries"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "356494d3",
"metadata": {},
"outputs": [],
"source": [
"kreisValues = sorted(timeSeries['Kreis'].drop_duplicates().values)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "05aa0117",
"metadata": {},
"outputs": [],
"source": [
"def getKreisOptions(kreisValues):\n",
" return [getKreisOption(kreis) for kreis in kreisValues]\n",
"\n",
"def getKreisOption(kreis):\n",
" return f'<option value=\"{kreis}\">{kreis}</option>'\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "9c38ca16",
"metadata": {},
"outputs": [],
"source": [
"kreisOptions = ['<option selected=\"\" value=\"de\">Alle Landkreise</option>'] + getKreisOptions(kreisValues)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "9eb453d0",
"metadata": {},
"outputs": [],
"source": [
"from bs4 import BeautifulSoup\n",
"\n",
"\n",
"class KreisOptionsSetter:\n",
"\n",
" def setKreisOptions(self, html, options):\n",
" soup = self._setKreisOptions(self._parse(html), self._parseOptions(options))\n",
" return str(soup)\n",
"\n",
" def _setKreisOptions(self, soup, options):\n",
" kreisSelect = soup.find(id = \"kreisSelect\")\n",
" kreisSelect.clear()\n",
" for option in options:\n",
" kreisSelect.append(option)\n",
" return soup\n",
"\n",
" def _parseOptions(self, options):\n",
" return [self._parse(option).option for option in options]\n",
"\n",
" def _parse(self, html):\n",
" return BeautifulSoup(html, 'lxml')\n"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "29b0930a",
"metadata": {},
"outputs": [],
"source": [
"import unittest"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "45072a1d",
"metadata": {},
"outputs": [],
"source": [
"class TestHelper:\n",
"\n",
" @staticmethod\n",
" def createDataFrame(index, columns, data, dtypes = {}):\n",
" return pd.DataFrame(index = index, columns = columns, data = data).astype(dtypes)\n"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "e4f8fa80",
"metadata": {},
"outputs": [],
"source": [
"class KreisOptionsSetterTest(unittest.TestCase):\n",
"\n",
" def test_setKreisOptions(self):\n",
" # Given\n",
" kreisOptionsSetter = KreisOptionsSetter()\n",
"\n",
" # When\n",
" htmlActual = kreisOptionsSetter.setKreisOptions(\n",
" html='''\n",
" <html>\n",
" <body>\n",
" <p>Test<p/>\n",
" <select id=\"kreisSelect\" name=\"kreis\">\n",
" <option selected=\"\" value=\"de\">Alle Landkreise</option>\n",
" <option value=\"Ahrweiler\">Ahrweiler</option>\n",
" <option value=\"Wiesbaden, Landeshauptstadt\">Wiesbaden, Landeshauptstadt</option>\n",
" <option value=\"Aichach-Friedberg\">Aichach-Friedberg</option>\n",
" </select>\n",
" </body>\n",
" </html>\n",
" ''',\n",
" options=[\n",
" '<option selected=\"\" value=\"de\">Alle Landkreise</option>',\n",
" '<option value=\"Ahrweiler\">Ahrweiler</option>',\n",
" '<option value=\"Aichach-Friedberg\">Aichach-Friedberg</option>'])\n",
"\n",
" # Then\n",
" assertEqualHTML(\n",
" htmlActual,\n",
" '''\n",
" <html>\n",
" <body>\n",
" <p>Test<p/>\n",
" <select id=\"kreisSelect\" name=\"kreis\">\n",
" <option selected=\"\" value=\"de\">Alle Landkreise</option>\n",
" <option value=\"Ahrweiler\">Ahrweiler</option>\n",
" <option value=\"Aichach-Friedberg\">Aichach-Friedberg</option>\n",
" </select>\n",
" </body>\n",
" </html>\n",
" ''')\n",
"\n",
"# adapted from https://stackoverflow.com/questions/8006909/pretty-print-assertequal-for-html-strings\n",
"def assertEqualHTML(string1, string2, file1='', file2=''):\n",
" u'''\n",
" Compare two unicode strings containing HTML.\n",
" A human friendly diff goes to logging.error() if they\n",
" are not equal, and an exception gets raised.\n",
" '''\n",
" from bs4 import BeautifulSoup as bs\n",
" import difflib\n",
"\n",
" def short(mystr):\n",
" max = 20\n",
" if len(mystr) > max:\n",
" return mystr[:max]\n",
" return mystr\n",
" p = []\n",
" for mystr, file in [(string1, file1), (string2, file2)]:\n",
" if not isinstance(mystr, str):\n",
" raise Exception(u'string ist not unicode: %r %s' %\n",
" (short(mystr), file))\n",
" soup = bs(mystr)\n",
" pretty = soup.prettify()\n",
" p.append(pretty)\n",
" if p[0] != p[1]:\n",
" for line in difflib.unified_diff(p[0].splitlines(), p[1].splitlines(), fromfile=file1, tofile=file2):\n",
" display(line)\n",
" display(p[0], ' != ', p[1])\n",
" raise Exception('Not equal %s %s' % (file1, file2))\n"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "403f8b7b",
"metadata": {},
"outputs": [],
"source": [
"from bs4 import BeautifulSoup\n",
"\n",
"\n",
"def saveKreisOptions(kreisOptions):\n",
" HtmlTransformerUtil().applySoupTransformerToFile(\n",
" file = \"../../docs/intensivstationen.html\",\n",
" soupTransformer =\n",
" lambda soup:\n",
" BeautifulSoup(\n",
" KreisOptionsSetter().setKreisOptions(html = str(soup), options = kreisOptions),\n",
" 'lxml'))\n"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "5dd8d864",
"metadata": {},
"outputs": [],
"source": [
"saveKreisOptions(kreisOptions)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "43c2f826",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import json\n",
"\n",
"\n",
"class IOUtils:\n",
"\n",
" def saveDictAsJson(dict, file):\n",
" IOUtils.ensurePath(file)\n",
" with open(file, 'w') as outfile:\n",
" json.dump(dict, outfile)\n",
"\n",
" @staticmethod\n",
" def ensurePath(file):\n",
" directory = os.path.dirname(file)\n",
" if not os.path.exists(directory):\n",
" os.makedirs(directory)\n"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "997a4bdb",
"metadata": {},
"outputs": [],
"source": [
"def getIntensiveCareBeds(timeSeries, kreis = None):\n",
" if kreis is not None:\n",
" return timeSeries[timeSeries['Kreis'] == kreis][['date', 'betten_belegt', 'betten_frei', 'Einwohnerzahl']]\n",
" else:\n",
" return timeSeries.groupby('date').agg(**{\n",
" 'betten_belegt': pd.NamedAgg(column = 'betten_belegt', aggfunc = 'sum'),\n",
" 'betten_frei': pd.NamedAgg(column = 'betten_frei', aggfunc = 'sum'),\n",
" 'Einwohnerzahl': pd.NamedAgg(column = 'Einwohnerzahl', aggfunc = 'sum')\n",
" }).reset_index()"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "a97f5b2b",
"metadata": {},
"outputs": [],
"source": [
"def getAndPersistIntensiveCareBeds(timeSeries, kreis = None):\n",
" intensiveCareBeds = getIntensiveCareBeds(timeSeries, kreis)\n",
" display(kreis)\n",
" _saveAsJson(intensiveCareBeds, _getFilename(kreis))\n",
" return intensiveCareBeds\n",
"\n",
"\n",
"def _saveAsJson(intensiveCareBeds, file):\n",
" IOUtils.saveDictAsJson(\n",
" {\n",
" 'population': int(intensiveCareBeds.iloc[0]['Einwohnerzahl']),\n",
" 'data': _intensiveCareBeds2Dict(intensiveCareBeds),\n",
" },\n",
" file)\n",
"\n",
"\n",
"def _intensiveCareBeds2Dict(intensiveCareBeds):\n",
" df = intensiveCareBeds[['date', 'betten_belegt', 'betten_frei']].copy()\n",
" df['date'] = df['date'].dt.strftime('%Y-%m-%d')\n",
" return df.to_dict(orient = \"records\")\n",
"\n",
"\n",
"def _getFilename(kreis):\n",
" return f'../../docs/data/intensivstationen/intensivstationen-{_getSuffix(kreis)}.json'\n",
"\n",
"\n",
"def _getSuffix(kreis):\n",
" return kreis if kreis is not None else 'de'\n"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "349edd73",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"None"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>betten_belegt</th>\n",
" <th>betten_frei</th>\n",
" <th>Einwohnerzahl</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2020-04-24</td>\n",
" <td>19237</td>\n",
" <td>12270</td>\n",
" <td>82401553.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2020-04-25</td>\n",
" <td>19100</td>\n",
" <td>12290</td>\n",
" <td>82401553.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2020-04-26</td>\n",
" <td>18617</td>\n",
" <td>12694</td>\n",
" <td>82401553.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2020-04-27</td>\n",
" <td>18803</td>\n",
" <td>12537</td>\n",
" <td>82360711.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2020-04-28</td>\n",
" <td>19345</td>\n",
" <td>12207</td>\n",
" <td>82504802.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>701</th>\n",
" <td>2022-03-26</td>\n",
" <td>20268</td>\n",
" <td>3924</td>\n",
" <td>82658396.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>702</th>\n",
" <td>2022-03-27</td>\n",
" <td>19921</td>\n",
" <td>4187</td>\n",
" <td>82658396.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>703</th>\n",
" <td>2022-03-28</td>\n",
" <td>20123</td>\n",
" <td>4263</td>\n",
" <td>82658396.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>704</th>\n",
" <td>2022-03-29</td>\n",
" <td>20656</td>\n",
" <td>3904</td>\n",
" <td>82658396.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>705</th>\n",
" <td>2022-03-30</td>\n",
" <td>20828</td>\n",
" <td>3772</td>\n",
" <td>82658396.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>706 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" date betten_belegt betten_frei Einwohnerzahl\n",
"0 2020-04-24 19237 12270 82401553.0\n",
"1 2020-04-25 19100 12290 82401553.0\n",
"2 2020-04-26 18617 12694 82401553.0\n",
"3 2020-04-27 18803 12537 82360711.0\n",
"4 2020-04-28 19345 12207 82504802.0\n",
".. ... ... ... ...\n",
"701 2022-03-26 20268 3924 82658396.0\n",
"702 2022-03-27 19921 4187 82658396.0\n",
"703 2022-03-28 20123 4263 82658396.0\n",
"704 2022-03-29 20656 3904 82658396.0\n",
"705 2022-03-30 20828 3772 82658396.0\n",
"\n",
"[706 rows x 4 columns]"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"getAndPersistIntensiveCareBeds(timeSeries)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "1b97137f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Ahrweiler'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Aichach-Friedberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Alb-Donau-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Altenburger Land'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Altenkirchen (Westerwald)'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Altmarkkreis Salzwedel'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Altötting'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Alzey-Worms'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Amberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Amberg-Sulzbach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ammerland'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Anhalt-Bitterfeld'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ansbach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Aschaffenburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Augsburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Aurich'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bad Dürkheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bad Kissingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bad Kreuznach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bad Tölz-Wolfratshausen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Baden-Baden, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bamberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Barnim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bautzen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bayreuth'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Berchtesgadener Land'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bergstraße'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Berlin, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bernkastel-Wittlich'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Biberach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bielefeld, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Birkenfeld'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bochum, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bodenseekreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bonn, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Borken'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bottrop, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Brandenburg an der Havel, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Braunschweig, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Breisgau-Hochschwarzwald'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bremen, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Bremerhaven, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Burgenlandkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Böblingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Börde'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Calw'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Celle'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Cham'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Chemnitz, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Cloppenburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Coburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Cochem-Zell'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Coesfeld'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Cottbus, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Cuxhaven'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Dachau'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Dahme-Spreewald'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Darmstadt, Wissenschaftsstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Darmstadt-Dieburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Deggendorf'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Delmenhorst, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Dessau-Roßlau, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Diepholz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Dillingen a.d.Donau'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Dingolfing-Landau'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Dithmarschen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Donau-Ries'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Donnersbergkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Dortmund, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Dresden, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Duisburg, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Düren'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Düsseldorf, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ebersberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Eichsfeld'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Eichstätt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Eifelkreis Bitburg-Prüm'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Elbe-Elster'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Emden, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Emmendingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Emsland'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ennepe-Ruhr-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Enzkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Erding'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Erfurt, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Erlangen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Erlangen-Höchstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Erzgebirgskreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Essen, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Esslingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Euskirchen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Flensburg, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Forchheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Frankenthal (Pfalz), kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Frankfurt (Oder), Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Frankfurt am Main, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Freiburg im Breisgau, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Freising'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Freudenstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Freyung-Grafenau'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Friesland'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Fulda'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Fürstenfeldbruck'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Fürth'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Garmisch-Partenkirchen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Gelsenkirchen, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Gera, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Germersheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Gießen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Gifhorn'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Goslar'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Gotha'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Grafschaft Bentheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Greiz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Groß-Gerau'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Göppingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Görlitz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Göttingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Günzburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Gütersloh'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hagen, Stadt der FernUniversität'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Halle (Saale), Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hamburg, Freie und Hansestadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hameln-Pyrmont'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hamm, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Harburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Harz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Havelland'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Haßberge'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Heidekreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Heidelberg, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Heidenheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Heilbronn'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Heilbronn, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Heinsberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Helmstedt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Herford'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Herne, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hersfeld-Rotenburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Herzogtum Lauenburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hildburghausen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hildesheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hochsauerlandkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hochtaunuskreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hof'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Hohenlohekreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Holzminden'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Höxter'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ilm-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ingolstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Jena, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Jerichower Land'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kaiserslautern'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kaiserslautern, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Karlsruhe'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Karlsruhe, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kassel'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kassel, documenta-Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kaufbeuren'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kelheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kempten (Allgäu)'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kiel, Landeshauptstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kitzingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kleve'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Koblenz, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Konstanz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Krefeld, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kronach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kulmbach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kusel'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Kyffhäuserkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Köln, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Lahn-Dill-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Landau in der Pfalz, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Landkreis Rostock'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Landsberg am Lech'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Landshut'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Leer'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Leipzig'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Leipzig, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Leverkusen, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Lichtenfels'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Limburg-Weilburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Lindau (Bodensee)'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Lippe'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ludwigsburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ludwigshafen am Rhein, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ludwigslust-Parchim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Lörrach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Lübeck, Hansestadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Lüchow-Dannenberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Lüneburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Magdeburg, Landeshauptstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Main-Kinzig-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Main-Spessart'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Main-Tauber-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Main-Taunus-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mainz, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mainz-Bingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mannheim, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mansfeld-Südharz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Marburg-Biedenkopf'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mayen-Koblenz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mecklenburgische Seenplatte'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Meißen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Memmingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Merzig-Wadern'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mettmann'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Miesbach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Miltenberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Minden-Lübbecke'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mittelsachsen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Märkisch-Oderland'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Märkischer Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mönchengladbach, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mühldorf a.Inn'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Mülheim an der Ruhr, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'München'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'München, Landeshauptstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Münster, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neckar-Odenwald-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neu-Ulm'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neuburg-Schrobenhausen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neumarkt i.d.OPf.'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neumünster, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neunkirchen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neustadt a.d.Aisch-Bad Windsheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neustadt an der Weinstraße, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Neuwied'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Nienburg (Weser)'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Nordfriesland'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Nordhausen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Nordsachsen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Nordwestmecklenburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Northeim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Nürnberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Nürnberger Land'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Oberallgäu'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Oberbergischer Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Oberhausen, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Oberhavel'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Oberspreewald-Lausitz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Odenwaldkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Oder-Spree'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Offenbach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Offenbach am Main, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Oldenburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Oldenburg (Oldenburg), Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Olpe'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ortenaukreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Osnabrück'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Osnabrück, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ostalbkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ostallgäu'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Osterholz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ostholstein'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ostprignitz-Ruppin'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Paderborn'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Passau'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Peine'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Pfaffenhofen a.d.Ilm'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Pforzheim, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Pinneberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Pirmasens, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Plön'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Potsdam, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Potsdam-Mittelmark'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Prignitz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rastatt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ravensburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Recklinghausen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Regen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Regensburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Region Hannover'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Regionalverband Saarbrücken'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rems-Murr-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Remscheid, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rendsburg-Eckernförde'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Reutlingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rhein-Erft-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rhein-Hunsrück-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rhein-Kreis Neuss'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rhein-Lahn-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rhein-Neckar-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rhein-Sieg-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rheingau-Taunus-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rheinisch-Bergischer Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rhön-Grabfeld'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rosenheim'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rostock'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rotenburg (Wümme)'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Roth'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rottal-Inn'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Rottweil'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Saale-Holzland-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Saale-Orla-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Saalekreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Saalfeld-Rudolstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Saarlouis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Saarpfalz-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Salzgitter, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Salzlandkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schaumburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schleswig-Flensburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schmalkalden-Meiningen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schwabach'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schwalm-Eder-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schwandorf'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schwarzwald-Baar-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schweinfurt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schwerin'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Schwäbisch Hall'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Segeberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Siegen-Wittgenstein'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Sigmaringen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Soest'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Solingen, Klingenstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Sonneberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Speyer, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Spree-Neiße'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'St. Wendel'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Stade'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Starnberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Steinburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Steinfurt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Stendal'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Stormarn'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Straubing'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Straubing-Bogen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Stuttgart, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Städteregion Aachen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Suhl, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Sächsische Schweiz-Osterzgebirge'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Sömmerda'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Südliche Weinstraße'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Südwestpfalz'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Teltow-Fläming'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Tirschenreuth'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Traunstein'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Trier, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Trier-Saarburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Tuttlingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Tübingen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Uckermark'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Uelzen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Ulm, Stadtkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Unna'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Unstrut-Hainich-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Unterallgäu'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Vechta'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Verden'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Viersen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Vogelsbergkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Vogtlandkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Vorpommern-Greifswald'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Vorpommern-Rügen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Vulkaneifel'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Waldeck-Frankenberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Waldshut'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Warendorf'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wartburgkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Weiden i.d.OPf.'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Weilheim-Schongau'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Weimar, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Weimarer Land'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Weißenburg-Gunzenhausen'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Werra-Meißner-Kreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wesel'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wesermarsch'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Westerwaldkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wetteraukreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wiesbaden, Landeshauptstadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wilhelmshaven, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wittenberg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wittmund'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wolfenbüttel'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wolfsburg, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Worms, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wunsiedel i.Fichtelgebirge'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Wuppertal, Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Würzburg'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Zollernalbkreis'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Zweibrücken, kreisfreie Stadt'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'Zwickau'"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"for kreis in kreisValues:\n",
" getAndPersistIntensiveCareBeds(timeSeries, kreis)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "d9d4acab",
"metadata": {},
"outputs": [],
"source": [
"class MedianOfFreeBedsByKreisTableFactory:\n",
" \n",
" def __init__(self, dataFrame):\n",
" self.dataFrame = dataFrame\n",
"\n",
" def createMedianOfFreeBedsByKreisTable(self, kreisKey):\n",
" self.dataFrame['free_beds_divided_by_all_beds_in_percent'] = self.dataFrame['betten_frei'] / (self.dataFrame['betten_frei'] + self.dataFrame['betten_belegt']) * 100\n",
" aggregated = self.dataFrame.groupby(kreisKey).agg(\n",
" median_free_beds_in_percent =\n",
" pd.NamedAgg(\n",
" column = 'free_beds_divided_by_all_beds_in_percent',\n",
" aggfunc = 'median'))\n",
" return aggregated.sort_values(by = 'median_free_beds_in_percent', ascending = False)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "a739d4d1",
"metadata": {},
"outputs": [],
"source": [
"from pandas.testing import assert_frame_equal\n",
"import statistics\n",
"\n",
"class MedianOfFreeBedsByKreisTableFactoryTest(unittest.TestCase):\n",
"\n",
" def test_createMedianOfFreeBedsByKreisTable(self):\n",
" # Given\n",
" dataFrame = TestHelper.createDataFrame(\n",
" columns = ['date', 'betten_frei', 'betten_belegt', 'Kreis'],\n",
" data = [ ['2020-04-24', 40, 38, 'Flensburg, Stadt'],\n",
" ['2020-04-24', 42, 36, 'Flensburg, Stadt'],\n",
" ['2020-04-24', 44, 34, 'Flensburg, Stadt'],\n",
" ['2020-04-24', 9, 10, 'Bamberg']],\n",
" index = [\n",
" 0,\n",
" 1,\n",
" 2,\n",
" 3])\n",
" medianOfFreeBedsByKreisTableFactory = MedianOfFreeBedsByKreisTableFactory(dataFrame)\n",
" \n",
" # When\n",
" medianOfFreeBedsByKreisTable = medianOfFreeBedsByKreisTableFactory.createMedianOfFreeBedsByKreisTable('Kreis')\n",
"\n",
" # Then\n",
" assert_frame_equal(\n",
" medianOfFreeBedsByKreisTable,\n",
" TestHelper.createDataFrame(\n",
" columns = ['median_free_beds_in_percent'],\n",
" data = [ [statistics.median([40/(40 + 38) * 100, 42/(42 + 36) * 100, 44/(44 + 34) * 100])],\n",
" [9/(9 + 10) * 100]],\n",
" index = pd.Index(\n",
" name = 'Kreis',\n",
" data = [\n",
" 'Flensburg, Stadt',\n",
" 'Bamberg'\n",
" ])),\n",
" check_dtype = False)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "af22cdc5",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"test_setKreisOptions (__main__.KreisOptionsSetterTest) ... ok\n",
"test_createMedianOfFreeBedsByKreisTable (__main__.MedianOfFreeBedsByKreisTableFactoryTest) ... ok\n",
"\n",
"----------------------------------------------------------------------\n",
"Ran 2 tests in 0.019s\n",
"\n",
"OK\n"
]
},
{
"data": {
"text/plain": [
"<unittest.main.TestProgram at 0x7f7609c09640>"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"unittest.main(argv = [''], verbosity = 2, exit = False)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "f10704f3",
"metadata": {},
"outputs": [],
"source": [
"medianOfFreeBedsByKreisTableFactory = MedianOfFreeBedsByKreisTableFactory(timeSeries)\n",
"medianOfFreeBedsByKreisTable = medianOfFreeBedsByKreisTableFactory.createMedianOfFreeBedsByKreisTable('Kreis')\n",
"medianOfFreeBedsByKreisTable.reset_index().to_json('../../docs/data/intensivstationen/medianOfFreeBedsByKreisTable.json', orient = \"records\")"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "396cb4f8",
"metadata": {},
"outputs": [],
"source": [
"def createMedianOfFreeBedsByKreisTableForChoroplethMap(medianOfFreeBedsByKreisTableFactory):\n",
" medianOfFreeBedsByKreisTable = medianOfFreeBedsByKreisTableFactory.createMedianOfFreeBedsByKreisTable('gemeindeschluessel').reset_index()\n",
" return ColumnsAdder(kreise).addKreisAndEinwohnerzahlColumns(medianOfFreeBedsByKreisTable)\n",
" \n",
"medianOfFreeBedsByKreisTable = createMedianOfFreeBedsByKreisTableForChoroplethMap(medianOfFreeBedsByKreisTableFactory)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "b4247571",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"\n",
"\n",
"class Datawrapper:\n",
"\n",
" def __init__(self, accessToken):\n",
" self.authHeader = {\"Authorization\": f\"Bearer {accessToken}\"}\n",
"\n",
" def setChartTitle(self, title):\n",
" response = requests.request(\n",
" \"PATCH\",\n",
" \"https://api.datawrapper.de/v3/charts/dYmYb\",\n",
" json={\"title\": title},\n",
" headers={\n",
" \"Accept\": \"*/*\",\n",
" \"Content-Type\": \"application/json\"\n",
" } | self.authHeader)\n",
" return json.loads(response.text)\n",
"\n",
" def uploadChartData(self, data: pd.DataFrame):\n",
" response = requests.request(\n",
" \"PUT\",\n",
" \"https://api.datawrapper.de/v3/charts/dYmYb/data\",\n",
" data=data.to_csv(\n",
" index=False,\n",
" columns=['gemeindeschluessel', 'median_free_beds_in_percent', 'Kreis']).encode(\"utf-8\"),\n",
" headers={\n",
" \"Accept\": \"*/*\",\n",
" \"Content-Type\": \"text/csv\"\n",
" } | self.authHeader)\n",
" return response.text\n",
"\n",
" def fetchChartData(self):\n",
" response = requests.request(\n",
" \"GET\",\n",
" \"https://api.datawrapper.de/v3/charts/dYmYb/data\",\n",
" headers={\n",
" \"Accept\": \"text/csv\"\n",
" } | self.authHeader)\n",
"\n",
" return response.text\n",
"\n",
" def publishChart(self):\n",
" response = requests.request(\n",
" \"POST\",\n",
" \"https://api.datawrapper.de/v3/charts/dYmYb/publish\",\n",
" headers={\n",
" \"Accept\": \"*/*\"\n",
" } | self.authHeader)\n",
" return json.loads(response.text)\n"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "d1b75357",
"metadata": {},
"outputs": [],
"source": [
"def getChartTitle(dateStart, dateEnd):\n",
" def formatDate(date):\n",
" return date.strftime(\"%d.%m.%Y\")\n",
"\n",
" return f\"Median freier Intensivbetten im Zeitraum {formatDate(dateStart)} bis {formatDate(dateEnd)}\""
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "9de2f34e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'data': {'publicId': 'dYmYb',\n",
" 'language': 'de-DE',\n",
" 'theme': 'datawrapper',\n",
" 'id': 'dYmYb',\n",
" 'type': 'd3-maps-choropleth',\n",
" 'title': 'Median freier Intensivbetten im Zeitraum 24.04.2020 bis 30.03.2022',\n",
" 'lastEditStep': 5,\n",
" 'publishedAt': '2022-03-31T06:50:23.522Z',\n",
" 'publicUrl': 'https://datawrapper.dwcdn.net/dYmYb/41/',\n",
" 'publicVersion': 41,\n",
" 'deleted': False,\n",
" 'deletedAt': None,\n",
" 'forkable': True,\n",
" 'isFork': False,\n",
" 'metadata': {'data': {'transpose': False,\n",
" 'vertical-header': True,\n",
" 'horizontal-header': True,\n",
" 'column-format': {'ags': {'type': 'text'},\n",
" 'Kreis': {'type': 'text'},\n",
" 'Einwohnerzahl': {'type': 'number',\n",
" 'number-append': '',\n",
" 'number-format': 'auto',\n",
" 'number-divisor': 0,\n",
" 'number-prepend': ''},\n",
" 'gemeindeschluessel': {'type': 'text'},\n",
" 'median_free_beds_in_percent': {'type': 'number'}},\n",
" 'upload-method': 'upload'},\n",
" 'describe': {'source-name': 'Landkreis-Daten',\n",
" 'source-url': 'https://www.intensivregister.de/#/aktuelle-lage/downloads',\n",
" 'intro': '',\n",
" 'byline': '',\n",
" 'aria-description': '',\n",
" 'number-format': '-',\n",
" 'number-divisor': 0,\n",
" 'number-append': '',\n",
" 'number-prepend': '',\n",
" 'hide-title': False},\n",
" 'visualize': {'highlighted-series': [],\n",
" 'highlighted-values': [],\n",
" 'labels': {'max': 33, 'type': 'places', 'places': [], 'enabled': False},\n",
" 'legend': {'size': 170,\n",
" 'title': '',\n",
" 'labels': 'ranges',\n",
" 'enabled': True,\n",
" 'reverse': True,\n",
" 'labelMax': 'high',\n",
" 'labelMin': 'low',\n",
" 'position': 'mt',\n",
" 'hideItems': [],\n",
" 'offsetTop': 0,\n",
" 'offsetLeft': 0,\n",
" 'interactive': True,\n",
" 'labelCenter': 'medium',\n",
" 'labelFormat': '0%',\n",
" 'orientation': 'horizontal',\n",
" 'customLabels': ['Group A', 'Group B', 'Group C']},\n",
" 'basemap': 'germany-kreise-2021',\n",
" 'sharing': {'auto': True, 'enabled': False},\n",
" 'tooltip': {'body': 'Median freier Intensivbetten: <b>{{ FORMAT(median_free_beds_in_percent, \"0.0%\") }}</b>\\n\\n',\n",
" 'title': '{{ kreis }}',\n",
" 'sticky': True,\n",
" 'enabled': True},\n",
" 'zoomable': True,\n",
" 'map-align': 'center',\n",
" 'colorscale': {'map': [],\n",
" 'mode': 'discrete',\n",
" 'stops': 'custom',\n",
" 'colors': [{'color': '#F03B20', 'position': 0},\n",
" {'color': '#FEB24C', 'position': 0.5},\n",
" {'color': '#38A800', 'position': 1}],\n",
" 'palette': 0,\n",
" 'rangeMax': '100',\n",
" 'rangeMin': '0',\n",
" 'stopCount': 3,\n",
" 'customStops': [None, '10', '25', None, 45.5, 56.1, None],\n",
" 'rangeCenter': '',\n",
" 'categoryOrder': [],\n",
" 'interpolation': 'equidistant',\n",
" 'categoryLabels': []},\n",
" 'max-height': 650,\n",
" 'map-padding': 0,\n",
" 'map-key-attr': 'ags',\n",
" 'map-type-set': True,\n",
" 'chart-type-set': True,\n",
" 'max-map-height': 650,\n",
" 'min-label-zoom': 1,\n",
" 'zoom-button-pos': 'br',\n",
" 'map-label-format': '0,0.[00]',\n",
" 'text-annotations': [],\n",
" 'hide-empty-regions': False,\n",
" 'avoid-label-overlap': True},\n",
" 'publish': {'embed-width': 600,\n",
" 'embed-height': 785,\n",
" 'blocks': {'logo': {'enabled': False},\n",
" 'embed': True,\n",
" 'download-pdf': False,\n",
" 'download-svg': False,\n",
" 'get-the-data': True,\n",
" 'download-image': True},\n",
" 'embed-codes': {'embed-method-responsive': '<iframe title=\"Median freier Intensivbetten im Zeitraum 24.04.2020 bis 30.03.2022\" aria-label=\"Karte\" id=\"datawrapper-chart-dYmYb\" src=\"https://datawrapper.dwcdn.net/dYmYb/41/\" scrolling=\"no\" frameborder=\"0\" style=\"width: 0; min-width: 100% !important; border: none;\" height=\"785\"></iframe><script type=\"text/javascript\">!function(){\"use strict\";window.addEventListener(\"message\",(function(e){if(void 0!==e.data[\"datawrapper-height\"]){var t=document.querySelectorAll(\"iframe\");for(var a in e.data[\"datawrapper-height\"])for(var r=0;r<t.length;r++){if(t[r].contentWindow===e.source)t[r].style.height=e.data[\"datawrapper-height\"][a]+\"px\"}}}))}();\\n</script>',\n",
" 'embed-method-iframe': '<iframe title=\"Median freier Intensivbetten im Zeitraum 24.04.2020 bis 30.03.2022\" aria-label=\"Karte\" id=\"datawrapper-chart-dYmYb\" src=\"https://datawrapper.dwcdn.net/dYmYb/41/\" scrolling=\"no\" frameborder=\"0\" style=\"border: none;\" width=\"600\" height=\"785\"></iframe>'},\n",
" 'chart-height': 673.13330078125},\n",
" 'annotate': {'notes': ''},\n",
" 'axes': {'keys': 'gemeindeschluessel',\n",
" 'values': 'median_free_beds_in_percent'},\n",
" 'json_error': None},\n",
" 'externalData': '',\n",
" 'keywords': '. . landkreis-daten. . . ',\n",
" 'utf8': False,\n",
" 'createdAt': '2022-03-25T16:27:58.000Z',\n",
" 'lastModifiedAt': '2022-03-31T06:50:23.522Z',\n",
" 'forkedFrom': None,\n",
" 'organizationId': None,\n",
" 'authorId': 433861,\n",
" 'folderId': None},\n",
" 'version': 41,\n",
" 'url': 'https://datawrapper.dwcdn.net/dYmYb/41/'}"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from decouple import AutoConfig\n",
"\n",
"config = AutoConfig(search_path='../..')\n",
"dataWrapper = Datawrapper(config('DATAWRAPPER_API_TOKEN'))\n",
"dataWrapper.setChartTitle(\n",
" getChartTitle(\n",
" dateStart=timeSeries['date'].min(),\n",
" dateEnd=timeSeries['date'].max()))\n",
"dataWrapper.uploadChartData(medianOfFreeBedsByKreisTable)\n",
"dataWrapper.publishChart()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0218cdb4",
"metadata": {},
"outputs": [],
"source": [
"def publishGitHubPages():\n",
" %cd /home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch-pages\n",
" ! git add -A\n",
" ! git commit -m \"updating data\"\n",
" ! git push"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5f173c2b",
"metadata": {},
"outputs": [],
"source": [
"publishGitHubPages()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}