{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "7a71e987-161b-4dc6-aada-865774f3bb89",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:20:22.861962Z",
     "iopub.status.busy": "2025-06-18T10:20:22.861575Z",
     "iopub.status.idle": "2025-06-18T10:20:22.866152Z",
     "shell.execute_reply": "2025-06-18T10:20:22.865306Z",
     "shell.execute_reply.started": "2025-06-18T10:20:22.861933Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "1cacd7c3-946c-4b5b-966b-bed1236be283",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:20:24.047252Z",
     "iopub.status.busy": "2025-06-18T10:20:24.046921Z",
     "iopub.status.idle": "2025-06-18T10:20:24.170709Z",
     "shell.execute_reply": "2025-06-18T10:20:24.169861Z",
     "shell.execute_reply.started": "2025-06-18T10:20:24.047211Z"
    }
   },
   "outputs": [],
   "source": [
    "bestellungen = pd.read_csv(\"https://data.hsbo.de/theater_bestellungen.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "abf14f1e-cca5-4eb8-ac4d-9160992f50d2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:20:24.840460Z",
     "iopub.status.busy": "2025-06-18T10:20:24.840187Z",
     "iopub.status.idle": "2025-06-18T10:20:24.872837Z",
     "shell.execute_reply": "2025-06-18T10:20:24.872035Z",
     "shell.execute_reply.started": "2025-06-18T10:20:24.840437Z"
    }
   },
   "outputs": [],
   "source": [
    "positionen = pd.read_csv(\"https://data.hsbo.de/theater_positionen.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "f408690f-2069-46bc-9be4-7f92b36e5090",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:20:36.307620Z",
     "iopub.status.busy": "2025-06-18T10:20:36.307240Z",
     "iopub.status.idle": "2025-06-18T10:20:36.318689Z",
     "shell.execute_reply": "2025-06-18T10:20:36.318011Z",
     "shell.execute_reply.started": "2025-06-18T10:20:36.307591Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Bestelldatum</th>\n",
       "      <th>Bestelluhrzeit</th>\n",
       "      <th>Gesamtbetrag</th>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th>Zahlungsmethoden</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:51:44</td>\n",
       "      <td>5</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:55:46</td>\n",
       "      <td>17</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10302</td>\n",
       "      <td>2024-08-07</td>\n",
       "      <td>20:29:39</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10303</td>\n",
       "      <td>2024-08-08</td>\n",
       "      <td>21:03:50</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10304</td>\n",
       "      <td>2024-08-09</td>\n",
       "      <td>13:11:27</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   BestellNr Bestelldatum Bestelluhrzeit  Gesamtbetrag Verkaufskanal  \\\n",
       "0      10300   2024-08-02       20:51:44             5   Online-Shop   \n",
       "1      10301   2024-08-02       20:55:46            17   Online-Shop   \n",
       "2      10302   2024-08-07       20:29:39            36   Online-Shop   \n",
       "3      10303   2024-08-08       21:03:50            48   Online-Shop   \n",
       "4      10304   2024-08-09       13:11:27            36   Online-Shop   \n",
       "\n",
       "  Zahlungsmethoden  \n",
       "0           PayPal  \n",
       "1           PayPal  \n",
       "2           PayPal  \n",
       "3           PayPal  \n",
       "4           PayPal  "
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bestellungen.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "f8f548aa-1f12-4037-b4ca-02babaea68d5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:21:22.763204Z",
     "iopub.status.busy": "2025-06-18T10:21:22.762824Z",
     "iopub.status.idle": "2025-06-18T10:21:22.775762Z",
     "shell.execute_reply": "2025-06-18T10:21:22.775109Z",
     "shell.execute_reply.started": "2025-06-18T10:21:22.763175Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Position</th>\n",
       "      <th>Vorstellung</th>\n",
       "      <th>Datum</th>\n",
       "      <th>Sitzbereich</th>\n",
       "      <th>Sitzplatz</th>\n",
       "      <th>Sitzreihe</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10301</td>\n",
       "      <td>2</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10302</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10302</td>\n",
       "      <td>2</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   BestellNr  Position               Vorstellung                Datum  \\\n",
       "0      10300         1  Hexenjagd, Arthur Miller  2024-09-21 19:30:00   \n",
       "1      10301         1  Hexenjagd, Arthur Miller  2024-09-21 19:30:00   \n",
       "2      10301         2  Hexenjagd, Arthur Miller  2024-09-21 19:30:00   \n",
       "3      10302         1  Hexenjagd, Arthur Miller  2024-09-27 19:30:00   \n",
       "4      10302         2  Hexenjagd, Arthur Miller  2024-09-27 19:30:00   \n",
       "\n",
       "  Sitzbereich  Sitzplatz  Sitzreihe  \n",
       "0     Tribüne        1.0        1.0  \n",
       "1     Tribüne        2.0        1.0  \n",
       "2     Tribüne        3.0        1.0  \n",
       "3     Tribüne        1.0        2.0  \n",
       "4     Tribüne        2.0        2.0  "
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positionen.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "b1c10815-ff11-4eca-ac1c-183269ef1658",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:23:59.899714Z",
     "iopub.status.busy": "2025-06-18T10:23:59.899299Z",
     "iopub.status.idle": "2025-06-18T10:23:59.905786Z",
     "shell.execute_reply": "2025-06-18T10:23:59.905126Z",
     "shell.execute_reply.started": "2025-06-18T10:23:59.899685Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#1.1.1\n",
    "positionen.Vorstellung.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "f9040f7e-def1-4a94-a208-987e509cc9bf",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:24:26.134767Z",
     "iopub.status.busy": "2025-06-18T10:24:26.134345Z",
     "iopub.status.idle": "2025-06-18T10:24:26.140675Z",
     "shell.execute_reply": "2025-06-18T10:24:26.140014Z",
     "shell.execute_reply.started": "2025-06-18T10:24:26.134737Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['Hexenjagd, Arthur Miller',\n",
       "       'Der zerbrochne Krug, Heinrich von Kleist',\n",
       "       'Drei Männer im Schnee, Erich Kästner',\n",
       "       'Die Räuber, Friedrich Schiller',\n",
       "       'Viel Lärm um nichts, William Shakespeare'], dtype=object)"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Kontrolle: welche sind das?\n",
    "positionen.Vorstellung.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "33672ff9-bdd8-469c-a625-66a3e4b6c9bc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:27:53.010299Z",
     "iopub.status.busy": "2025-06-18T10:27:53.009887Z",
     "iopub.status.idle": "2025-06-18T10:27:53.016387Z",
     "shell.execute_reply": "2025-06-18T10:27:53.015696Z",
     "shell.execute_reply.started": "2025-06-18T10:27:53.010269Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(26.76923076923077)"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#1.1.2\n",
    "# Gesamtzahl Tickets durch die Anzahl der Termine teilen\n",
    "positionen[\"Position\"].count() / positionen.Datum.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "2bdf5fcf-59c2-40ac-a978-91f609bb0d54",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:30:46.192475Z",
     "iopub.status.busy": "2025-06-18T10:30:46.192083Z",
     "iopub.status.idle": "2025-06-18T10:30:46.201877Z",
     "shell.execute_reply": "2025-06-18T10:30:46.201219Z",
     "shell.execute_reply.started": "2025-06-18T10:30:46.192445Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "BestellNr    Online-Shop\n",
       "dtype: object"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#1.1.3\n",
    "bestellungen[[\"BestellNr\", \"Verkaufskanal\"]].groupby(\"Verkaufskanal\").count().idxmax()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "c3fd443e-7484-4380-a1c8-12bbbe992203",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:30:00.226125Z",
     "iopub.status.busy": "2025-06-18T10:30:00.225738Z",
     "iopub.status.idle": "2025-06-18T10:30:00.236843Z",
     "shell.execute_reply": "2025-06-18T10:30:00.236137Z",
     "shell.execute_reply.started": "2025-06-18T10:30:00.226097Z"
    }
   },
   "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>BestellNr</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Online-Shop</th>\n",
       "      <td>229</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vorverkaufsstellen</th>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    BestellNr\n",
       "Verkaufskanal                \n",
       "Online-Shop               229\n",
       "Vorverkaufsstellen         68"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Kontrolle: die Verkaufszahlen anzeigen\n",
    "bestellungen[[\"BestellNr\", \"Verkaufskanal\"]].groupby(\"Verkaufskanal\").count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "c94f7876-4bab-42ad-bc2c-842b37a7e96b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:36:14.794242Z",
     "iopub.status.busy": "2025-06-18T10:36:14.793700Z",
     "iopub.status.idle": "2025-06-18T10:36:14.811415Z",
     "shell.execute_reply": "2025-06-18T10:36:14.810747Z",
     "shell.execute_reply.started": "2025-06-18T10:36:14.794212Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Position</th>\n",
       "      <th>Vorstellung</th>\n",
       "      <th>Datum</th>\n",
       "      <th>Sitzbereich</th>\n",
       "      <th>Sitzplatz</th>\n",
       "      <th>Sitzreihe</th>\n",
       "      <th>Wochentag</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Saturday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Saturday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10301</td>\n",
       "      <td>2</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Saturday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10302</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10302</td>\n",
       "      <td>2</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Friday</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>691</th>\n",
       "      <td>10597</td>\n",
       "      <td>4</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>9.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>692</th>\n",
       "      <td>10598</td>\n",
       "      <td>1</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>693</th>\n",
       "      <td>10598</td>\n",
       "      <td>2</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>694</th>\n",
       "      <td>10600</td>\n",
       "      <td>1</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>695</th>\n",
       "      <td>10600</td>\n",
       "      <td>2</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>696 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     BestellNr  Position                     Vorstellung               Datum  \\\n",
       "0        10300         1        Hexenjagd, Arthur Miller 2024-09-21 19:30:00   \n",
       "1        10301         1        Hexenjagd, Arthur Miller 2024-09-21 19:30:00   \n",
       "2        10301         2        Hexenjagd, Arthur Miller 2024-09-21 19:30:00   \n",
       "3        10302         1        Hexenjagd, Arthur Miller 2024-09-27 19:30:00   \n",
       "4        10302         2        Hexenjagd, Arthur Miller 2024-09-27 19:30:00   \n",
       "..         ...       ...                             ...                 ...   \n",
       "691      10597         4  Die Räuber, Friedrich Schiller 2025-02-07 19:30:00   \n",
       "692      10598         1  Die Räuber, Friedrich Schiller 2025-02-07 19:30:00   \n",
       "693      10598         2  Die Räuber, Friedrich Schiller 2025-02-07 19:30:00   \n",
       "694      10600         1  Die Räuber, Friedrich Schiller 2025-02-21 19:30:00   \n",
       "695      10600         2  Die Räuber, Friedrich Schiller 2025-02-21 19:30:00   \n",
       "\n",
       "    Sitzbereich  Sitzplatz  Sitzreihe Wochentag  \n",
       "0       Tribüne        1.0        1.0  Saturday  \n",
       "1       Tribüne        2.0        1.0  Saturday  \n",
       "2       Tribüne        3.0        1.0  Saturday  \n",
       "3       Tribüne        1.0        2.0    Friday  \n",
       "4       Tribüne        2.0        2.0    Friday  \n",
       "..          ...        ...        ...       ...  \n",
       "691     Tribüne        9.0        6.0    Friday  \n",
       "692     Tribüne        3.0        4.0    Friday  \n",
       "693     Tribüne        4.0        4.0    Friday  \n",
       "694     Tribüne        1.0        2.0    Friday  \n",
       "695     Tribüne        2.0        2.0    Friday  \n",
       "\n",
       "[696 rows x 8 columns]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#1.1.4\n",
    "positionen[\"Datum\"] = pd.to_datetime(positionen.Datum)\n",
    "positionen[\"Wochentag\"] = positionen[\"Datum\"].dt.day_name()\n",
    "positionen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "46bd66c0-f78e-40d9-9d2e-f850f672d6bb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:36:29.039285Z",
     "iopub.status.busy": "2025-06-18T10:36:29.038910Z",
     "iopub.status.idle": "2025-06-18T10:36:29.048497Z",
     "shell.execute_reply": "2025-06-18T10:36:29.047837Z",
     "shell.execute_reply.started": "2025-06-18T10:36:29.039255Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Position    Friday\n",
       "dtype: object"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positionen[[\"Wochentag\", \"Position\"]].groupby(\"Wochentag\").count().idxmax()    #0 ist Montag"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "8cd9d1c5-db99-402e-927d-e785954c5098",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:36:29.924502Z",
     "iopub.status.busy": "2025-06-18T10:36:29.924187Z",
     "iopub.status.idle": "2025-06-18T10:36:29.934032Z",
     "shell.execute_reply": "2025-06-18T10:36:29.933407Z",
     "shell.execute_reply.started": "2025-06-18T10:36:29.924475Z"
    }
   },
   "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>Position</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Wochentag</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Friday</th>\n",
       "      <td>330</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Saturday</th>\n",
       "      <td>175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sunday</th>\n",
       "      <td>102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Thursday</th>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tuesday</th>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Position\n",
       "Wochentag          \n",
       "Friday          330\n",
       "Saturday        175\n",
       "Sunday          102\n",
       "Thursday         69\n",
       "Tuesday          20"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Kontrolle\n",
    "positionen[[\"Wochentag\", \"Position\"]].groupby(\"Wochentag\").count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "92d9201f-3417-4f87-bbf5-54d1c9e49b47",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:38:27.273835Z",
     "iopub.status.busy": "2025-06-18T10:38:27.273437Z",
     "iopub.status.idle": "2025-06-18T10:38:27.279617Z",
     "shell.execute_reply": "2025-06-18T10:38:27.278979Z",
     "shell.execute_reply.started": "2025-06-18T10:38:27.273805Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.int64(696)"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#1.2.1 (Anzahl der positionen / Anzahl unterschiedlicher Bestellnummern)\n",
    "positionen.BestellNr.count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "0b4ed006-090c-4d72-aae2-417fc4de453a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:38:31.228377Z",
     "iopub.status.busy": "2025-06-18T10:38:31.228043Z",
     "iopub.status.idle": "2025-06-18T10:38:31.233846Z",
     "shell.execute_reply": "2025-06-18T10:38:31.233177Z",
     "shell.execute_reply.started": "2025-06-18T10:38:31.228349Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "297"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positionen.BestellNr.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "0ec1e98c-0de1-4df6-a718-104ea30d719c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:39:09.363097Z",
     "iopub.status.busy": "2025-06-18T10:39:09.362676Z",
     "iopub.status.idle": "2025-06-18T10:39:09.369192Z",
     "shell.execute_reply": "2025-06-18T10:39:09.368535Z",
     "shell.execute_reply.started": "2025-06-18T10:39:09.363068Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(2.3434343434343434)"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positionen.BestellNr.count() / positionen.BestellNr.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac855ffb-342e-49f2-9ed4-654819353b8c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#1.2.2 ((Anzahl der Positionen / Anzahl der unterschiedlichen Vorstellungsdatumswerte) (wenn nach dem Durchschnitt gefragt ist)\n",
    "positionen.BestellNr.count() / positionen.Datum.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "10761a20-13ff-44e2-83d5-35d441d5566e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:42:51.915557Z",
     "iopub.status.busy": "2025-06-18T10:42:51.915152Z",
     "iopub.status.idle": "2025-06-18T10:42:51.923359Z",
     "shell.execute_reply": "2025-06-18T10:42:51.922698Z",
     "shell.execute_reply.started": "2025-06-18T10:42:51.915528Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Datum\n",
       "2024-09-20 19:30:00    45\n",
       "2024-09-21 19:30:00    53\n",
       "2024-09-22 19:30:00    18\n",
       "2024-09-27 19:30:00    59\n",
       "2024-09-29 19:30:00    60\n",
       "2024-10-03 19:30:00    54\n",
       "2024-10-04 19:30:00    64\n",
       "2024-11-14 20:00:00     2\n",
       "2024-11-15 20:00:00    18\n",
       "2024-11-16 20:00:00    27\n",
       "2024-11-19 20:00:00    18\n",
       "2024-12-06 19:30:00    78\n",
       "2024-12-07 19:30:00    40\n",
       "2025-02-07 19:30:00    30\n",
       "2025-02-08 19:30:00    19\n",
       "2025-02-09 18:00:00     7\n",
       "2025-02-14 19:30:00     9\n",
       "2025-02-15 19:30:00    29\n",
       "2025-02-16 18:00:00     9\n",
       "2025-02-20 19:30:00     9\n",
       "2025-02-21 19:30:00    18\n",
       "2025-03-27 19:00:00     4\n",
       "2025-03-28 19:00:00     9\n",
       "2025-03-30 17:00:00     8\n",
       "2025-04-05 19:00:00     7\n",
       "2025-04-08 19:00:00     2\n",
       "Name: BestellNr, dtype: int64"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Alternativ (andere Interpretation der Aufgabe)\n",
    "positionen.groupby(\"Datum\").BestellNr.count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "d9971ae5-6d15-447c-b1bf-e1a7422ea066",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:44:43.699399Z",
     "iopub.status.busy": "2025-06-18T10:44:43.699010Z",
     "iopub.status.idle": "2025-06-18T10:44:43.706667Z",
     "shell.execute_reply": "2025-06-18T10:44:43.705764Z",
     "shell.execute_reply.started": "2025-06-18T10:44:43.699370Z"
    }
   },
   "outputs": [],
   "source": [
    "#1.2.3 Wochentage bestimmen, gruppieren und zählen\n",
    "bestellungen.Bestelldatum = pd.to_datetime(bestellungen.Bestelldatum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "aadf6ddf-922e-4d84-b4ca-771c279e6011",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:45:00.402965Z",
     "iopub.status.busy": "2025-06-18T10:45:00.402532Z",
     "iopub.status.idle": "2025-06-18T10:45:00.417438Z",
     "shell.execute_reply": "2025-06-18T10:45:00.416745Z",
     "shell.execute_reply.started": "2025-06-18T10:45:00.402935Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Bestelldatum</th>\n",
       "      <th>Bestelluhrzeit</th>\n",
       "      <th>Gesamtbetrag</th>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th>Zahlungsmethoden</th>\n",
       "      <th>WochentagBestellung</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:51:44</td>\n",
       "      <td>5</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:55:46</td>\n",
       "      <td>17</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10302</td>\n",
       "      <td>2024-08-07</td>\n",
       "      <td>20:29:39</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10303</td>\n",
       "      <td>2024-08-08</td>\n",
       "      <td>21:03:50</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10304</td>\n",
       "      <td>2024-08-09</td>\n",
       "      <td>13:11:27</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</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",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>292</th>\n",
       "      <td>10595</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>15:15:04</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>293</th>\n",
       "      <td>10596</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>17:55:07</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>294</th>\n",
       "      <td>10597</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>23:03:43</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>10598</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>08:33:16</td>\n",
       "      <td>24</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>10600</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>11:46:50</td>\n",
       "      <td>24</td>\n",
       "      <td>Vorverkaufsstellen</td>\n",
       "      <td>Vorverkaufsstelle</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>297 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     BestellNr Bestelldatum Bestelluhrzeit  Gesamtbetrag       Verkaufskanal  \\\n",
       "0        10300   2024-08-02       20:51:44             5         Online-Shop   \n",
       "1        10301   2024-08-02       20:55:46            17         Online-Shop   \n",
       "2        10302   2024-08-07       20:29:39            36         Online-Shop   \n",
       "3        10303   2024-08-08       21:03:50            48         Online-Shop   \n",
       "4        10304   2024-08-09       13:11:27            36         Online-Shop   \n",
       "..         ...          ...            ...           ...                 ...   \n",
       "292      10595   2024-12-09       15:15:04            48         Online-Shop   \n",
       "293      10596   2024-12-09       17:55:07            36         Online-Shop   \n",
       "294      10597   2024-12-09       23:03:43            48         Online-Shop   \n",
       "295      10598   2024-12-10       08:33:16            24         Online-Shop   \n",
       "296      10600   2024-12-10       11:46:50            24  Vorverkaufsstellen   \n",
       "\n",
       "      Zahlungsmethoden  WochentagBestellung  \n",
       "0               PayPal                    4  \n",
       "1               PayPal                    4  \n",
       "2               PayPal                    2  \n",
       "3               PayPal                    3  \n",
       "4               PayPal                    4  \n",
       "..                 ...                  ...  \n",
       "292             PayPal                    0  \n",
       "293             PayPal                    0  \n",
       "294             PayPal                    0  \n",
       "295             PayPal                    1  \n",
       "296  Vorverkaufsstelle                    1  \n",
       "\n",
       "[297 rows x 7 columns]"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#bestellungen[\"WochentagBestellung\"] = bestellungen.Bestelldatum.dt.day_name()    # 0 ist Montag :-)\n",
    "bestellungen[\"WochentagBestellung\"] = bestellungen.Bestelldatum.dt.weekday    # 0 ist Montag :-)\n",
    "bestellungen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "22bf1574-6f5b-469a-b884-d04613956fee",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:45:59.741290Z",
     "iopub.status.busy": "2025-06-18T10:45:59.740876Z",
     "iopub.status.idle": "2025-06-18T10:45:59.756373Z",
     "shell.execute_reply": "2025-06-18T10:45:59.755701Z",
     "shell.execute_reply.started": "2025-06-18T10:45:59.741260Z"
    }
   },
   "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>Position</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>117</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Position\n",
       "WochentagBestellung          \n",
       "0                         107\n",
       "1                         144\n",
       "2                          65\n",
       "3                          88\n",
       "4                         117\n",
       "5                          91\n",
       "6                          84"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = bestellungen.merge(positionen)\n",
    "df[[\"Position\", \"WochentagBestellung\"]].groupby(\"WochentagBestellung\").count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "2ddb25c7-137a-46f6-bbfa-fa7c950430d2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:46:06.272437Z",
     "iopub.status.busy": "2025-06-18T10:46:06.272056Z",
     "iopub.status.idle": "2025-06-18T10:46:06.292375Z",
     "shell.execute_reply": "2025-06-18T10:46:06.291561Z",
     "shell.execute_reply.started": "2025-06-18T10:46:06.272409Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Bestelldatum</th>\n",
       "      <th>Bestelluhrzeit</th>\n",
       "      <th>Gesamtbetrag</th>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th>Zahlungsmethoden</th>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th>Position</th>\n",
       "      <th>Vorstellung</th>\n",
       "      <th>Datum</th>\n",
       "      <th>Sitzbereich</th>\n",
       "      <th>Sitzplatz</th>\n",
       "      <th>Sitzreihe</th>\n",
       "      <th>Wochentag</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:51:44</td>\n",
       "      <td>5</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Saturday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:55:46</td>\n",
       "      <td>17</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Saturday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10301</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:55:46</td>\n",
       "      <td>17</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Saturday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10302</td>\n",
       "      <td>2024-08-07</td>\n",
       "      <td>20:29:39</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10302</td>\n",
       "      <td>2024-08-07</td>\n",
       "      <td>20:29:39</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>Hexenjagd, Arthur Miller</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Friday</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",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>691</th>\n",
       "      <td>10597</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>23:03:43</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>9.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>692</th>\n",
       "      <td>10598</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>08:33:16</td>\n",
       "      <td>24</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>693</th>\n",
       "      <td>10598</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>08:33:16</td>\n",
       "      <td>24</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>694</th>\n",
       "      <td>10600</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>11:46:50</td>\n",
       "      <td>24</td>\n",
       "      <td>Vorverkaufsstellen</td>\n",
       "      <td>Vorverkaufsstelle</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>695</th>\n",
       "      <td>10600</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>11:46:50</td>\n",
       "      <td>24</td>\n",
       "      <td>Vorverkaufsstellen</td>\n",
       "      <td>Vorverkaufsstelle</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>Die Räuber, Friedrich Schiller</td>\n",
       "      <td>2025-02-21 19:30:00</td>\n",
       "      <td>Tribüne</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Friday</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>696 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     BestellNr Bestelldatum Bestelluhrzeit  Gesamtbetrag       Verkaufskanal  \\\n",
       "0        10300   2024-08-02       20:51:44             5         Online-Shop   \n",
       "1        10301   2024-08-02       20:55:46            17         Online-Shop   \n",
       "2        10301   2024-08-02       20:55:46            17         Online-Shop   \n",
       "3        10302   2024-08-07       20:29:39            36         Online-Shop   \n",
       "4        10302   2024-08-07       20:29:39            36         Online-Shop   \n",
       "..         ...          ...            ...           ...                 ...   \n",
       "691      10597   2024-12-09       23:03:43            48         Online-Shop   \n",
       "692      10598   2024-12-10       08:33:16            24         Online-Shop   \n",
       "693      10598   2024-12-10       08:33:16            24         Online-Shop   \n",
       "694      10600   2024-12-10       11:46:50            24  Vorverkaufsstellen   \n",
       "695      10600   2024-12-10       11:46:50            24  Vorverkaufsstellen   \n",
       "\n",
       "      Zahlungsmethoden  WochentagBestellung  Position  \\\n",
       "0               PayPal                    4         1   \n",
       "1               PayPal                    4         1   \n",
       "2               PayPal                    4         2   \n",
       "3               PayPal                    2         1   \n",
       "4               PayPal                    2         2   \n",
       "..                 ...                  ...       ...   \n",
       "691             PayPal                    0         4   \n",
       "692             PayPal                    1         1   \n",
       "693             PayPal                    1         2   \n",
       "694  Vorverkaufsstelle                    1         1   \n",
       "695  Vorverkaufsstelle                    1         2   \n",
       "\n",
       "                        Vorstellung               Datum Sitzbereich  \\\n",
       "0          Hexenjagd, Arthur Miller 2024-09-21 19:30:00     Tribüne   \n",
       "1          Hexenjagd, Arthur Miller 2024-09-21 19:30:00     Tribüne   \n",
       "2          Hexenjagd, Arthur Miller 2024-09-21 19:30:00     Tribüne   \n",
       "3          Hexenjagd, Arthur Miller 2024-09-27 19:30:00     Tribüne   \n",
       "4          Hexenjagd, Arthur Miller 2024-09-27 19:30:00     Tribüne   \n",
       "..                              ...                 ...         ...   \n",
       "691  Die Räuber, Friedrich Schiller 2025-02-07 19:30:00     Tribüne   \n",
       "692  Die Räuber, Friedrich Schiller 2025-02-07 19:30:00     Tribüne   \n",
       "693  Die Räuber, Friedrich Schiller 2025-02-07 19:30:00     Tribüne   \n",
       "694  Die Räuber, Friedrich Schiller 2025-02-21 19:30:00     Tribüne   \n",
       "695  Die Räuber, Friedrich Schiller 2025-02-21 19:30:00     Tribüne   \n",
       "\n",
       "     Sitzplatz  Sitzreihe Wochentag  \n",
       "0          1.0        1.0  Saturday  \n",
       "1          2.0        1.0  Saturday  \n",
       "2          3.0        1.0  Saturday  \n",
       "3          1.0        2.0    Friday  \n",
       "4          2.0        2.0    Friday  \n",
       "..         ...        ...       ...  \n",
       "691        9.0        6.0    Friday  \n",
       "692        3.0        4.0    Friday  \n",
       "693        4.0        4.0    Friday  \n",
       "694        1.0        2.0    Friday  \n",
       "695        2.0        2.0    Friday  \n",
       "\n",
       "[696 rows x 14 columns]"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "e4e221ad-ae72-4b99-a407-0158ac8b0f64",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:47:51.727603Z",
     "iopub.status.busy": "2025-06-18T10:47:51.727182Z",
     "iopub.status.idle": "2025-06-18T10:47:51.737293Z",
     "shell.execute_reply": "2025-06-18T10:47:51.736593Z",
     "shell.execute_reply.started": "2025-06-18T10:47:51.727572Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Position    1\n",
       "dtype: int32"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[[\"Position\", \"WochentagBestellung\"]].groupby(\"WochentagBestellung\").count().idxmax()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "93631192-0495-47b5-9c7f-654cd47dcbaa",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:50:10.558788Z",
     "iopub.status.busy": "2025-06-18T10:50:10.558345Z",
     "iopub.status.idle": "2025-06-18T10:50:10.571986Z",
     "shell.execute_reply": "2025-06-18T10:50:10.571326Z",
     "shell.execute_reply.started": "2025-06-18T10:50:10.558759Z"
    }
   },
   "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></th>\n",
       "      <th>Position</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">0</th>\n",
       "      <th>Online-Shop</th>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vorverkaufsstellen</th>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>Online-Shop</th>\n",
       "      <td>106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vorverkaufsstellen</th>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>Online-Shop</th>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vorverkaufsstellen</th>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">3</th>\n",
       "      <th>Online-Shop</th>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vorverkaufsstellen</th>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">4</th>\n",
       "      <th>Online-Shop</th>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vorverkaufsstellen</th>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">5</th>\n",
       "      <th>Online-Shop</th>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vorverkaufsstellen</th>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <th>Online-Shop</th>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        Position\n",
       "WochentagBestellung Verkaufskanal               \n",
       "0                   Online-Shop               80\n",
       "                    Vorverkaufsstellen        27\n",
       "1                   Online-Shop              106\n",
       "                    Vorverkaufsstellen        38\n",
       "2                   Online-Shop               45\n",
       "                    Vorverkaufsstellen        20\n",
       "3                   Online-Shop               77\n",
       "                    Vorverkaufsstellen        11\n",
       "4                   Online-Shop               87\n",
       "                    Vorverkaufsstellen        30\n",
       "5                   Online-Shop               59\n",
       "                    Vorverkaufsstellen        32\n",
       "6                   Online-Shop               84"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#1.2.4 Gruppieren nach Wochentag und Verkaufskanal\n",
    "#df = bestellungen.merge(positionen) gerade schon gemacht\n",
    "df[[\"Position\", \"WochentagBestellung\", \"Verkaufskanal\"]].groupby([\"WochentagBestellung\", \"Verkaufskanal\"]).count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "484a204a-808a-421b-9666-88d3ca50bff1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:52:27.251905Z",
     "iopub.status.busy": "2025-06-18T10:52:27.251491Z",
     "iopub.status.idle": "2025-06-18T10:52:27.263703Z",
     "shell.execute_reply": "2025-06-18T10:52:27.263043Z",
     "shell.execute_reply.started": "2025-06-18T10:52:27.251875Z"
    }
   },
   "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>Position</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Position\n",
       "WochentagBestellung          \n",
       "0                          80\n",
       "1                         106\n",
       "2                          45\n",
       "3                          77\n",
       "4                          87\n",
       "5                          59\n",
       "6                          84"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Alternativ\n",
    "online = df[df.Verkaufskanal==\"Online-Shop\"][[\"Position\", \"WochentagBestellung\"]].groupby(\"WochentagBestellung\").count()\n",
    "online"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "98623cd7-6da5-4ad8-b3bf-93a2b880c213",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:52:39.488261Z",
     "iopub.status.busy": "2025-06-18T10:52:39.487860Z",
     "iopub.status.idle": "2025-06-18T10:52:39.499793Z",
     "shell.execute_reply": "2025-06-18T10:52:39.499115Z",
     "shell.execute_reply.started": "2025-06-18T10:52:39.488232Z"
    }
   },
   "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>Position</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Position\n",
       "WochentagBestellung          \n",
       "0                          27\n",
       "1                          38\n",
       "2                          20\n",
       "3                          11\n",
       "4                          30\n",
       "5                          32"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vvk = df[df.Verkaufskanal==\"Vorverkaufsstellen\"][[\"Position\", \"WochentagBestellung\"]].groupby(\"WochentagBestellung\").count()\n",
    "vvk"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "23f56f12-ff27-4c4a-bef2-4faf88bd2523",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:55:04.008445Z",
     "iopub.status.busy": "2025-06-18T10:55:04.008042Z",
     "iopub.status.idle": "2025-06-18T10:55:04.020277Z",
     "shell.execute_reply": "2025-06-18T10:55:04.019602Z",
     "shell.execute_reply.started": "2025-06-18T10:55:04.008415Z"
    }
   },
   "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>Position_x</th>\n",
       "      <th>Position_y</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>27.0</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>38.0</td>\n",
       "      <td>106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20.0</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11.0</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>30.0</td>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>32.0</td>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>NaN</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Position_x  Position_y\n",
       "WochentagBestellung                        \n",
       "0                          27.0          80\n",
       "1                          38.0         106\n",
       "2                          20.0          45\n",
       "3                          11.0          77\n",
       "4                          30.0          87\n",
       "5                          32.0          59\n",
       "6                           NaN          84"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vvk.merge(online, how=\"outer\", left_index=True, right_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "28a31d83-bdff-4600-900c-29e22e47585d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:57:37.094522Z",
     "iopub.status.busy": "2025-06-18T10:57:37.094154Z",
     "iopub.status.idle": "2025-06-18T10:57:37.105905Z",
     "shell.execute_reply": "2025-06-18T10:57:37.105254Z",
     "shell.execute_reply.started": "2025-06-18T10:57:37.094494Z"
    }
   },
   "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>Datum</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>BestellNr</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10300</th>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10301</th>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10302</th>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10303</th>\n",
       "      <td>2024-10-04 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10304</th>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10595</th>\n",
       "      <td>2025-03-30 17:00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10596</th>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10597</th>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10598</th>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10600</th>\n",
       "      <td>2025-02-21 19:30:00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>297 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Datum\n",
       "BestellNr                    \n",
       "10300     2024-09-21 19:30:00\n",
       "10301     2024-09-21 19:30:00\n",
       "10302     2024-09-27 19:30:00\n",
       "10303     2024-10-04 19:30:00\n",
       "10304     2024-09-27 19:30:00\n",
       "...                       ...\n",
       "10595     2025-03-30 17:00:00\n",
       "10596     2025-02-07 19:30:00\n",
       "10597     2025-02-07 19:30:00\n",
       "10598     2025-02-07 19:30:00\n",
       "10600     2025-02-21 19:30:00\n",
       "\n",
       "[297 rows x 1 columns]"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#1.2.5\n",
    "df[[\"BestellNr\", \"Datum\"]].groupby(\"BestellNr\").min()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "78706d8b-b2ca-47c3-b651-cf3d4a28bbe2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T10:59:39.491031Z",
     "iopub.status.busy": "2025-06-18T10:59:39.490631Z",
     "iopub.status.idle": "2025-06-18T10:59:39.499613Z",
     "shell.execute_reply": "2025-06-18T10:59:39.498926Z",
     "shell.execute_reply.started": "2025-06-18T10:59:39.491002Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "BestellNr\n",
       "10300   2024-09-21 19:30:00\n",
       "10301   2024-09-21 19:30:00\n",
       "10302   2024-09-27 19:30:00\n",
       "10303   2024-10-04 19:30:00\n",
       "10304   2024-09-27 19:30:00\n",
       "                ...        \n",
       "10595   2025-03-30 17:00:00\n",
       "10596   2025-02-07 19:30:00\n",
       "10597   2025-02-07 19:30:00\n",
       "10598   2025-02-07 19:30:00\n",
       "10600   2025-02-21 19:30:00\n",
       "Name: Datum, Length: 297, dtype: datetime64[ns]"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#1.2.6\n",
    "#df.Bestelldatum = pd.to_datetime(df.Bestelldatum)  # schon vorher gemacht\n",
    "\n",
    "#fruehesterVorstellungstag\n",
    "fruehesterVorstellungstag = positionen.groupby(\"BestellNr\").Datum.min()\n",
    "\n",
    "fruehesterVorstellungstag"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "aa2429d1-24a8-43bb-add4-c9107df405a1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:01:18.847686Z",
     "iopub.status.busy": "2025-06-18T11:01:18.847297Z",
     "iopub.status.idle": "2025-06-18T11:01:18.863066Z",
     "shell.execute_reply": "2025-06-18T11:01:18.862373Z",
     "shell.execute_reply.started": "2025-06-18T11:01:18.847656Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Bestelldatum</th>\n",
       "      <th>Bestelluhrzeit</th>\n",
       "      <th>Gesamtbetrag</th>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th>Zahlungsmethoden</th>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th>Datum</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:51:44</td>\n",
       "      <td>5</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:55:46</td>\n",
       "      <td>17</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10302</td>\n",
       "      <td>2024-08-07</td>\n",
       "      <td>20:29:39</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>2</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10303</td>\n",
       "      <td>2024-08-08</td>\n",
       "      <td>21:03:50</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>3</td>\n",
       "      <td>2024-10-04 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10304</td>\n",
       "      <td>2024-08-09</td>\n",
       "      <td>13:11:27</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>2024-09-27 19:30:00</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>292</th>\n",
       "      <td>10595</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>15:15:04</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>2025-03-30 17:00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>293</th>\n",
       "      <td>10596</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>17:55:07</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>294</th>\n",
       "      <td>10597</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>23:03:43</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>10598</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>08:33:16</td>\n",
       "      <td>24</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>1</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>10600</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>11:46:50</td>\n",
       "      <td>24</td>\n",
       "      <td>Vorverkaufsstellen</td>\n",
       "      <td>Vorverkaufsstelle</td>\n",
       "      <td>1</td>\n",
       "      <td>2025-02-21 19:30:00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>297 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     BestellNr Bestelldatum Bestelluhrzeit  Gesamtbetrag       Verkaufskanal  \\\n",
       "0        10300   2024-08-02       20:51:44             5         Online-Shop   \n",
       "1        10301   2024-08-02       20:55:46            17         Online-Shop   \n",
       "2        10302   2024-08-07       20:29:39            36         Online-Shop   \n",
       "3        10303   2024-08-08       21:03:50            48         Online-Shop   \n",
       "4        10304   2024-08-09       13:11:27            36         Online-Shop   \n",
       "..         ...          ...            ...           ...                 ...   \n",
       "292      10595   2024-12-09       15:15:04            48         Online-Shop   \n",
       "293      10596   2024-12-09       17:55:07            36         Online-Shop   \n",
       "294      10597   2024-12-09       23:03:43            48         Online-Shop   \n",
       "295      10598   2024-12-10       08:33:16            24         Online-Shop   \n",
       "296      10600   2024-12-10       11:46:50            24  Vorverkaufsstellen   \n",
       "\n",
       "      Zahlungsmethoden  WochentagBestellung               Datum  \n",
       "0               PayPal                    4 2024-09-21 19:30:00  \n",
       "1               PayPal                    4 2024-09-21 19:30:00  \n",
       "2               PayPal                    2 2024-09-27 19:30:00  \n",
       "3               PayPal                    3 2024-10-04 19:30:00  \n",
       "4               PayPal                    4 2024-09-27 19:30:00  \n",
       "..                 ...                  ...                 ...  \n",
       "292             PayPal                    0 2025-03-30 17:00:00  \n",
       "293             PayPal                    0 2025-02-07 19:30:00  \n",
       "294             PayPal                    0 2025-02-07 19:30:00  \n",
       "295             PayPal                    1 2025-02-07 19:30:00  \n",
       "296  Vorverkaufsstelle                    1 2025-02-21 19:30:00  \n",
       "\n",
       "[297 rows x 8 columns]"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bneu = bestellungen.merge(fruehesterVorstellungstag, right_index=True, left_on=\"BestellNr\")\n",
    "bneu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "6f6f47fb-0fd9-4096-8e0c-26964ca2fd9d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:02:49.834898Z",
     "iopub.status.busy": "2025-06-18T11:02:49.834458Z",
     "iopub.status.idle": "2025-06-18T11:02:49.850964Z",
     "shell.execute_reply": "2025-06-18T11:02:49.850284Z",
     "shell.execute_reply.started": "2025-06-18T11:02:49.834869Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Bestelldatum</th>\n",
       "      <th>Bestelluhrzeit</th>\n",
       "      <th>Gesamtbetrag</th>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th>Zahlungsmethoden</th>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th>Datum</th>\n",
       "      <th>TageVorab</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:51:44</td>\n",
       "      <td>5</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:55:46</td>\n",
       "      <td>17</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>2024-09-21 19:30:00</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10302</td>\n",
       "      <td>2024-08-07</td>\n",
       "      <td>20:29:39</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>2</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10303</td>\n",
       "      <td>2024-08-08</td>\n",
       "      <td>21:03:50</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>3</td>\n",
       "      <td>2024-10-04 19:30:00</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10304</td>\n",
       "      <td>2024-08-09</td>\n",
       "      <td>13:11:27</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>2024-09-27 19:30:00</td>\n",
       "      <td>49</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",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>292</th>\n",
       "      <td>10595</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>15:15:04</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>2025-03-30 17:00:00</td>\n",
       "      <td>111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>293</th>\n",
       "      <td>10596</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>17:55:07</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>294</th>\n",
       "      <td>10597</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>23:03:43</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>10598</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>08:33:16</td>\n",
       "      <td>24</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>1</td>\n",
       "      <td>2025-02-07 19:30:00</td>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>10600</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>11:46:50</td>\n",
       "      <td>24</td>\n",
       "      <td>Vorverkaufsstellen</td>\n",
       "      <td>Vorverkaufsstelle</td>\n",
       "      <td>1</td>\n",
       "      <td>2025-02-21 19:30:00</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>297 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     BestellNr Bestelldatum Bestelluhrzeit  Gesamtbetrag       Verkaufskanal  \\\n",
       "0        10300   2024-08-02       20:51:44             5         Online-Shop   \n",
       "1        10301   2024-08-02       20:55:46            17         Online-Shop   \n",
       "2        10302   2024-08-07       20:29:39            36         Online-Shop   \n",
       "3        10303   2024-08-08       21:03:50            48         Online-Shop   \n",
       "4        10304   2024-08-09       13:11:27            36         Online-Shop   \n",
       "..         ...          ...            ...           ...                 ...   \n",
       "292      10595   2024-12-09       15:15:04            48         Online-Shop   \n",
       "293      10596   2024-12-09       17:55:07            36         Online-Shop   \n",
       "294      10597   2024-12-09       23:03:43            48         Online-Shop   \n",
       "295      10598   2024-12-10       08:33:16            24         Online-Shop   \n",
       "296      10600   2024-12-10       11:46:50            24  Vorverkaufsstellen   \n",
       "\n",
       "      Zahlungsmethoden  WochentagBestellung               Datum  TageVorab  \n",
       "0               PayPal                    4 2024-09-21 19:30:00         50  \n",
       "1               PayPal                    4 2024-09-21 19:30:00         50  \n",
       "2               PayPal                    2 2024-09-27 19:30:00         51  \n",
       "3               PayPal                    3 2024-10-04 19:30:00         57  \n",
       "4               PayPal                    4 2024-09-27 19:30:00         49  \n",
       "..                 ...                  ...                 ...        ...  \n",
       "292             PayPal                    0 2025-03-30 17:00:00        111  \n",
       "293             PayPal                    0 2025-02-07 19:30:00         60  \n",
       "294             PayPal                    0 2025-02-07 19:30:00         60  \n",
       "295             PayPal                    1 2025-02-07 19:30:00         59  \n",
       "296  Vorverkaufsstelle                    1 2025-02-21 19:30:00         73  \n",
       "\n",
       "[297 rows x 9 columns]"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bneu[\"TageVorab\"] = (bneu.Datum - bneu.Bestelldatum).dt.days\n",
    "bneu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "f68a86a9-9ade-4b88-8e7c-970cbcf85cdd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:03:27.142212Z",
     "iopub.status.busy": "2025-06-18T11:03:27.141801Z",
     "iopub.status.idle": "2025-06-18T11:03:27.148144Z",
     "shell.execute_reply": "2025-06-18T11:03:27.147463Z",
     "shell.execute_reply.started": "2025-06-18T11:03:27.142182Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(25.73063973063973)"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bneu.TageVorab.mean()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "de3d671d-461d-42a4-84b6-8aaa64d08732",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "a551e025-f33b-4ae7-9b0f-30885017ec83",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:08:40.937305Z",
     "iopub.status.busy": "2025-06-18T11:08:40.936901Z",
     "iopub.status.idle": "2025-06-18T11:08:40.942418Z",
     "shell.execute_reply": "2025-06-18T11:08:40.941688Z",
     "shell.execute_reply.started": "2025-06-18T11:08:40.937277Z"
    }
   },
   "outputs": [],
   "source": [
    "#1.2.7\n",
    "\n",
    "def bestimmeGebuehr(art):\n",
    "    if art == \"PayPal\":\n",
    "        return 0.01\n",
    "    if art == \"Vorverkaufsstelle\":\n",
    "        return 0.05\n",
    "    if art == \"Kreditkarte\":\n",
    "        return 0.1\n",
    "    return 0 \n",
    "    \n",
    "def zahlungsGebuehr(betrag, art):    \n",
    "    prozent = bestimmeGebuehr(art)\n",
    "    return betrag * prozent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "19d9494d-0fad-4f95-a82c-d32e785a99a8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:09:01.954497Z",
     "iopub.status.busy": "2025-06-18T11:09:01.954093Z",
     "iopub.status.idle": "2025-06-18T11:09:01.959922Z",
     "shell.execute_reply": "2025-06-18T11:09:01.959246Z",
     "shell.execute_reply.started": "2025-06-18T11:09:01.954468Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "zahlungsGebuehr(100, \"PayPal\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "fd26097c-089d-48f1-8809-83dfcae4eee4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:15:24.706414Z",
     "iopub.status.busy": "2025-06-18T11:15:24.706016Z",
     "iopub.status.idle": "2025-06-18T11:15:24.710881Z",
     "shell.execute_reply": "2025-06-18T11:15:24.710124Z",
     "shell.execute_reply.started": "2025-06-18T11:15:24.706385Z"
    }
   },
   "outputs": [],
   "source": [
    "#1.2.8\n",
    "\n",
    "bestellungen[\"Gebuehr\"] = 0.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "bc7bc0a5-059d-4305-9994-d5a33e1535b3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:15:25.383429Z",
     "iopub.status.busy": "2025-06-18T11:15:25.383119Z",
     "iopub.status.idle": "2025-06-18T11:15:25.396497Z",
     "shell.execute_reply": "2025-06-18T11:15:25.395818Z",
     "shell.execute_reply.started": "2025-06-18T11:15:25.383403Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Bestelldatum</th>\n",
       "      <th>Bestelluhrzeit</th>\n",
       "      <th>Gesamtbetrag</th>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th>Zahlungsmethoden</th>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th>Gebuehr</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:51:44</td>\n",
       "      <td>5</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:55:46</td>\n",
       "      <td>17</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10302</td>\n",
       "      <td>2024-08-07</td>\n",
       "      <td>20:29:39</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10303</td>\n",
       "      <td>2024-08-08</td>\n",
       "      <td>21:03:50</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10304</td>\n",
       "      <td>2024-08-09</td>\n",
       "      <td>13:11:27</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>0</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>292</th>\n",
       "      <td>10595</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>15:15:04</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>293</th>\n",
       "      <td>10596</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>17:55:07</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>294</th>\n",
       "      <td>10597</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>23:03:43</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>10598</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>08:33:16</td>\n",
       "      <td>24</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>10600</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>11:46:50</td>\n",
       "      <td>24</td>\n",
       "      <td>Vorverkaufsstellen</td>\n",
       "      <td>Vorverkaufsstelle</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>297 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     BestellNr Bestelldatum Bestelluhrzeit  Gesamtbetrag       Verkaufskanal  \\\n",
       "0        10300   2024-08-02       20:51:44             5         Online-Shop   \n",
       "1        10301   2024-08-02       20:55:46            17         Online-Shop   \n",
       "2        10302   2024-08-07       20:29:39            36         Online-Shop   \n",
       "3        10303   2024-08-08       21:03:50            48         Online-Shop   \n",
       "4        10304   2024-08-09       13:11:27            36         Online-Shop   \n",
       "..         ...          ...            ...           ...                 ...   \n",
       "292      10595   2024-12-09       15:15:04            48         Online-Shop   \n",
       "293      10596   2024-12-09       17:55:07            36         Online-Shop   \n",
       "294      10597   2024-12-09       23:03:43            48         Online-Shop   \n",
       "295      10598   2024-12-10       08:33:16            24         Online-Shop   \n",
       "296      10600   2024-12-10       11:46:50            24  Vorverkaufsstellen   \n",
       "\n",
       "      Zahlungsmethoden  WochentagBestellung  Gebuehr  \n",
       "0               PayPal                    4        0  \n",
       "1               PayPal                    4        0  \n",
       "2               PayPal                    2        0  \n",
       "3               PayPal                    3        0  \n",
       "4               PayPal                    4        0  \n",
       "..                 ...                  ...      ...  \n",
       "292             PayPal                    0        0  \n",
       "293             PayPal                    0        0  \n",
       "294             PayPal                    0        0  \n",
       "295             PayPal                    1        0  \n",
       "296  Vorverkaufsstelle                    1        0  \n",
       "\n",
       "[297 rows x 8 columns]"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bestellungen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "49267d70-1f28-41c4-acb8-cb0137675768",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:15:42.913784Z",
     "iopub.status.busy": "2025-06-18T11:15:42.913367Z",
     "iopub.status.idle": "2025-06-18T11:15:43.005372Z",
     "shell.execute_reply": "2025-06-18T11:15:43.004739Z",
     "shell.execute_reply.started": "2025-06-18T11:15:42.913756Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_2213/742280477.py:3: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '0.05' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
      "  bestellungen.loc[i, \"Gebuehr\"] = gebuehr\n"
     ]
    }
   ],
   "source": [
    "for i, tuple in bestellungen.iterrows():\n",
    "    gebuehr = zahlungsGebuehr(tuple.Gesamtbetrag, tuple.Zahlungsmethoden)\n",
    "    bestellungen.loc[i, \"Gebuehr\"] = gebuehr "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "da281894-1b47-46d7-aadd-835677507d4a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-06-18T11:16:11.520174Z",
     "iopub.status.busy": "2025-06-18T11:16:11.519893Z",
     "iopub.status.idle": "2025-06-18T11:16:11.530452Z",
     "shell.execute_reply": "2025-06-18T11:16:11.529980Z",
     "shell.execute_reply.started": "2025-06-18T11:16:11.520154Z"
    }
   },
   "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>BestellNr</th>\n",
       "      <th>Bestelldatum</th>\n",
       "      <th>Bestelluhrzeit</th>\n",
       "      <th>Gesamtbetrag</th>\n",
       "      <th>Verkaufskanal</th>\n",
       "      <th>Zahlungsmethoden</th>\n",
       "      <th>WochentagBestellung</th>\n",
       "      <th>Gebuehr</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10300</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:51:44</td>\n",
       "      <td>5</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10301</td>\n",
       "      <td>2024-08-02</td>\n",
       "      <td>20:55:46</td>\n",
       "      <td>17</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>0.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10302</td>\n",
       "      <td>2024-08-07</td>\n",
       "      <td>20:29:39</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>2</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10303</td>\n",
       "      <td>2024-08-08</td>\n",
       "      <td>21:03:50</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>3</td>\n",
       "      <td>0.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10304</td>\n",
       "      <td>2024-08-09</td>\n",
       "      <td>13:11:27</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>4</td>\n",
       "      <td>0.36</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>292</th>\n",
       "      <td>10595</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>15:15:04</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>0.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>293</th>\n",
       "      <td>10596</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>17:55:07</td>\n",
       "      <td>36</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>294</th>\n",
       "      <td>10597</td>\n",
       "      <td>2024-12-09</td>\n",
       "      <td>23:03:43</td>\n",
       "      <td>48</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>0</td>\n",
       "      <td>0.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>10598</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>08:33:16</td>\n",
       "      <td>24</td>\n",
       "      <td>Online-Shop</td>\n",
       "      <td>PayPal</td>\n",
       "      <td>1</td>\n",
       "      <td>0.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>10600</td>\n",
       "      <td>2024-12-10</td>\n",
       "      <td>11:46:50</td>\n",
       "      <td>24</td>\n",
       "      <td>Vorverkaufsstellen</td>\n",
       "      <td>Vorverkaufsstelle</td>\n",
       "      <td>1</td>\n",
       "      <td>1.20</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>297 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     BestellNr Bestelldatum Bestelluhrzeit  Gesamtbetrag       Verkaufskanal  \\\n",
       "0        10300   2024-08-02       20:51:44             5         Online-Shop   \n",
       "1        10301   2024-08-02       20:55:46            17         Online-Shop   \n",
       "2        10302   2024-08-07       20:29:39            36         Online-Shop   \n",
       "3        10303   2024-08-08       21:03:50            48         Online-Shop   \n",
       "4        10304   2024-08-09       13:11:27            36         Online-Shop   \n",
       "..         ...          ...            ...           ...                 ...   \n",
       "292      10595   2024-12-09       15:15:04            48         Online-Shop   \n",
       "293      10596   2024-12-09       17:55:07            36         Online-Shop   \n",
       "294      10597   2024-12-09       23:03:43            48         Online-Shop   \n",
       "295      10598   2024-12-10       08:33:16            24         Online-Shop   \n",
       "296      10600   2024-12-10       11:46:50            24  Vorverkaufsstellen   \n",
       "\n",
       "      Zahlungsmethoden  WochentagBestellung  Gebuehr  \n",
       "0               PayPal                    4     0.05  \n",
       "1               PayPal                    4     0.17  \n",
       "2               PayPal                    2     0.36  \n",
       "3               PayPal                    3     0.48  \n",
       "4               PayPal                    4     0.36  \n",
       "..                 ...                  ...      ...  \n",
       "292             PayPal                    0     0.48  \n",
       "293             PayPal                    0     0.36  \n",
       "294             PayPal                    0     0.48  \n",
       "295             PayPal                    1     0.24  \n",
       "296  Vorverkaufsstelle                    1     1.20  \n",
       "\n",
       "[297 rows x 8 columns]"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bestellungen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ce682f55-7cb2-40d2-a379-70fc6d33163b",
   "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.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
