{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3d974110-5b17-4aef-845b-d78b2bcc2327",
   "metadata": {
    "editable": false,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "<div style=\"float: right;\"><img src=\"https://www.hochschule-bochum.de/_assets/e1b7833f96a3afb11c987930cb75faa0/Images/hs-bo_logo.svg\" style=\"height:40px;\"></div>\n",
    "<div style=\"clear: both;\"></div>\n",
    "<div style='text-align: center; margin-top: 40px; margin-bottom:40px;'>\n",
    "<h1>Probeklausur 2 Wirtschaftsinformatik</h1>\n",
    "<h2>Wintersemester 2024/2025</h2>    \n",
    "</div>\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6f21e6a1-862a-4d0e-8683-92e3f0d5a511",
   "metadata": {
    "editable": false,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "# Aufgabe - Grundlagen (max. 20 Punkte)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ae920af1-ff30-41f4-a398-251b35e02248",
   "metadata": {
    "editable": false,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 1.1 Aufgabe (Codierung) \n",
    "\n",
    "Wir haben als einfache Möglichkeit zur Darstellung von Bildern die pixelweise Speicherung \n",
    "kennengelernt (*Bitmap Bilder*). Sie möchten nun ein Bild mit halbem Speicherbedarf speichern. \n",
    "\n",
    "Um welchen Faktor müssen Sie die Auflösung in Breite und Länge jeweils reduzieren?\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "raw",
   "id": "8d29cab4-659d-4adf-8b0f-feb06084cd6a",
   "metadata": {},
   "source": [
    "Der Faktor ist wurzel(1/2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ab6dbfa-daa0-4411-9445-9e2e312dbbe4",
   "metadata": {
    "editable": false,
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 1.2 Aufgabe (Speicherung von Daten) \n",
    "Sie befinden sich in dem Verzeichnis `/Users/IHRE_MATRIKELNR/Downloads` ihres Computers (wobei Sie die Matrikelnummer durch ihre eigene Matrikelnummer ersetzen). Sie möchten eine Datei aus diesem Verzeichnis im Verzeichnis `/Users/IHRE_MATRIKELNR/Dateien/hochschule` speichern?\n",
    "\n",
    "\n",
    "Mit welchem relativen Pfad können Sie den Zielpfad erreichen!\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "raw",
   "id": "6f1d993f-c573-4fdc-9091-e6802aefb254",
   "metadata": {},
   "source": [
    "../Dateien/Hochschule"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7e21f81d-d395-4e16-9f05-37e6823286d9",
   "metadata": {
    "editable": false,
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 1.3 Aufgabe (Informationssicherheit) \n",
    "\n",
    "Betrachten Sie sich das Zertifikat der Internetseite [https://ibix.fbw.hs-bochum.de](https://ibix.fbw.hs-bochum.de) (nur über VPN erreichbar). Prüfen Sie die wesentlichen Eigenschaften dieses Zertifikats und schließen Sie daraus, ob die Seite sicher besucht werden kann.\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "raw",
   "id": "a38936ee-d91a-4876-9c88-7debcbf04e86",
   "metadata": {},
   "source": [
    "Der Name im Zertifikat passt zum Servernamen, das Zertifikat ist noch nicht abgelaufen, d.h. es ist ein gültiges Zertifikat."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7028ab2b-924b-470b-987a-1baf1b22ab06",
   "metadata": {
    "editable": false,
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "# Aufgabe - grundlegende Python Funktionen (max. 20 Punkte)\n",
    "\n",
    "Sie verleihen Tontechnik und berechnen mit einer Python-Funktion die Preise für den Verleih.\n",
    "\n",
    "Die folgende Tabelle zeigt einen Überblick über ihre Aufträge und die Verleihkosten:\n",
    "\n",
    "<table><tr><th>Kunde</th><th>Personenzahl</th><th>Raumgröße</th><th>Qualität</th><th>Sonderwünsche</th><th>Preis Tontechnik</th></tr><tr><td>Meier</td><td>10020</td><td>6824</td><td>Musik</td><td></td><td>15149.82</td></tr><tr><td>Schneider</td><td>10010</td><td>1475</td><td>Basslastig</td><td>Funkstrecken</td><td>30073.8</td></tr><tr><td>Kohler</td><td>15090</td><td>9822</td><td>Musik</td><td>Funkstrecken</td><td>26342.66</td></tr><tr><td>Meyer</td><td>8640</td><td>6585</td><td>Basslastig</td><td></td><td>22406.16</td></tr><tr><td>Müller</td><td>6930</td><td>6420</td><td>Sprache</td><td></td><td>5497.59</td></tr><tr><td>Schmidt</td><td>8340</td><td>796</td><td>Sprache</td><td>Funkstrecken</td><td>7625.17</td></tr><tr><td>Neumann</td><td>1860</td><td>7891</td><td>Musik</td><td></td><td>2983.26</td></tr><tr><td>Neumann</td><td>11780</td><td>7676</td><td>Musik</td><td>Funkstrecken</td><td>20617.82</td></tr></table>\n",
    "\n",
    "Die Dimensionierung der Tontechnikanlage beruht auf der Personenzahl, die beschallt werden soll. Für je 100 Personen benötigen Sie 68 Watt Musikleistung. Die Kosten für die Musikleistung ergibt sich dann wie folgt:\n",
    "\n",
    "   - Für Qualitaet: Sprache berechnen Sie 76,30 Euro je 68 Watt Musikleistung\n",
    "   - Für  Qualitaet: Musik berechnen Sie 149,10 Euro je 68 Watt Musikleistung\n",
    "   - Für  Qualitaet: Basslastig berechnen Sie 256,90 Euro je 68 Watt Musikleistung\n",
    "\n",
    "Für die Bereitstellung der Tontechnik werden pauschal 210 Euro berechnet.\n",
    "\n",
    "Außerdem gibt es einen Aufschlag von 16 Prozent auf den Gesamtpreis, wenn Funkstrecken für die Tonübertragung verwendet werden sollen.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2093c30c-0ca2-4d82-8253-72b2ae938bec",
   "metadata": {},
   "outputs": [],
   "source": [
    "testDaten = [\n",
    "   ('Meier', 10020, 6824, 'Musik', ''),\n",
    "   ('Schneider', 10010, 1475, 'Basslastig', 'Funkstrecken'),\n",
    "   ('Kohler', 15090, 9822, 'Musik', 'Funkstrecken'),\n",
    "   ('Meyer', 8640, 6585, 'Basslastig', ''),\n",
    "   ('Müller', 6930, 6420, 'Sprache', ''),\n",
    "   ('Schmidt', 8340, 796, 'Sprache', 'Funkstrecken'),\n",
    "   ('Neumann', 1860, 7891, 'Musik', ''),\n",
    "   ('Neumann', 11780, 7676, 'Musik', 'Funkstrecken')\n",
    "]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d6e73364-8dd5-4864-8d38-b582813a65d7",
   "metadata": {
    "editable": false,
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 2.1 Aufgabe \n",
    "\n",
    "Programmieren Sie eine Funktion `berechnePreistontechnik(...)`, der Sie die Anzahl der Besucher, die Musikqualität und die Sonderwünsche übergeben. (Die Datei mit den Beispieldaten enthält die richtigen Ergebnisse.) \n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ff28e63b-aa70-4c4b-9572-914b1e31b570",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-22T08:35:28.610174Z",
     "iopub.status.busy": "2025-01-22T08:35:28.609820Z",
     "iopub.status.idle": "2025-01-22T08:35:28.615646Z",
     "shell.execute_reply": "2025-01-22T08:35:28.614864Z",
     "shell.execute_reply.started": "2025-01-22T08:35:28.610146Z"
    }
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz fuer ihre Loesung zu Aufgabe 2.1:\n",
    "def berechnePreistontechnik(besucher, qualitaet, wuensche):\n",
    "    preis = { 'Sprache': 76.3, 'Musik': 149.1, 'Basslastig': 256.9 }\n",
    "\n",
    "    basis_preis = 76.3\n",
    "    if qualitaet == 'Musik':\n",
    "        basis_preis = 149.1\n",
    "\n",
    "    if qualitaet == 'Basslastig':\n",
    "        basis_preis = 256.9\n",
    "    \n",
    "    gesamtkosten = 210 + (besucher/100) * basis_preis   # preis[qualitaet]\n",
    "\n",
    "    if wuensche == 'Funkstrecken':\n",
    "        gesamtkosten = gesamtkosten * 1.16\n",
    "    \n",
    "    return gesamtkosten"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a29273b5-4fb9-438c-97fe-b1e821fbcba1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-22T08:33:38.061317Z",
     "iopub.status.busy": "2025-01-22T08:33:38.060954Z",
     "iopub.status.idle": "2025-01-22T08:33:38.070276Z",
     "shell.execute_reply": "2025-01-22T08:33:38.069572Z",
     "shell.execute_reply.started": "2025-01-22T08:33:38.061287Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15149.82"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "berechnePreistontechnik(10020, 'Musik', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49c7d92c-163f-4bd9-b214-c1c11aeb0a09",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "ca346f9c-e484-4655-b1e9-80d56dbfa0e3",
   "metadata": {
    "editable": false,
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 2.2 Aufgabe \n",
    "\n",
    "Programmieren Sie eine Funktion `berechne_statistikwert(...)`, der Sie die\n",
    "Liste von Tupeln entsprechend der obigen Tabelle übergeben. \n",
    "\n",
    "Die Funktion berechnet mit Hilfe einer Schleife die durchschnittliche Raumgröße, \n",
    "die bei Datensätzen mit Funkstrecken beschallt werden soll.\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f00b26e6-b223-4b67-af13-18fc936247d2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-22T08:42:23.374787Z",
     "iopub.status.busy": "2025-01-22T08:42:23.374424Z",
     "iopub.status.idle": "2025-01-22T08:42:23.380124Z",
     "shell.execute_reply": "2025-01-22T08:42:23.379321Z",
     "shell.execute_reply.started": "2025-01-22T08:42:23.374757Z"
    }
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz fuer ihre Loesung zu Aufgabe 2.2:\n",
    "def berechne_statistikwert(liste):\n",
    "    anzahl = 0\n",
    "    summe = 0\n",
    "    durchschnitt = 0\n",
    "\n",
    "    for tupel in liste:\n",
    "        if tupel[4] == 'Funkstrecke':\n",
    "            anzahl = anzahl + 1\n",
    "            raumgroesse = tupel[2]\n",
    "            summe = summe + raumgroesse\n",
    "\n",
    "    if anzahl > 0:\n",
    "        durchschnitt = summe / anzahl\n",
    "        \n",
    "    return durchschnitt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbb147a9-4d7e-4ac6-9807-eef145c62c0f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a153379c-b914-45d7-928a-be1417ef7e87",
   "metadata": {
    "editable": false,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "# Aufgabe - Datenanalyse (max. 40 Punkte)\n",
    "\n",
    "\n",
    "In dieser Aufgabe geht es erneut um die Tankpreis-Daten. Die Daten zu den Preisen\n",
    "finden sich unter der URL\n",
    "[https://data.hsbo.de/tankpreise_Bochum_2020.csv](https://data.hsbo.de/tankpreise_Bochum_2020.csv). Die Datei enthält eine Liste mit Benzinpreisen an Tankstellen zu verschiedenen Zeitpunkten. Die Tankstellen werden durch eine ´station_uuid´ identifiziert.\n",
    "\n",
    "Weitere Informationen zu den Tankstellen finden Sie in einer weitere Datei, die Sie unter \n",
    "[https://data.hsbo.de/tankstellen.csv](https://data.hsbo.de/tankstellen.csv)\n",
    "finden.\n",
    "\n",
    "\n",
    "Lesen Sie die Daten mit Hilfe von Pandas in zwei DataFrames ein und verschaffen Sie \n",
    "sich einen Überblick über die Spalten und Größe der Tabellen.\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6cccceb-8930-4601-b258-6c7108bb6ded",
   "metadata": {
    "editable": false,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 3.1 Aufgabe \n",
    "\n",
    "Schreiben Sie eine Funktion `uebersicht(df)`, die den DataFrame mit den \n",
    "Tankpreisen als Parameter bekommt und ein Tupel mit \n",
    "\n",
    "  - Anzahl der unterschiedlichen Tankstellen\n",
    "  - maximaler Preis für Diesel\n",
    "  - Gesamtzahl der Preismeldungen\n",
    " \n",
    " zurückliefert.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "14f1379c-e3c3-4d1b-aeed-7b517b31f0d2",
   "metadata": {
    "editable": true,
    "execution": {
     "iopub.execute_input": "2025-01-22T08:46:23.804003Z",
     "iopub.status.busy": "2025-01-22T08:46:23.803699Z",
     "iopub.status.idle": "2025-01-22T08:46:23.807360Z",
     "shell.execute_reply": "2025-01-22T08:46:23.806583Z",
     "shell.execute_reply.started": "2025-01-22T08:46:23.803989Z"
    },
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "65dac55a-7c5e-49e1-934c-6bc9000d9df2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-22T09:06:14.437872Z",
     "iopub.status.busy": "2025-01-22T09:06:14.437538Z",
     "iopub.status.idle": "2025-01-22T09:06:15.435694Z",
     "shell.execute_reply": "2025-01-22T09:06:15.435240Z",
     "shell.execute_reply.started": "2025-01-22T09:06:14.437857Z"
    }
   },
   "outputs": [],
   "source": [
    "tankpreise = pd.read_csv('https://data.hsbo.de/tankpreise_Bochum_2020.csv')\n",
    "tankstellen = pd.read_csv('https://data.hsbo.de/tankstellen.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1cb2b1c8-5217-4199-8026-26e731168806",
   "metadata": {
    "editable": true,
    "execution": {
     "iopub.execute_input": "2025-01-22T08:46:50.856323Z",
     "iopub.status.busy": "2025-01-22T08:46:50.855954Z",
     "iopub.status.idle": "2025-01-22T08:46:50.868026Z",
     "shell.execute_reply": "2025-01-22T08:46:50.867291Z",
     "shell.execute_reply.started": "2025-01-22T08:46:50.856307Z"
    },
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "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>station_uuid</th>\n",
       "      <th>diesel</th>\n",
       "      <th>e5</th>\n",
       "      <th>e10</th>\n",
       "      <th>dieselchange</th>\n",
       "      <th>e5change</th>\n",
       "      <th>e10change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-01-01 02:03:03+01</td>\n",
       "      <td>b7dc5a11-661a-419f-8d30-d9763b2897c7</td>\n",
       "      <td>1.289</td>\n",
       "      <td>1.409</td>\n",
       "      <td>1.369</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-01-01 04:36:04+01</td>\n",
       "      <td>51d4b638-a095-1aa0-e100-80009459e03a</td>\n",
       "      <td>1.309</td>\n",
       "      <td>1.429</td>\n",
       "      <td>1.409</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-01-01 04:36:04+01</td>\n",
       "      <td>51d4b671-a095-1aa0-e100-80009459e03a</td>\n",
       "      <td>1.319</td>\n",
       "      <td>1.439</td>\n",
       "      <td>1.399</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-01-01 04:36:04+01</td>\n",
       "      <td>51d4b500-a095-1aa0-e100-80009459e03a</td>\n",
       "      <td>1.319</td>\n",
       "      <td>1.439</td>\n",
       "      <td>1.419</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-01-01 04:36:04+01</td>\n",
       "      <td>cd8b8686-d085-1ed7-a59b-163f66bf05c4</td>\n",
       "      <td>1.319</td>\n",
       "      <td>1.439</td>\n",
       "      <td>1.419</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     date                          station_uuid  diesel  \\\n",
       "0  2020-01-01 02:03:03+01  b7dc5a11-661a-419f-8d30-d9763b2897c7   1.289   \n",
       "1  2020-01-01 04:36:04+01  51d4b638-a095-1aa0-e100-80009459e03a   1.309   \n",
       "2  2020-01-01 04:36:04+01  51d4b671-a095-1aa0-e100-80009459e03a   1.319   \n",
       "3  2020-01-01 04:36:04+01  51d4b500-a095-1aa0-e100-80009459e03a   1.319   \n",
       "4  2020-01-01 04:36:04+01  cd8b8686-d085-1ed7-a59b-163f66bf05c4   1.319   \n",
       "\n",
       "      e5    e10  dieselchange  e5change  e10change  \n",
       "0  1.409  1.369             0         0          1  \n",
       "1  1.429  1.409             1         1          1  \n",
       "2  1.439  1.399             1         1          1  \n",
       "3  1.439  1.419             1         1          1  \n",
       "4  1.439  1.419             1         1          1  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tankpreise.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "4d18baa8-587a-481b-a417-a9afdcb60162",
   "metadata": {
    "editable": true,
    "execution": {
     "iopub.execute_input": "2025-01-22T08:55:57.218576Z",
     "iopub.status.busy": "2025-01-22T08:55:57.218202Z",
     "iopub.status.idle": "2025-01-22T08:55:57.223869Z",
     "shell.execute_reply": "2025-01-22T08:55:57.223085Z",
     "shell.execute_reply.started": "2025-01-22T08:55:57.218546Z"
    },
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz fuer ihre Loesung zu Aufgabe 3.1:\n",
    "def uebersicht(df):\n",
    "    anzahl_unterschiedlicher_tankstellen = df['station_uuid'].nunique()\n",
    "    anzahl_preismeldungen = df['dieselchange'].count()\n",
    "\n",
    "    max_diesel_preis = df['diesel'].max()\n",
    "    anzahl_tankstellen_marken = beide_funktionen['brand'].nunique()\n",
    "    \n",
    "    return (anzahl_unterschiedlicher_tankstellen, max_disel_preis, anzahl_preismeldungen)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "885086ca-fada-4d55-873e-ef5205a15b98",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "208f925e-64c9-4ee6-a815-0ebde6840a15",
   "metadata": {
    "editable": false,
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 3.2 Aufgabe  \n",
    "\n",
    "Schreiben Sie eine Funktion `anzahl(df,tankstellen_id)`, die den DataFrame mit den \n",
    "Preisdaten und die uuid einer Tankstelle bekommt und die Anzahl der Preismeldungen für diese Tankstelle als Ergebnis zurückliefert.\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "4835d297-23a1-42cc-bd1f-aa12c33b07cb",
   "metadata": {
    "editable": true,
    "execution": {
     "iopub.execute_input": "2025-01-22T09:04:26.221190Z",
     "iopub.status.busy": "2025-01-22T09:04:26.220809Z",
     "iopub.status.idle": "2025-01-22T09:04:26.226327Z",
     "shell.execute_reply": "2025-01-22T09:04:26.225607Z",
     "shell.execute_reply.started": "2025-01-22T09:04:26.221160Z"
    },
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz fuer ihre Loesung zu Aufgabe 3.2:\n",
    "def anzahl(df, tankstellen_id):\n",
    "    filtern_nach_tankstelle = df[df['station_uuid'] == tankstellen_id]\n",
    "    anzahl_preismeldungen = filtern_nach_tankstelle['dieselchange'].count()\n",
    "    anzahl_preismeldungen = len(filtern_nach_tankstelle)\n",
    "\n",
    "    # Falls man die Aufgabenstellung als Anzahl der AENDERUNGEN interpretiert:\n",
    "    filtern_nach_tankstelle['anzahl_aenderungen'] = filtern_nach_tankstelle['dieselchange'] + filtern_nach_tankstelle['e5change'] + filtern_nach_tankstelle['e10change']\n",
    "    anzahl_preisaenderungen = filtern_nach_tankstelle['anzahl_aenderungen'].sum()\n",
    "\n",
    "    return anzahl_preismeldungen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2045eb21-31db-42cd-a7c4-96638ed00384",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "2d050ec9-35a4-47fa-ad19-8469c9cebb66",
   "metadata": {
    "editable": false,
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 3.3 Aufgabe \n",
    "\n",
    "Schreiben Sie eine Funktion `tankstellen_nach_marke(df)`, die den DataFrame \n",
    "mit den Tankstellen als Parameter bekommt und einen DataFrame mit einer \n",
    "Spalte `brand` und einer Spalte für die Anzahl dazugehörigen Tankstellen zurückliefert. \n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "4bec133d-ea84-45cb-85a1-946cc54104ba",
   "metadata": {
    "editable": true,
    "execution": {
     "iopub.execute_input": "2025-01-22T12:25:40.551075Z",
     "iopub.status.busy": "2025-01-22T12:25:40.550716Z",
     "iopub.status.idle": "2025-01-22T12:25:40.555655Z",
     "shell.execute_reply": "2025-01-22T12:25:40.554888Z",
     "shell.execute_reply.started": "2025-01-22T12:25:40.551046Z"
    },
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz fuer ihre Loesung zu Aufgabe 3.3:\n",
    "def tankstellen_nach_marke(df):\n",
    "    verkleinert_df = df[['brand','uuid']]\n",
    "    return verkleinert_df.groupby('brand').nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "f3cd9682-8f93-474f-98f6-7443080ae2d9",
   "metadata": {
    "editable": true,
    "execution": {
     "iopub.execute_input": "2025-01-22T12:25:40.851318Z",
     "iopub.status.busy": "2025-01-22T12:25:40.851006Z",
     "iopub.status.idle": "2025-01-22T12:25:40.869719Z",
     "shell.execute_reply": "2025-01-22T12:25:40.869027Z",
     "shell.execute_reply.started": "2025-01-22T12:25:40.851292Z"
    },
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "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>uuid</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>brand</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>AVIA Xpress</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Autohof Frechen (Mundorf Tank)</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F T B</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Freie Tankstelle Hirschmann</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1A Tank</th>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>roth</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ssd GmbH</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>super wash</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tankpool24</th>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>team</th>\n",
       "      <td>79</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>899 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                 uuid\n",
       "brand                                \n",
       " AVIA Xpress                        1\n",
       " Autohof Frechen (Mundorf Tank)     1\n",
       " F T B                              1\n",
       " Freie Tankstelle Hirschmann        1\n",
       "1A Tank                             5\n",
       "...                               ...\n",
       "roth                                1\n",
       "ssd GmbH                            1\n",
       "super wash                          1\n",
       "tankpool24                          6\n",
       "team                               79\n",
       "\n",
       "[899 rows x 1 columns]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tankstellen_nach_marke(tankstellen)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bbe120d8-7c82-4def-9599-715b86c508f8",
   "metadata": {
    "editable": false,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 3.4 Aufgabe \n",
    "\n",
    "Schreiben Sie eine Funktion `preise_nach_kalenderwoche(df)`, die für die Preisdaten einen neuen DataFrame berechnet und zurückgibt, welche Dieselpreise \n",
    "in den verschiedenen Kalenderwochen durchschnittlichen galten.\n",
    "\n",
    "*Beachten Sie*: \n",
    "Um aus einen (Datetime-)Datum das die Kalenderwoche zu extrahieren, können \n",
    "Sie `dt.isocalendar().week` verwenden (genauso wie bei `dt.month` für den Monat).\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "7709be7a-350c-4844-96c3-81d5f57291e9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-22T09:13:53.678681Z",
     "iopub.status.busy": "2025-01-22T09:13:53.678363Z",
     "iopub.status.idle": "2025-01-22T09:13:53.681745Z",
     "shell.execute_reply": "2025-01-22T09:13:53.681056Z",
     "shell.execute_reply.started": "2025-01-22T09:13:53.678667Z"
    }
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz fuer ihre Loesung zu Aufgabe 3.4:\n",
    "def preise_nach_kalenderwoche(df):\n",
    "    verkleinerte_liste = df[['date','diesel']]\n",
    "    verkleinerte_liste['date'] = pd.to_datetime(verkleinerte_liste['date'], utc=True)\n",
    "    verkleinerte_liste['kalenderwoche'] = verkleinerte_liste['date'].dt.isocalendar().week\n",
    "    nur_kalenderwoche_diesel = verkleinerte_liste[['kalenderwoche','diesel']]\n",
    "    gruppierte_liste = nur_kalenderwoche_diesel.groupby('kalenderwoche').mean()\n",
    "    return gruppierte_liste"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "76544bd5-d0f8-419a-9148-9da6eacc30c9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-22T09:13:54.171178Z",
     "iopub.status.busy": "2025-01-22T09:13:54.170862Z",
     "iopub.status.idle": "2025-01-22T09:13:55.026292Z",
     "shell.execute_reply": "2025-01-22T09:13:55.025902Z",
     "shell.execute_reply.started": "2025-01-22T09:13:54.171151Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_953/4251794026.py:4: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  verkleinerte_liste['date'] = pd.to_datetime(verkleinerte_liste['date'], utc=True)\n",
      "/tmp/ipykernel_953/4251794026.py:5: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  verkleinerte_liste['kalenderwoche'] = verkleinerte_liste['date'].dt.isocalendar().week\n"
     ]
    },
    {
     "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>diesel</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>kalenderwoche</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.321682</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.315491</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.291023</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.273853</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1.243170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1.238018</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1.233762</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1.241917</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1.205290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1.201091</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1.162729</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>1.122293</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1.112065</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1.109260</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1.098156</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1.085063</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1.043801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1.028793</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>1.013699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1.017654</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1.035383</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1.047293</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>1.043405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>1.054265</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>1.078442</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1.079698</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>1.081756</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1.078639</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1.067454</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>1.075700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1.074172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>1.076426</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>1.078573</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>1.080227</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>1.065456</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>1.061559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>1.046300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>1.030291</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>1.036611</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>1.037012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>1.033463</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>1.045844</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>1.030903</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>1.019164</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>1.017231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>1.036309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>1.062909</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>1.067708</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>1.070647</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>1.090859</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>1.094641</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>1.121449</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>1.153897</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 diesel\n",
       "kalenderwoche          \n",
       "1              1.321682\n",
       "2              1.315491\n",
       "3              1.291023\n",
       "4              1.273853\n",
       "5              1.243170\n",
       "6              1.238018\n",
       "7              1.233762\n",
       "8              1.241917\n",
       "9              1.205290\n",
       "10             1.201091\n",
       "11             1.162729\n",
       "12             1.122293\n",
       "13             1.112065\n",
       "14             1.109260\n",
       "15             1.098156\n",
       "16             1.085063\n",
       "17             1.043801\n",
       "18             1.028793\n",
       "19             1.013699\n",
       "20             1.017654\n",
       "21             1.035383\n",
       "22             1.047293\n",
       "23             1.043405\n",
       "24             1.054265\n",
       "25             1.078442\n",
       "26             1.079698\n",
       "27             1.081756\n",
       "28             1.078639\n",
       "29             1.067454\n",
       "30             1.075700\n",
       "31             1.074172\n",
       "32             1.076426\n",
       "33             1.078573\n",
       "34             1.080227\n",
       "35             1.065456\n",
       "36             1.061559\n",
       "37             1.046300\n",
       "38             1.030291\n",
       "39             1.036611\n",
       "40             1.037012\n",
       "41             1.033463\n",
       "42             1.045844\n",
       "43             1.030903\n",
       "44             1.019164\n",
       "45             1.017231\n",
       "46             1.036309\n",
       "47             1.062909\n",
       "48             1.067708\n",
       "49             1.070647\n",
       "50             1.090859\n",
       "51             1.094641\n",
       "52             1.121449\n",
       "53             1.153897"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "preise_nach_kalenderwoche(tankpreise)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68a67f37-f251-42ea-9935-fe072f807cee",
   "metadata": {
    "editable": false,
    "tags": [
     "klausur"
    ]
   },
   "source": [
    "### 3.5 Aufgabe \n",
    "\n",
    "Schreiben Sie eine Funktion `preise_nach_plz(tankstellen_df, tankpreise_df)`,\n",
    "die einen DataFrame mit den durchschnittlichen Preisen für Diesel, E5 und \n",
    "E10 pro Postleitzahl berechnet.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "3334eef2-5489-40fc-9357-f5e839d032c0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-22T09:20:52.904715Z",
     "iopub.status.busy": "2025-01-22T09:20:52.904301Z",
     "iopub.status.idle": "2025-01-22T09:20:52.907263Z",
     "shell.execute_reply": "2025-01-22T09:20:52.906922Z",
     "shell.execute_reply.started": "2025-01-22T09:20:52.904698Z"
    }
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz fuer ihre Loesung zu Aufgabe 3.5:\n",
    "def preise_nach_plz(tankstellen_df, tankpreise_df):\n",
    "    verbunden = tankpreise_df.merge(tankstellen_df, left_on='station_uuid', right_on='uuid')\n",
    "    durchschnitt_gruppiert_plz = verbunden.groupby('post_code')[['diesel', 'e5', 'e10']].mean()\n",
    "    return durchschnitt_gruppiert_plz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "13534568-75bc-4294-b9ec-ff2394843d58",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-22T09:20:53.345996Z",
     "iopub.status.busy": "2025-01-22T09:20:53.345692Z",
     "iopub.status.idle": "2025-01-22T09:20:53.489713Z",
     "shell.execute_reply": "2025-01-22T09:20:53.489319Z",
     "shell.execute_reply.started": "2025-01-22T09:20:53.345970Z"
    }
   },
   "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>diesel</th>\n",
       "      <th>e5</th>\n",
       "      <th>e10</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>post_code</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>44787</th>\n",
       "      <td>1.076055</td>\n",
       "      <td>1.257486</td>\n",
       "      <td>1.220406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44789</th>\n",
       "      <td>1.105354</td>\n",
       "      <td>1.285039</td>\n",
       "      <td>1.249071</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44791</th>\n",
       "      <td>1.095637</td>\n",
       "      <td>1.276390</td>\n",
       "      <td>1.239803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44793</th>\n",
       "      <td>1.091841</td>\n",
       "      <td>1.271549</td>\n",
       "      <td>1.234035</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44795</th>\n",
       "      <td>1.104093</td>\n",
       "      <td>1.280253</td>\n",
       "      <td>1.244203</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44797</th>\n",
       "      <td>1.099091</td>\n",
       "      <td>1.276876</td>\n",
       "      <td>1.240937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44799</th>\n",
       "      <td>1.109524</td>\n",
       "      <td>1.288415</td>\n",
       "      <td>1.251704</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44803</th>\n",
       "      <td>1.092145</td>\n",
       "      <td>1.272344</td>\n",
       "      <td>1.236134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44805</th>\n",
       "      <td>1.114762</td>\n",
       "      <td>1.294354</td>\n",
       "      <td>1.258859</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44807</th>\n",
       "      <td>1.103791</td>\n",
       "      <td>1.286213</td>\n",
       "      <td>1.249808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44809</th>\n",
       "      <td>1.087649</td>\n",
       "      <td>1.269947</td>\n",
       "      <td>1.233162</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44866</th>\n",
       "      <td>1.114702</td>\n",
       "      <td>1.296657</td>\n",
       "      <td>1.263559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44867</th>\n",
       "      <td>1.087711</td>\n",
       "      <td>1.266949</td>\n",
       "      <td>1.231208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44869</th>\n",
       "      <td>1.077850</td>\n",
       "      <td>1.258900</td>\n",
       "      <td>1.225337</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44879</th>\n",
       "      <td>1.081344</td>\n",
       "      <td>1.260688</td>\n",
       "      <td>1.224956</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44892</th>\n",
       "      <td>1.092089</td>\n",
       "      <td>1.271568</td>\n",
       "      <td>1.235104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44894</th>\n",
       "      <td>1.102400</td>\n",
       "      <td>1.281909</td>\n",
       "      <td>1.245798</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             diesel        e5       e10\n",
       "post_code                              \n",
       "44787      1.076055  1.257486  1.220406\n",
       "44789      1.105354  1.285039  1.249071\n",
       "44791      1.095637  1.276390  1.239803\n",
       "44793      1.091841  1.271549  1.234035\n",
       "44795      1.104093  1.280253  1.244203\n",
       "44797      1.099091  1.276876  1.240937\n",
       "44799      1.109524  1.288415  1.251704\n",
       "44803      1.092145  1.272344  1.236134\n",
       "44805      1.114762  1.294354  1.258859\n",
       "44807      1.103791  1.286213  1.249808\n",
       "44809      1.087649  1.269947  1.233162\n",
       "44866      1.114702  1.296657  1.263559\n",
       "44867      1.087711  1.266949  1.231208\n",
       "44869      1.077850  1.258900  1.225337\n",
       "44879      1.081344  1.260688  1.224956\n",
       "44892      1.092089  1.271568  1.235104\n",
       "44894      1.102400  1.281909  1.245798"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "preise_nach_plz(tankstellen, tankpreise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b102e2e6-ed82-4d6b-ba2b-453b130b08ad",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.12.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
