diff --git a/notebooks/demo_interact.ipynb b/notebooks/demo_interact.ipynb deleted file mode 100644 index 1b14382a63c3937782c38e916a62073216eefc46..0000000000000000000000000000000000000000 --- a/notebooks/demo_interact.ipynb +++ /dev/null @@ -1,185 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "a173b63d-52c5-4ce7-8445-9104c5a225d5", - "metadata": {}, - "outputs": [], - "source": [ - "%matplotlib inline" - ] - }, - { - "cell_type": "markdown", - "id": "ac77aa2a-ab03-4d18-88dc-8bed1a231d0c", - "metadata": {}, - "source": [ - "This demo need ipywidgets module\n", - "\n", - "```\n", - "pip install ipywidgets\n", - "```\n", - "\n", - "And enabling the widget backend (see the first cell of this notbook)." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "c4504712-9c32-4198-af1e-6887e4da3acc", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "import ipywidgets\n", - "from ipywidgets import interact" - ] - }, - { - "cell_type": "markdown", - "id": "f32dbf0d-8468-4386-ac3b-520a3330c84c", - "metadata": {}, - "source": [ - "## doc\n", - "\n", - "Link to offical ipywidget interact\n", - "\n", - "https://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html" - ] - }, - { - "cell_type": "markdown", - "id": "bb2ec7a4-acc8-46d0-acd5-61db4ef1d85d", - "metadata": {}, - "source": [ - "## first widget" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "0ca0db23-4ff5-45d6-b7c4-469cfa454013", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "b47c6742ec6640b58daef1b2bd3a21c3", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "IntSlider(value=2, max=10, step=2)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "slider = ipywidgets.IntSlider(2, min=0, max=10, step=2)\n", - "display(slider)" - ] - }, - { - "cell_type": "markdown", - "id": "03ef9efd-47be-47cb-9f93-4f64ddbf7da4", - "metadata": {}, - "source": [ - "There are lot mmore widget than sliders" - ] - }, - { - "cell_type": "markdown", - "id": "b89ba6db-4aa5-4964-8a05-60c0b07c0c93", - "metadata": {}, - "source": [ - "## How to link widget to a figure" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "d01dab50-0b8b-4fcc-a6e8-9d0d47dcd1b6", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "105e94fa42384b6ca497981937b34d65", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "interactive(children=(FloatSlider(value=0.5, description='c', max=4.0, step=0.5), Output()), _dom_classes=('wi…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "def sinewave(c=1):\n", - " x = np.linspace(0, 2 * np.pi, 100)\n", - " y = np.sin(x*c)\n", - "\n", - " plt.plot(x, y)\n", - " plt.ylabel('sin(x)')\n", - " plt.xlabel('x')\n", - " plt.title('Sinwave function')\n", - " plt.show()\n", - "slider = ipywidgets.FloatSlider(.5, min=0, max=4, step=.5)\n", - "interact(sinewave, c=slider);" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5e6312df-92da-40b9-8321-7b42932570fa", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "id": "1a02d93a-13dd-4cca-89cd-3d7926662506", - "metadata": {}, - "source": [ - "a tutorial\n", - "\n", - "https://towardsdatascience.com/bring-your-jupyter-notebook-to-life-with-interactive-widgets-bc12e03f0916" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "411ced85-689d-43a9-9ac5-4f7a69646fd8", - "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.8.12" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/notebooks/interactivity_TP.ipynb b/notebooks/interactivity_TP.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..6dcd2cec068444019bd875f7656f68ab4e4f02ac --- /dev/null +++ b/notebooks/interactivity_TP.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6066486e-1c4d-4da3-bbdd-d55bff7f64ca", + "metadata": {}, + "source": [ + "<center><b>Hands-on</b></center>\n", + "<b><p style=\"text-align:center;font-size:50px\">Interactivity</p></b>\n", + "<div style=\"text-align:center\">\n", + " <div>\n", + " Etienne Kornobis, François Laurent, Bertrand Néron\n", + " <br />\n", + " <a src=\" https://research.pasteur.fr/en/team/bioinformatics-and-biostatistics-hub/\">Bioinformatics and Biostatistics HUB</a>\n", + " <br />\n", + " © Institut Pasteur, 2022\n", + " </div> \n", + "</div>" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "4d12349e-6d72-4fb1-8bd7-775816af97e4", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import seaborn as sns\n", + "from ipywidgets import interact, widgets" + ] + }, + { + "cell_type": "markdown", + "id": "c4cfe182-0b6d-4325-8d53-459ad69ba161", + "metadata": {}, + "source": [ + "Using the `data/city_temperature.csv` dataset, we are going to practice interactivity using ipywidgets. \n", + "- Make a decorated function which returns a dataframe with only the data for a country selected by the user (through a dropdown widget for example): \n", + "\n", + "There is other ways, but the `unique` method can be of use as well:\n", + "> https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.unique.html#pandas.Series.unique" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3eba1eea-b75d-4a85-b1e0-404a89a3f6f2", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "id": "3841dd4e-c97d-4df7-b501-6dc385cb38c3", + "metadata": {}, + "source": [ + "- Make a decorated function which returns a graph of the temperatures with only the data for a city selected by the user." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f8599e2c-3b5d-4c52-a959-372572669253", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "id": "83c1db00-c52e-4f02-a922-a572329be2b1", + "metadata": {}, + "source": [ + "These temperatures in Fahrenheit are cumbersome especially in Europe, let's convert them to Celsius. Here is the formula to apply:\n", + "\n", + "$$°C = \\frac{°F - 32}{1.8}$$\n", + "- Create a new column to the dataframe with the temperatures as Celsius and redraw the last graph. We saw in the course that mathematical operations can be directly performed on Series, but it is also a good occasion to practice the `apply` method, using a `farhenheit_to_celsius` function for the conversion).\n", + "\n", + "> https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.apply.html" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aa8ec056-256f-4a95-bc9e-8ba3a5e13a15", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "id": "ace3cbd1-95ea-42a8-a763-4e6ecc481c6e", + "metadata": {}, + "source": [ + "As a side note `apply` can be usefull to access indices and columns names but `itertuples` is a much faster method to deal with the same kind of operations.\n", + "\n", + "> https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.itertuples.html" + ] + }, + { + "cell_type": "markdown", + "id": "99e9b153-c168-4192-a18e-0c12fb3a61c4", + "metadata": {}, + "source": [ + "- Using your interactive plot, you should see something strange checking the 10 first cities. What is happening in Addis Ababa ?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1e1fc7e2-8d86-4ef3-bd77-866b68d6dc48", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dev", + "language": "python", + "name": "dev" + }, + "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.10.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/interactivity_TP_solutions.ipynb b/notebooks/interactivity_TP_solutions.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..0dedb593b9ad7f40218262e3b8fc76075b3f1bc4 --- /dev/null +++ b/notebooks/interactivity_TP_solutions.ipynb @@ -0,0 +1,719 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6066486e-1c4d-4da3-bbdd-d55bff7f64ca", + "metadata": {}, + "source": [ + "<center><b>Hands-on</b></center>\n", + "<b><p style=\"text-align:center;font-size:50px\">Interactivity</p></b>\n", + "<div style=\"text-align:center\">\n", + " <div>\n", + " Etienne Kornobis, François Laurent, Bertrand Néron\n", + " <br />\n", + " <a src=\" https://research.pasteur.fr/en/team/bioinformatics-and-biostatistics-hub/\">Bioinformatics and Biostatistics HUB</a>\n", + " <br />\n", + " © Institut Pasteur, 2022\n", + " </div> \n", + "</div>" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "4d12349e-6d72-4fb1-8bd7-775816af97e4", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import seaborn as sns\n", + "from ipywidgets import interact, widgets" + ] + }, + { + "cell_type": "markdown", + "id": "c4cfe182-0b6d-4325-8d53-459ad69ba161", + "metadata": {}, + "source": [ + "Using the `data/city_temperature.csv` dataset, we are going to practice interactivity using ipywidgets. \n", + "- Make a decorated function which returns a dataframe with only the data for a country selected by the user (through a dropdown widget for example): \n", + "\n", + "There is other ways, but the `unique` method can be of use as well:\n", + "> https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.unique.html#pandas.Series.unique" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "0c98d6d5-1abe-4b8c-a65e-6e37e032be5f", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/tmp/ipykernel_34363/4028327859.py:1: DtypeWarning: Columns (2) have mixed types. Specify dtype option on import or set low_memory=False.\n", + " df = pd.read_csv(\"data/city_temperature.csv\")\n" + ] + } + ], + "source": [ + "df = pd.read_csv(\"data/city_temperature.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "ce0f614a-b506-43cc-87bd-cc92a28ba54d", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "eb6fddb5326449ca815735a85668c885", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='country', options=('Algeria', 'Burundi', 'Benin', 'Central African…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "@interact(country=widgets.Dropdown(options=df.Country.unique()))\n", + "def show_table(country):\n", + " return df.query(\"Country == @country\")" + ] + }, + { + "cell_type": "markdown", + "id": "3841dd4e-c97d-4df7-b501-6dc385cb38c3", + "metadata": {}, + "source": [ + "- Make a decorated function which returns a graph of the temperatures with only the data for a city selected by the user." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "d63898f0-fd24-417d-bb86-5ff903337436", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9464502403674d71bec6f520a0482b99", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='city', options=('Algiers', 'Bujumbura', 'Cotonou', 'Bangui', 'Braz…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "@interact(city=widgets.Dropdown(options=df.City.unique()))\n", + "def show_table(city):\n", + " df_selection = df.query(\"City == @city\")\n", + " sns.lineplot(x=\"Year\", y=\"AvgTemperature\", data=df_selection)" + ] + }, + { + "cell_type": "markdown", + "id": "83c1db00-c52e-4f02-a922-a572329be2b1", + "metadata": {}, + "source": [ + "These temperatures in Fahrenheit are cumbersome especially in Europe, let's convert them to Celsius. Here is the formula to apply:\n", + "\n", + "$$°C = \\frac{°F - 32}{1.8}$$\n", + "- Create a new column to the dataframe with the temperatures as Celsius and redraw the last graph. We saw in the course that mathematical operations can be directly performed on Series, but it is also a good occasion to practice the `apply` method, using a `farhenheit_to_celsius` function for the conversion).\n", + "\n", + "> https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.apply.html" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "20ffe958-a838-4901-a97d-c8074bf5d0e3", + "metadata": {}, + "outputs": [], + "source": [ + "df.loc[:,\"AvgTemperature_C\"] = (df.loc[:,\"AvgTemperature\"] - 23) / 1.8" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "9a7d32ef-266f-46d5-adf1-7c4691e48bb6", + "metadata": {}, + "outputs": [], + "source": [ + "def fahrenheit_to_celsius(x):\n", + " return (x - 23) / 1.8" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "dabc2d42-1439-4044-87d1-6c5bdc75df13", + "metadata": {}, + "outputs": [], + "source": [ + "df.loc[:,\"AvgTemperature_C\"] = df.loc[:,\"AvgTemperature\"].apply(fahrenheit_to_celsius)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "4e95c73b-075d-4e3a-acf9-396b3a75f75d", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "58cf81c263cf465a8620f911aee4309d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='city', options=('Algiers', 'Bujumbura', 'Cotonou', 'Bangui', 'Braz…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "@interact(city=widgets.Dropdown(options=df.City.unique()))\n", + "def show_table(city):\n", + " df_selection = df.query(\"City == @city\")\n", + " sns.lineplot(x=\"Year\", y=\"AvgTemperature_C\", data=df_selection)" + ] + }, + { + "cell_type": "markdown", + "id": "ace3cbd1-95ea-42a8-a763-4e6ecc481c6e", + "metadata": {}, + "source": [ + "As a side note `apply` can be usefull to access indices and columns names but `itertuples` is a much faster method to deal with the same kind of operations.\n", + "\n", + "> https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.itertuples.html" + ] + }, + { + "cell_type": "markdown", + "id": "99e9b153-c168-4192-a18e-0c12fb3a61c4", + "metadata": {}, + "source": [ + "- Using your interactive plot, you should see something strange checking the 10 first cities. What is happening in Addis Ababa ?" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "e8d6d579-ca30-4bbc-b1bd-9b7ea28c4068", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + }, + "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>Region</th>\n", + " <th>Country</th>\n", + " <th>State</th>\n", + " <th>City</th>\n", + " <th>Month</th>\n", + " <th>Day</th>\n", + " <th>Year</th>\n", + " <th>AvgTemperature</th>\n", + " <th>AvgTemperature_C</th>\n", + " </tr>\n", + " </thead>\n", + " <tbody>\n", + " <tr>\n", + " <th>58178</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>3</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58179</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>4</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58180</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>5</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58181</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>6</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58182</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>7</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58183</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>8</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58184</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>9</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58185</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>10</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58186</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>11</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58187</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>12</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58188</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>13</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58189</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>14</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58190</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>15</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58191</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>16</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58192</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>17</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58193</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>18</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58194</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>19</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58195</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>20</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58196</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>21</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58197</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>22</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58198</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>23</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58199</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>24</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58200</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>25</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58201</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>26</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58202</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>27</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58203</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>28</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58204</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>29</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58205</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>30</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " <tr>\n", + " <th>58206</th>\n", + " <td>Africa</td>\n", + " <td>Ethiopia</td>\n", + " <td>NaN</td>\n", + " <td>Addis Ababa</td>\n", + " <td>12</td>\n", + " <td>31</td>\n", + " <td>201</td>\n", + " <td>-99.0</td>\n", + " <td>-67.777778</td>\n", + " </tr>\n", + " </tbody>\n", + "</table>\n", + "</div>" + ], + "text/plain": [ + " Region Country State City Month Day Year AvgTemperature \\\n", + "58178 Africa Ethiopia NaN Addis Ababa 12 3 201 -99.0 \n", + "58179 Africa Ethiopia NaN Addis Ababa 12 4 201 -99.0 \n", + "58180 Africa Ethiopia NaN Addis Ababa 12 5 201 -99.0 \n", + "58181 Africa Ethiopia NaN Addis Ababa 12 6 201 -99.0 \n", + "58182 Africa Ethiopia NaN Addis Ababa 12 7 201 -99.0 \n", + "58183 Africa Ethiopia NaN Addis Ababa 12 8 201 -99.0 \n", + "58184 Africa Ethiopia NaN Addis Ababa 12 9 201 -99.0 \n", + "58185 Africa Ethiopia NaN Addis Ababa 12 10 201 -99.0 \n", + "58186 Africa Ethiopia NaN Addis Ababa 12 11 201 -99.0 \n", + "58187 Africa Ethiopia NaN Addis Ababa 12 12 201 -99.0 \n", + "58188 Africa Ethiopia NaN Addis Ababa 12 13 201 -99.0 \n", + "58189 Africa Ethiopia NaN Addis Ababa 12 14 201 -99.0 \n", + "58190 Africa Ethiopia NaN Addis Ababa 12 15 201 -99.0 \n", + "58191 Africa Ethiopia NaN Addis Ababa 12 16 201 -99.0 \n", + "58192 Africa Ethiopia NaN Addis Ababa 12 17 201 -99.0 \n", + "58193 Africa Ethiopia NaN Addis Ababa 12 18 201 -99.0 \n", + "58194 Africa Ethiopia NaN Addis Ababa 12 19 201 -99.0 \n", + "58195 Africa Ethiopia NaN Addis Ababa 12 20 201 -99.0 \n", + "58196 Africa Ethiopia NaN Addis Ababa 12 21 201 -99.0 \n", + "58197 Africa Ethiopia NaN Addis Ababa 12 22 201 -99.0 \n", + "58198 Africa Ethiopia NaN Addis Ababa 12 23 201 -99.0 \n", + "58199 Africa Ethiopia NaN Addis Ababa 12 24 201 -99.0 \n", + "58200 Africa Ethiopia NaN Addis Ababa 12 25 201 -99.0 \n", + "58201 Africa Ethiopia NaN Addis Ababa 12 26 201 -99.0 \n", + "58202 Africa Ethiopia NaN Addis Ababa 12 27 201 -99.0 \n", + "58203 Africa Ethiopia NaN Addis Ababa 12 28 201 -99.0 \n", + "58204 Africa Ethiopia NaN Addis Ababa 12 29 201 -99.0 \n", + "58205 Africa Ethiopia NaN Addis Ababa 12 30 201 -99.0 \n", + "58206 Africa Ethiopia NaN Addis Ababa 12 31 201 -99.0 \n", + "\n", + " AvgTemperature_C \n", + "58178 -67.777778 \n", + "58179 -67.777778 \n", + "58180 -67.777778 \n", + "58181 -67.777778 \n", + "58182 -67.777778 \n", + "58183 -67.777778 \n", + "58184 -67.777778 \n", + "58185 -67.777778 \n", + "58186 -67.777778 \n", + "58187 -67.777778 \n", + "58188 -67.777778 \n", + "58189 -67.777778 \n", + "58190 -67.777778 \n", + "58191 -67.777778 \n", + "58192 -67.777778 \n", + "58193 -67.777778 \n", + "58194 -67.777778 \n", + "58195 -67.777778 \n", + "58196 -67.777778 \n", + "58197 -67.777778 \n", + "58198 -67.777778 \n", + "58199 -67.777778 \n", + "58200 -67.777778 \n", + "58201 -67.777778 \n", + "58202 -67.777778 \n", + "58203 -67.777778 \n", + "58204 -67.777778 \n", + "58205 -67.777778 \n", + "58206 -67.777778 " + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.query(\"City == 'Addis Ababa' & Year < 1995\")" + ] + }, + { + "cell_type": "markdown", + "id": "667384c4-7e17-4117-8ba5-f5d26dfae3da", + "metadata": {}, + "source": [ + "Either some extremely cold temperature from an extremely old record... or some malformated data..." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dev", + "language": "python", + "name": "dev" + }, + "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.10.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/interactivity_cours.ipynb b/notebooks/interactivity_cours.ipynb index 9abe0cd6c8768fd996b2680b14278626b9379981..c9d1825b2424af7edebdbdf3110894e0f731cf34 100644 Binary files a/notebooks/interactivity_cours.ipynb and b/notebooks/interactivity_cours.ipynb differ