From 158ac45486a7bd80c2968ffee3e597a7a9dc98c4 Mon Sep 17 00:00:00 2001 From: 8af936f0a98530ad3530092bbc37987a <8af936f0a98530ad3530092bbc37987a@app-learninglab.inria.fr> Date: Tue, 23 Feb 2021 11:53:14 +0000 Subject: [PATCH] =?UTF-8?q?module=205A=20(toujours=20un=20probl=C3=A8me=20?= =?UTF-8?q?avec=20le=20chargement=20colonne=20week)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module3/chabert.ipynb | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/module3/chabert.ipynb b/module3/chabert.ipynb index e646b02..6bb58f4 100644 --- a/module3/chabert.ipynb +++ b/module3/chabert.ipynb @@ -2242,6 +2242,81 @@ "sorted_data['inc'][-200:].plot()" ] }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "module 'pandas' has no attribute 'Timesstamp'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTimesstamp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2000\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m8\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m: module 'pandas' has no attribute 'Timesstamp'" + ] + } + ], + "source": [ + "first_august_week = [pd.Period(pd.Timestamp(y, 8, 1), 'W')\n", + " for y in range(sorted_data.index[0].year, \n", + " sorted_data.index[-1].year)]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "year = []\n", + "yearly_incidence = []\n", + "for week1, week2 in zip(first_august_week[:-1], \n", + " first_ august_week[1:]):\n", + " one_year = sorted_data['inc'][week1:week2-1]\n", + " assert abs(len(one_year)-52) < 2\n", + " yearly_incidence.apprend(one_year.sum())\n", + " year.append(week2.year)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "yearly_incidence = pd.Serie(index=year, data = yeraly_incidence)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "yearly_incidence.plot(style='*')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "yearly_incidence.sort_values" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "yearly_incidence.hist(xrot=20)" + ] + }, { "cell_type": "code", "execution_count": null, -- 2.18.1