From 8b063f9b05a67c03a73bb434ff0b059dcc4a1c20 Mon Sep 17 00:00:00 2001 From: cded6f222a164a22601711b16e547edb Date: Mon, 30 Nov 2020 23:07:56 +0000 Subject: [PATCH] Autour du SARS-CoV-2 (Covid-19) --- module3/exo3/exercice.ipynb | 70 +++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/module3/exo3/exercice.ipynb b/module3/exo3/exercice.ipynb index 0bbbe37..ae8cb06 100644 --- a/module3/exo3/exercice.ipynb +++ b/module3/exo3/exercice.ipynb @@ -1,5 +1,70 @@ { - "cells": [], + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%matplotlib inline\n", + "import matplotlib.pyplot as plt\n", + "import pandas as pd\n", + "import isoweek\n", + "\n", + "data_url =\"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\"\n", + "\n", + "raw_data = pd.read_csv(data_url, skiprows=1)\n", + "raw_data\n", + "\n", + "raw_data[raw_data.isnull().any(axis=1)] \n", + "\n", + "data = raw_data.dropna().copy()\n", + "data\n", + "\n", + "def convert_week(year_and_week_int):\n", + " year_and_week_str = str(year_and_week_int)\n", + " year = int(year_and_week_str[:4])\n", + " week = int(year_and_week_str[4:])\n", + " w = isoweek.Week(year, week)\n", + " return pd.Period(w.day(0), 'W')\n", + "\n", + "data['period'] = [convert_week(yw) for yw in data['week']]\n", + "\n", + "sorted_data = data.set_index('period').sort_index()\n", + "\n", + "periods = sorted_data.index\n", + "for p1, p2 in zip(periods[:-1], periods[1:]):\n", + " delta = p2.to_timestamp() - p1.end_time\n", + " if delta > pd.Timedelta('1s'):\n", + " print(p1, p2)\n", + " \n", + " sorted_data['inc'].plot()\n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], "metadata": { "kernelspec": { "display_name": "Python 3", @@ -16,10 +81,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 } - -- 2.18.1