From 1caeff9333be835c0f1c4250bd7790a3635f1918 Mon Sep 17 00:00:00 2001 From: 521adc37f04e8509ebf5ce131815aa0a <521adc37f04e8509ebf5ce131815aa0a@app-learninglab.inria.fr> Date: Sat, 6 Feb 2021 12:51:40 +0000 Subject: [PATCH] =?UTF-8?q?D=C3=A9finir=20une=20fonction=20de=20conversion?= =?UTF-8?q?=20year/week=20pour=20toutes=20les=20lignes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module3/exo2/exercice.ipynb | 45 ++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/module3/exo2/exercice.ipynb b/module3/exo2/exercice.ipynb index c059551..6063041 100644 --- a/module3/exo2/exercice.ipynb +++ b/module3/exo2/exercice.ipynb @@ -2062,7 +2062,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -2083,6 +2083,49 @@ "print(w.day(0))" ] }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Period('1984-10-29/1984-11-04', 'W-SUN')" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pd.Period(w.day(0), \"w\")" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "# Définir une fonction pour chaque ligne des jeux de données\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\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 9, -- 2.18.1