diff --git a/notebooks/notebook_current_data.ipynb b/notebooks/notebook_current_data.ipynb index 4526089..0287d13 100644 --- a/notebooks/notebook_current_data.ipynb +++ b/notebooks/notebook_current_data.ipynb @@ -19,9 +19,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Data fetch: ok\n" + ] + } + ], "source": [ "import sys\n", "import os\n", @@ -35,6 +43,12 @@ "# User input the city, for the weather\n", "city_name = input(\"Enter a city in Norway: \")\n", "\n", + "for letter in city_name:\n", + " if letter in 'æøå':\n", + " city_name = city_name.replace('æ', 'ae')\n", + " city_name = city_name.replace('ø', 'o')\n", + " city_name = city_name.replace('å', 'aa')\n", + "\n", "# Stores the return of the function\n", "data, folder = fetch_current_data(city_name)" ] @@ -54,9 +68,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Data has been written to /Users/toravestlund/Documents/ITBAITBEDR/TDT4114 - Anvendt programmering/anvendt_mappe/data/../data/output_current_data/data_aaa_maura.json\n" + ] + } + ], "source": [ "# Gets the absolute path to the src folder\n", "sys.path.append(os.path.abspath(\"../src\"))\n", @@ -81,9 +103,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'coord': {'lon': 11.0167, 'lat': 60.25},\n", + " 'weather': [{'id': 500,\n", + " 'main': 'Rain',\n", + " 'description': 'light rain',\n", + " 'icon': '10d'}],\n", + " 'base': 'stations',\n", + " 'main': {'temp': 3.14,\n", + " 'temp_min': 2.52,\n", + " 'temp_max': 3.84,\n", + " 'humidity': 93,\n", + " 'sea_level': 1003,\n", + " 'grnd_level': 965},\n", + " 'visibility': 10000,\n", + " 'wind': {'speed': 1.54, 'deg': 70},\n", + " 'rain': {'1h': 0.11},\n", + " 'clouds': {'all': 75},\n", + " 'dt': 1743329160,\n", + " 'sys': {'type': 1,\n", + " 'id': 1624,\n", + " 'country': 'NO',\n", + " 'sunrise': 1743309996,\n", + " 'sunset': 1743357233},\n", + " 'timezone': 7200,\n", + " 'id': 3146270,\n", + " 'name': 'Maura',\n", + " 'cod': 200}" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import json\n", "\n", @@ -118,7 +175,92 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
namemain.tempmain.humiditymain.sea_levelmain.grnd_levelwind.speedrain.1hclouds.allsys.countrysys.sunrisesys.sunset
dt
2025-03-30 10:06:00Maura3.149310039651.540.1175NO2025-03-30 04:46:362025-03-30 17:53:53
\n", + "
" + ], + "text/plain": [ + " name main.temp main.humidity main.sea_level \\\n", + "dt \n", + "2025-03-30 10:06:00 Maura 3.14 93 1003 \n", + "\n", + " main.grnd_level wind.speed rain.1h clouds.all \\\n", + "dt \n", + "2025-03-30 10:06:00 965 1.54 0.11 75 \n", + "\n", + " sys.country sys.sunrise sys.sunset \n", + "dt \n", + "2025-03-30 10:06:00 NO 2025-03-30 04:46:36 2025-03-30 17:53:53 " + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import pandas as pd\n", "\n", @@ -151,6 +293,9 @@ "df['dt'] = pd.to_datetime(df['dt'], unit='s')\n", "df.set_index('dt', inplace=True)\n", "\n", + "# Drops the whole column, if all values is 'NaN' value.\n", + "df = df.dropna(axis='columns', how='all')\n", + "\n", "# Display the df after changes\n", "display(df)" ]