2022-10-10 11:13:41 +02:00
{
"cells": [
{
"cell_type": "markdown",
"id": "1a44722c-9586-4418-ad7f-8a3c964a9db8",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"# Daten visualiseren"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "a5292e13-c487-4e3a-8085-21d80469a734",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"outputs": [],
"source": [
"import pandas\n",
2023-04-11 13:49:33 +02:00
"d = pandas.read_csv('car.csv', sep='\\t', parse_dates=['Datum'])\n",
2022-10-10 11:13:41 +02:00
"fuel_only = d[d[\"Typ\"] == \"Benzin\"]"
]
},
{
"cell_type": "markdown",
"id": "ac401f86-f53e-470f-b80a-02a86e3e5632",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Alles auf einmal\n",
"Mittels `plot()` werden alle Zahlenspalten in einer Grafik dargestellt.\n",
"\n",
"**Hinweis:** auf https://jupyter.org/try-jupyter/lab/ wird nur dann eine Grafik angzeigt wenn man explizit `show()`aus `matplotlib.pyplot` aufruft."
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "f6af7955-e6ba-4f02-bfe0-e51f677778da",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAA21ElEQVR4nO3dd3hUZdrH8e89M2mQCBICAgEpAtIEMYIsoliQsioWXMteFHVlXUS6gigK6rJggXcRFxYVKYttARUV1CyC9A5C6CGiCQQpoYSSMjPP+8echElMSCHJJDP357piZp5T5j7HyY9nnjlFjDEopZQKDDZfF6CUUqrsaOgrpVQA0dBXSqkAoqGvlFIBRENfKaUCiMPXBRSkevXqpn79+r4uQymlKozN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2J59bhr6Sim/knAqgSlbp7D016XcWe9OXu34KhHBEb4uq9zQ0FdK+YXDZw/z8pqXWZ+8Hoc4GBEzgj7N+1Soyx6XBQ39YvC+YJpSyrf2n9zPvN3z+Drha+xiZ/gNw+neoHu5vnuVL2noK6UqpPOZ53l93et8lfAVofZQ7m10L0+2epI64XV8XVq5pqF/mRISEnjwwQd57LHHWL16NefOnWP//v2MGDGCjIwM5s6dS0hICIsXL6ZatWq+Llcpv5B4JpHBywcTfzKep1o9RZ/mfagaWtXXZVUIFT70J26YyJ6UPSW6zmurXcvIdiMLnG/v3r088sgjzJo1i61btxIXF8fWrVtJS0vjmmuuYeLEiWzdupWhQ4cyZ84chgwZUqJ1KhWIViStYNTKUdjExrQ7p9GxTkd
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"d.plot();\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "531b9a96-967c-4a20-89c4-8ddc2dd6e4d8",
"metadata": {},
"source": [
"Das ist in diesem Fall nicht besonders hilfreich weil jede Spalte eine andere Bedeutung hat.\n",
"Bei Messwerten, bei dem jede Spalte ein anderes Experiment ist könnte dies aber nützlich sein."
]
},
{
"cell_type": "markdown",
"id": "73365e97-2317-496c-8747-9514c3f385da",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Zwei Spalten als X-Y-Koordinaten darstellen"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "9279c8d3-eada-4cc1-a62f-00738cd22dde",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAskUlE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z99LRcoW+4sT0oCv9fp5HU3oLgWOoh+Fe5uepUBRJTbx/O3IyHNZv3c0tG3bRWxBGx6oOCu3O6ob2H6Yo9X3gf92/g1/7gr9rZJpJY8jzyDR+EZkGFFT1Def1bwB/DDwAXAV8wfm/Pqo8pI0gcXpc89C9m5/j9o2D9BWrGvZNFy3mlgd3TbhebeNpZopZuuh4Vl/ZDygnHDt1gldPKxNOGPGF/Bp/0DhIUWMmqHDw09RveXAXF5z2lra02vkzpzJarp+hlhXKY5Vxr7VumTGmMeR5lKaeOcA/SHXk7gHuVdV/FJGfAmtE5GrgWeCyCPOQGvYdHObA4VFGyq1Hfj/3UoBXD41w+8ZBegr17p7NhFenn7mEobHMml7iposWV6fsHtw4SEl1AjNB+dPJek5YAQhnTS/x+Q+cWtdWaumGHeluOS5ddHxTe37cRCb4VfUZ4Ayf9H3AeVHdN414hWu5UqG3KEzpKbYc+d30ezY/xx2O9j9WrlCuCFN6C9zy4C6OntLD0kXHNxReQEefefMUlsZy2rxjmV4qcnA42N6GOLBDw+vpdAYUpknjirPfCsL4WsFYuUJFqxshJ3vtONh3cHhCv03bTDLXsXomS5ANUX4aZakH7rjinZx6wrFNhcv6rbu5fu02hseqjX18Y5bquPC8ft12Vl95ZkP
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fuel_only.plot(kind=\"scatter\", x=\"km\", y=\"Preis\");\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "c50a29cb-39c3-4b3e-8e16-0c56adc09278",
"metadata": {},
"source": [
"Das sieht schon besser aus. Allerdings sind die Zahlen nicht wirklich vergleichbar. Besser wäre, den Preis / l darzustellen. Den müssen wir aber erst berechnen."
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "f996d38c-c942-4f19-89ce-65ee49405419",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"outputs": [],
"source": [
"ppl = fuel_only[\"Preis\"] / fuel_only[\"Liter\"]"
]
},
{
"cell_type": "markdown",
"id": "be50aaa8-1486-47a8-9f0c-bbdae50ef717",
"metadata": {},
"source": [
"Jetzt haben wir eine Spalte `ppl` (Preis pro l) und die Tabelle `fuel_with_ppl`.\n",
"Die Spalte `ppl` soll aber in die Tabelle eingefügt werden. Dazu benötigt sie zuerst einmal einen Namen."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "3092995f-b852-4db0-99aa-5bcf73cd0234",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"ppl_with_name = ppl.rename(\"Preis_pro_l\")"
]
},
{
"cell_type": "markdown",
"id": "db096e70-02ec-4f11-bfea-f229f72e6b89",
"metadata": {},
"source": [
"`rename()` benennt aber `ppl` nicht einfach um sondern erzeugt eine neue Spalte die den Namen enthält.\n",
"Diese kann kann mit der Tabelle vereinigt werden wobei wiederum eine neue Tabelle entsteht."
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "70eb9694-9866-42e8-b8b0-b22c6ec46377",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"fuel_with_ppl = fuel_only.join(ppl_with_name)"
]
},
{
"cell_type": "markdown",
"id": "bd233836-e76e-4aed-b1e9-3b6f7c5439ef",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"Diese drei Befehle kann man auch in einem Zusammenfassen. Damit spart man sich neue Variablennamen."
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "3df419ef-aae2-43fd-871c-d09985fad63f",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Datum</th>\n",
" <th>Typ</th>\n",
" <th>Beschreibung</th>\n",
" <th>Preis</th>\n",
" <th>km</th>\n",
" <th>Liter</th>\n",
" <th>Preis_pro_l</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2012-07-10</td>\n",
" <td>Benzin</td>\n",
" <td>ESSO</td>\n",
" <td>57.01</td>\n",
" <td>199</td>\n",
" <td>34.89</td>\n",
" <td>1.633993</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2012-07-23</td>\n",
" <td>Benzin</td>\n",
" <td>Kaufland</td>\n",
" <td>55.03</td>\n",
" <td>828</td>\n",
" <td>34.20</td>\n",
" <td>1.609064</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Datum Typ Beschreibung Preis km Liter Preis_pro_l\n",
"1 2012-07-10 Benzin ESSO 57.01 199 34.89 1.633993\n",
"3 2012-07-23 Benzin Kaufland 55.03 828 34.20 1.609064"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fuel_with_ppl = fuel_only.join((fuel_only[\"Preis\"] / fuel_only[\"Liter\"]).rename(\"Preis_pro_l\"))\n",
"fuel_with_ppl.head(2)"
]
},
{
"cell_type": "markdown",
"id": "b728a171-9484-4731-b933-628ed01f2f9c",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"Damit können wir jetzt die Treibstoffkosten in Abhängigkeit vom km-Stand darstellen."
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "4732e828-26e7-4563-826a-c1e2589c6f7b",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEGCAYAAACQO2mwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YY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gCM0sDi4HTgC7gcTNb7u7FI1s1gMKTFFeOeMpRBwDwlZ89w+IHOmlJGdv7iouX2ltSvLtjKp9cWvrmONxKq9xNZm33Vq65Zz02RE7ykd/3sNf4VnK5kOGOQFnpzW2oILg7aragmTvnl8+fGTbTTNEbDitTWPyUTpnqJyIa6WGgpkHC3R8ys+nD2PVYoNPdNwCY2Z3A2UBDBomopBmmHu58MX+mu8g+E9rTDGSyLDrlSN4++yDm3/DwkDfH4VRa5W4yaYsPUIV29mdZdMdvB9+3pMCsOPcTNwpt9Ec+nCHU1UIqX7MFzcKAdvmZM5k9ZW8mtKU586u/KNo+k9UYZDnR67Q/E/R9uOC4w+qWnkZo3XS8ma0GXgA+6e7rgCnAxsg2XcDcuJ3NbCGwEGDatGk1Tmp5CougIJjprrD3NBQXRa3e+HJZN8dKpzuM3mSGK2h4lX8McaPQRm8QfZkMWQ+KFCq5uamFVL5GDpqFT71xAe2ae9YP1ltdf+4xfOK7q8g15GtNG9efO/wK19z3T2hLx47a3EzirtPP/HAtGFwwtz6Bot5B4jfAYe6+zczOAH4IHFnJB7j7EmAJBBXXVU/hMEWLoOJu/Dm5oqjctpXcHKPBKHeB5FqKFGZVh+o/0ZKCdCqFATtjmuEmGchm2bqjb3Cu7/je5vnKublVGgTHukYMmqU6k5Y
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fuel_with_ppl.plot(kind=\"scatter\", x=\"km\", y=\"Preis_pro_l\");\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "38c63e68-eedd-485b-a247-66191d549f17",
"metadata": {},
"source": [
"Interessant ist jetz noch der Verbrauch des Fahrzeugs, d.h. wieviele Liter pro 100 km es verbraucht hat.\n",
"Dazu muss man die Differenz zwischen jeweils zwei km-Ständen berechnen.\n",
"Dies geschieht mit der Funktion `diff()` die man auf eine Spalte der Daten anwendet."
]
},
{
"cell_type": "markdown",
"id": "21350aab-508b-4305-b817-6854bc80df37",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Aufgabe\n",
"1. Was macht die Funktion `diff()` genau?\n",
"1. Bei welchen Daten kann man die noch verwenden?"
]
},
{
"cell_type": "markdown",
"id": "fd0919aa-bf37-4437-af2f-00b9a8f121b2",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Lösung\n",
"Schauen wir uns das mal genauer an. Zuerst die Daten"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "8bae2c0a-cab5-4c78-b9aa-8c065b69d152",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1 199\n",
"3 828\n",
"4 1444\n",
"6 2061\n",
"7 2710\n",
"Name: km, dtype: int64"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fuel_with_ppl[\"km\"].head(5)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "bd5eec5b-d958-428a-a164-eab324e9930d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1 NaN\n",
"3 629.0\n",
"4 616.0\n",
"6 617.0\n",
"7 649.0\n",
"Name: km, dtype: float64"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fuel_with_ppl[\"km\"].diff().head(5)"
]
},
{
"cell_type": "markdown",
"id": "31f246d4-bead-4393-a478-dd53e2719e86",
"metadata": {},
"source": [
"`diff()` berechnet die Differnz von zwei aufeinanderfolgenden Zeilen.\n",
"Den Abstand kann man aber auch selbst festlegen. Möchte man die Differenz von jeweils den übernächsten Zeilen muss man den Parameter `periods` verwenden."
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "785605be-c477-4397-a7ac-bba042e94984",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1 NaN\n",
"3 NaN\n",
"4 1245.0\n",
"6 1233.0\n",
"7 1266.0\n",
"Name: km, dtype: float64"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fuel_with_ppl[\"km\"].diff(periods=2).head(5)"
]
},
{
"cell_type": "markdown",
"id": "b322a18f-8d5b-44a1-b7a3-02daae8caff7",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Weiter mit der Verbrauchsberechung\n",
"Wir erzeugen jetzt eine neue **Series** in unserem **Data Frame** die gefahrenen km zwischen zwei Tankstopps enthält.\n",
"Mit der Funktion `diff()` geht das ohne Umwege:"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "b2173099-01c9-47d4-ba6d-177654600e51",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Datum</th>\n",
" <th>Typ</th>\n",
" <th>Beschreibung</th>\n",
" <th>Preis</th>\n",
" <th>km</th>\n",
" <th>Liter</th>\n",
" <th>Preis_pro_l</th>\n",
" <th>km_driven</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2012-07-10</td>\n",
" <td>Benzin</td>\n",
" <td>ESSO</td>\n",
" <td>57.01</td>\n",
" <td>199</td>\n",
" <td>34.89</td>\n",
" <td>1.633993</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2012-07-23</td>\n",
" <td>Benzin</td>\n",
" <td>Kaufland</td>\n",
" <td>55.03</td>\n",
" <td>828</td>\n",
" <td>34.20</td>\n",
" <td>1.609064</td>\n",
" <td>629.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Datum Typ Beschreibung Preis km Liter Preis_pro_l km_driven\n",
"1 2012-07-10 Benzin ESSO 57.01 199 34.89 1.633993 NaN\n",
"3 2012-07-23 Benzin Kaufland 55.03 828 34.20 1.609064 629.0"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fuel_with_ppl[\"km_driven\"] = fuel_with_ppl[\"km\"].diff()\n",
"fuel_with_ppl.head(2)"
]
},
{
"cell_type": "markdown",
"id": "15ad8aed-e928-46dc-aa6e-25ced6032236",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"Nun können wir den Verbrauch berechnen ..."
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "346095e8-ebeb-434c-81cd-ffa968176a74",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Datum</th>\n",
" <th>Typ</th>\n",
" <th>Beschreibung</th>\n",
" <th>Preis</th>\n",
" <th>km</th>\n",
" <th>Liter</th>\n",
" <th>Preis_pro_l</th>\n",
" <th>km_driven</th>\n",
" <th>l/100km</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2012-07-10</td>\n",
" <td>Benzin</td>\n",
" <td>ESSO</td>\n",
" <td>57.01</td>\n",
" <td>199</td>\n",
" <td>34.89</td>\n",
" <td>1.633993</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2012-07-23</td>\n",
" <td>Benzin</td>\n",
" <td>Kaufland</td>\n",
" <td>55.03</td>\n",
" <td>828</td>\n",
" <td>34.20</td>\n",
" <td>1.609064</td>\n",
" <td>629.0</td>\n",
" <td>5.437202</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Datum Typ Beschreibung Preis km Liter Preis_pro_l km_driven \\\n",
"1 2012-07-10 Benzin ESSO 57.01 199 34.89 1.633993 NaN \n",
"3 2012-07-23 Benzin Kaufland 55.03 828 34.20 1.609064 629.0 \n",
"\n",
" l/100km \n",
"1 NaN \n",
"3 5.437202 "
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fuel_all = fuel_with_ppl.join((fuel_with_ppl[\"Liter\"] * 100 / fuel_with_ppl[\"km_driven\"]).rename(\"l/100km\"))\n",
"fuel_all.head(2)"
]
},
{
"cell_type": "markdown",
"id": "17d09559-c563-43ba-8e0b-52c993bb36b1",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"... und den Verbrauch in der Grafik darstellen.\n",
"Dabei ändern wir gleich noch ein paar Parameter um zu zeigen, was es alles so für Möglichkeiten gibt."
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "a9da9245-86f4-4cdb-9dce-3129bb204dc1",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2AAAAEMCAYAAACiO9WsAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAACEFUlEQVR4nO3ddXjb19XA8e8VmJkChiQONszQYCFl3Loy0zrqto6527oO367clVdeYV2ZIW0aZmY0xcwkWbrvHz9JkW3Jli3JlPN5nj5NZFm+vhH8zj3nnqu01gghhBBCCCGECD9Tbw9ACCGEEEIIIU4UEoAJIYQQQgghRA+RAEwIIYQQQggheogEYEIIIYQQQgjRQyQAE0IIIYQQQogeIgGYEEIIIYQ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MISWIQgghuq4rmapwOHjwINnZ2URERHR4v8zMTPLy8jx/z8/PJzMzk8zMTJYtW9bqdnc5o8ViYcaMGXz44YcsXrzYc5/IyEjPn00mk+fvJpOJlpaWoH8nyYAJIcQAZjEbAZhNAjAhhBD90Pvvv89ZZ53V6f0uuOACnn32WbTWrF69msTERIYMGcKZZ57JRx99RGVlJZWVlXz00UeceeaZgNE+/qmnnmL37t389a9/Dfev4iEBmBBCDGBm1x4wu+wBE0II0Q998MEHrQKw+++/n6ysLPLz85k8eTI333wzAOeccw65ubmMGjWKW265hYcffhiAlJQUfvOb3zBr1ixmzZrFb3/7W1JSUjyPZzabeemll/jss8883xNuSuvQfyjPnDlTr1+/PuSPK4QQomv
"text/plain": [
"<Figure size 1080x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fuel_all.plot(x=\"Datum\", y=\"l/100km\", figsize=(15,4), title=\"Verbrauch meines Autos\");\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "49454f16-873e-4802-9535-ad331f698742",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Box-and-Whisker-Plots\n",
"Auf einen Blick sehen, wie die Daten verteilt sind.\n",
"Wer erinnert sich noch an `describe()`?"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "95c4dddf-de31-425b-9bee-7221a0c9b7d5",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAD5CAYAAADSiMnIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYG0lEQVR4nO3df5TV9X3n8edrBgWEKqic0YL0kg1JI2NjZKKk2dMa7RlBe4rbGhubIyTLhsaoSdvdTSelZ2mT2mK7u0kkiV1XSSCrqLU5lQYSQgCTtieoQ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q3CQzM+tVdUhI+k3ghYjYPIj9qUpE3BYRbRHRNmnSpEZ3x8xsxBhVw7wfBH5L0uXAGOBU4MvABEmj0tnCFGBXar8LOAfoljQKOA14sVDvVZwnVzczszqo+kwiIj4XEVMiokT5xvOGiPgosBG4KjWbD9yfhlelcdL0DRERqf6R9PTTNGA68BDwMDA9PS11clrHqmr7a2ZmA1fLmUTOHwN3S/oL4BHgjlS/A/impC5gD+WdPhHxhKR7gSeBg8D1EfEWgKQbgLVAM7AsIp4Ygv6amVnGoIRERDwAPJCGt1N+Mqlvm9eBD2fmvwm4qUJ9DbBmMPpoZmYD529cm5lZlkPCzMyyHBJmZpblkDAzsyyHhJmZZTkkzMwsyyFhZmZZDgkzM8tySJiZWZZDwszMshwSZmaW5ZAwM7Msh4SZmWU5JMzMLMshYWZmWQ4JMzPLckiYmVnWUPz5UhumSh2r67Ke08aeVJf1mNnQc0icIHYsuaKq+Uodq6ue18yOf77cZGZmWQ4JMzPLckiYmVmWQ8LMzLIcEmZmluWQMDOzLIeEmZllOSTMzCzLIWFmZllVh4SkcyR
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fuel_all.plot(kind=\"box\");\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "117cde42-698c-4d2d-841d-816772f6a422",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"Wenn sich die Werte in den Spalten voneinander unterscheiden ist es besser, wenn man die Daten einzeln visualisert:"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "395dd8c4-5c88-4bcf-b77f-06db4f8f92ab",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2cAAAD5CAYAAACjz03LAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWX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s/02depUbr31VubNm8fmzZuZN28et956K1OnTk07tHHLa87Myiwi9jppOyKupVhqf7BjK4GV5YjLzMzMxrd7772XuXPnsnr1ao444ggymQxz587llltuSTu0ccvJmZmZmZnZOLR9+3aWLl3KwQcfvLtt69at3HjjjSlGNb45Oatyh2QW8Z7liyr4eQCVqw5pZmZmZumYOHEiS5Ys4fOf//zutiVLljBx4sQUoxrfnJxVuVcLi11K38zMzMwOuIsvvpiFCxcCsGDBApYsWcLChQtZsGDBMGdauTg5MzMzMzMbhzo7OwH40pe+xBe+8AUmTpzIggULdrdb5blao5mZ1SRJh0m6RdKvJBUkfUDSEZLukvRU8vPwpK8kfVvSOkmPSTox7fjNzCqhs7OTbdu2ERFs27bNiVnKnJyZmVmtugb4eUS8GziB4iMpFgGrIuJYYFWyD3AWcGzymg9cV/lwzcxsvHNyZmZmNUfSocCHgC6AiNgREZuBc4HlSbflwJxk+1zghuQZg/cDh0maUtGgzcxs3POaMzMzKlsZ1VVRK+IYYBPwPUknAA8BlwJHRcTzSZ/fAkcl21OB50rO35C0PY+ZmVmFODkzM6OylVFdFbUiJgAnAu0R8YCka/jjFEYAIiIkxb68qaT5FKc9Mn369AMVq5mZGeBpjWZmVps2ABsi4oFk/xaKydoL/dMVk58
"text/plain": [
"<Figure size 1080x288 with 4 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fuel_all[[\"Liter\", \"Preis_pro_l\", \"km_driven\", \"l/100km\"]].plot(kind=\"box\", subplots=True, figsize=(15,4));\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "215661fd-30c1-4fa3-98e4-fbbd991f0402",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Bar-Charts"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "7f8176ab-6239-49e3-bf03-831448411301",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAEjCAYAAADQe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A0gRJl0v6iaQHJB0kaXdJqyQ9VJ4nlnUl6RxJvZLukXRAw+ssKOs/JGlBq28qIiKa0+qewVeBa2y/C/ht4AHgVOA629OB68o8wGHA9PJYBJwHIGl3YDFwIDALWNwfIBERMTZGHAaSdgM+AFwAYPsF208B84FlZbVlwJFlej5wkSs3AxMk7QkcCqyyvd72BmAVMG+kdUVERPNa2TOYBvQBF0q6U9L5kt4I7GH78bLOE8AeZXoy8FjD9mtL21DtryJpkaQeST19fX0tlB4REY1aCYPxwAHAebb3B55lc5cQALYNuIWf8Qq2l9ieaXtmV1fXaL1sRETHayUM1gJrbd9S5i+nCoefle4fyvOTZfk6YGrD9lNK21DtERExRkYcBrafAB6TtHdpmgPcD6wE+kcELQBWlOmVwHFlVNFsYGPpTroWmCtpYjlwPLe0RUTEGBnf4vafBi6WtAOwBjieKmCWS1oIPAp8tKx7FXA40As8V9bF9npJZwC3lfVOt72+xboiIqIJLYWB7buAmYMsmjPIugZOHOJ1lgJLW6klIiJGLmcgR0REwiAiIhIGERFBwiAiIkgYREQECYOIiCBhEBERJAwiIoKEQUREkDCIiAgSBhERQcIgIiJIGEREBAmDiIggYRARESQMIiKChEFERJAwiIgIEgYREUHCICIiGIUwkDRO0p2S/rHMT5N0i6ReSZdJ2qG0v6HM95bl3Q2vcVppf1DSoa3WFBERzRmNPYPPAA8
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"d.groupby(\"Typ\")[\"Preis\"].sum().plot(kind=\"bar\");\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "7d3bdb98-87cb-4990-9038-1f26a9bc49f9",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Pie-Charts"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "c30096be-6783-4f26-aa70-1bcf6e4c9d2c",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSU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aOAS20XkQrZ06JwgrlABe5wW89oNrJ7XMP9efV009W67XgHdxBWlryR2pZNLYoL8FhIAPjE9P1ezh9ft12Hh40ATrFdRLJlU1BcY7sAWy72vzDcTyTrz5PT2FW2C0i27AgKJ3gyMMl2GbbkSPMRV/qf0ZvF7PlsqKQ0qzuUsyMoPNyaaDE/53FPz5dgWTfgS7aLSKbMDwr3DtFP2y7DtnxpHH2Wb7n2VdiT1acfmR8UcDnZ8XMcth8GHkrLFc88ojhUUjrbdhHJkg1vMM+Mjoulr+ybOMO3bp3tOjwsa1sVmR0UTnA6ELJdRjq5LWfxPts1eNh5oZLSrFxSIbODQlsThzhSdkwbLVs3267DowqAi2wXkQyZHhTn2i4g3Yjguz2w6H3bdXjYF20XkAyZGxTuFPx6i3UbjpV3pw1k9w7bdXjU1GxcDT1zgwI8NXFIZ4jQ7ZbAfett1+FROcAJtotINA2KLDXHt2pSd+q1Y9OOjF2Rrj2ZGRROcAgw0XYZ6UyE4A05D79puw6PyrqbxDIzKGCW7QIywfn+paMDNDXarsODJoZKSvvYLiKRMjUoptkuIBP4pbnoa/4ndb3S1PMBJ9kuIpEyNSim2y4gU3wt58nBkC2zE2WUrOqnyLygcNfsmGy7jEzRTZqGX+B/+TXbdXhQVvVTZF5QuOt16LRvnfD9nEc8M49oGhkXKikdYLuIRMnEoNDTjk4KSt34k32r19iuw2MEONl2EYmiQeERtwTua7BdgweNs11AomhQeEQRu6aMk82bbNfhMSHbBSRKZgWFOyV/se0
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"d.groupby(\"Typ\")[\"Preis\"].sum().plot(kind=\"pie\");\n",
"plt.show()"
]
2023-07-17 17:50:02 +02:00
},
{
"cell_type": "markdown",
"id": "e6c9a7fb-b374-4743-8b37-77fc8de79cbd",
"metadata": {},
"source": [
"## Grafiken speichern/exportieren\n",
"\n",
"Zum speichern der Grafiken muss man sich zuerst mittels `get_figure()` einen Verweis auf die Grafik holen ",
"Danach kann man über diese Referenz die Grafik in verschiedenen Formaten speichern:\n",
"```\n",
"fig = d.groupby(\"Typ\")[\"Preis\"].sum().plot(kind=\"pie\").get_figure();\n",
"fig.savefig('pie.png');\n",
"fig.savefig('pie.pdf');\n",
"```"
]
2022-10-10 11:13:41 +02:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}