From 7ab29bfcff5c4e54dbfe865d9268e1246974ee08 Mon Sep 17 00:00:00 2001 From: 2120830 <2120830@stud.hs-mannheim.de> Date: Mon, 15 Dec 2025 19:52:00 +0100 Subject: [PATCH] =?UTF-8?q?hotspots=20=C3=BCber=20alle=20Jahre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notebooks/main.ipynb | 149 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 notebooks/main.ipynb diff --git a/notebooks/main.ipynb b/notebooks/main.ipynb new file mode 100644 index 0000000..2bfdf9a --- /dev/null +++ b/notebooks/main.ipynb @@ -0,0 +1,149 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\David Gaming\\AppData\\Local\\Temp\\ipykernel_18604\\2711366225.py:8: DtypeWarning: Columns (10,11,14,15,16) have mixed types. Specify dtype option on import or set low_memory=False.\n", + " df = pd.concat((pd.read_csv(f) for f in all_files), ignore_index=True)\n", + "C:\\Users\\David Gaming\\AppData\\Local\\Temp\\ipykernel_18604\\2711366225.py:8: DtypeWarning: Columns (10,11,14,15,16) have mixed types. Specify dtype option on import or set low_memory=False.\n", + " df = pd.concat((pd.read_csv(f) for f in all_files), ignore_index=True)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + " operator_name domain_name domain_id \\\n", + "0 Eco Counter GmbH Stadt Tübingen 667 \n", + "1 Eco Counter GmbH Stadt Tübingen 667 \n", + "2 Eco Counter GmbH Stadt Tübingen 667 \n", + "3 Eco Counter GmbH Stadt Tübingen 667 \n", + "4 Eco Counter GmbH Stadt Tübingen 667 \n", + "\n", + " counter_site counter_site_id \\\n", + "0 Fuß- & Radtunnel Südportal - Derendinger Allee 100003358 \n", + "1 Fuß- & Radtunnel Südportal - Derendinger Allee 100003358 \n", + "2 Fuß- & Radtunnel Südportal - Derendinger Allee 100003358 \n", + "3 Fuß- & Radtunnel Südportal - Derendinger Allee 100003358 \n", + "4 Fuß- & Radtunnel Südportal - Derendinger Allee 100003358 \n", + "\n", + " counter_serial longitude latitude timezone \\\n", + "0 YAH24052174 9.04806 48.518 (UTC+01:00) Europe/Paris DST \n", + "1 YAH24052174 9.04806 48.518 (UTC+01:00) Europe/Paris DST \n", + "2 YAH24052174 9.04806 48.518 (UTC+01:00) Europe/Paris DST \n", + "3 YAH24052174 9.04806 48.518 (UTC+01:00) Europe/Paris DST \n", + "4 YAH24052174 9.04806 48.518 (UTC+01:00) Europe/Paris DST \n", + "\n", + " iso_timestamp channels_in channels_out channels_unknown \\\n", + "0 2013-06-21T00:00:00+02:00 2844 2647 na \n", + "1 2013-06-22T00:00:00+02:00 2412 2233 na \n", + "2 2013-06-23T00:00:00+02:00 1884 1808 na \n", + "3 2013-06-24T00:00:00+02:00 2072 1878 na \n", + "4 2013-06-25T00:00:00+02:00 2426 2419 na \n", + "\n", + " channels_all site_temperature site_rain_accumulation site_snow_accumulation \n", + "0 5491 17.5 1.5 0.0 \n", + "1 4645 16.5 0.2 0.0 \n", + "2 3692 14.5 0.0 0.0 \n", + "3 3950 12.5 5.4 0.0 \n", + "4 4845 11.5 6.0 0.0 \n" + ] + } + ], + "source": [ + "\n", + "import pandas as pd\n", + "import glob\n", + "import os\n", + "\n", + "path = '../data/tageswerte_pro_Jahr/'\n", + "all_files = glob.glob(os.path.join(path , \"*.csv\")) #kein plan was das hier genau ist, hab es in Stack Overflow gefunden https://stackoverflow.com/questions/20906474/import-multiple-csv-files-into-pandas-and-concatenate-into-one-dataframe\n", + "\n", + "df = pd.concat((pd.read_csv(f) for f in all_files), ignore_index=True)\n", + "\n", + "print(df.head())" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Hotspots Durchschnitt Jahre\n", + "6 Kurpfalzbrücke 4994.045846\n", + "10 Renzstraße 3394.062305\n", + "5 Konrad-Adenauer-Brücke 2120.285610\n", + "1 Fernmeldeturm. 1828.993555\n", + "11 Schlosspark Lindenhof (Richtung Jugendherberge) 1333.949980\n", + "4 Jungbuschbrücke 1104.775576\n", + "9 Neckarauer Übergang -Schwetzinger Str. 1011.494404\n", + "7 Lindenhofüberführung 943.561290\n", + "8 Luzenbergstr. 667.606890\n", + "3 Feudenheimstr. stadtauswärts 512.098278\n" + ] + } + ], + "source": [ + "\n", + "#Hotspots seit Aufzeichnungsbeginn bis 2025 - gemittelt über die Jahre. \n", + "# Vllt noch den Vergleich zu den einzelnen Jahren ziehen und zeigen wie es sich verändert hat?!\n", + "hotspots = (\n", + " df[df[\"domain_name\"].str.strip() == \"Stadt Mannheim\"]\n", + " .groupby(\"counter_site\", as_index=False)[\"channels_all\"]\n", + " .mean()\n", + " .sort_values(\"channels_all\", ascending=False)\n", + " .head(10)\n", + ").rename(columns={\n", + " \"counter_site\": \"Hotspots\",\n", + " \"channels_all\": \"Durchschnitt Jahre\"\n", + " })\n", + "print(hotspots)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "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.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}