diff --git a/module3/exo1/analyse-syndrome-grippal.ipynb b/module3/exo1/analyse-syndrome-grippal.ipynb index 59d72b5b58a3ae26346460dd39e62a39c55243d7..17d7e423139d6383268fbfd081a847b5988cc1dd 100644 --- a/module3/exo1/analyse-syndrome-grippal.ipynb +++ b/module3/exo1/analyse-syndrome-grippal.ipynb @@ -34,7 +34,8 @@ }, "outputs": [], "source": [ - "data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\"" + "data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\"\n", + "local_filename = \"incidence-PAY-3.csv\"" ] }, { @@ -65,7 +66,19 @@ "metadata": {}, "outputs": [], "source": [ - "raw_data = pd.read_csv(data_url, skiprows=1)\n", + "if not os.path.exists(local_filename):\n", + " raw_data = pd.read_csv(data_url, skiprows=1)\n", + " raw_data.to_csv(local_filename, index=False) \n", + "else:\n", + " raw_data = pd.read_csv(local_filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "raw_data" ] }, @@ -278,12 +291,14 @@ "metadata": {}, "outputs": [], "source": [ + "first_august_week = [pd.Period(pd.Timestamp(y, 8, 1), 'W')\n", + " for y in range(1985, sorted_data.index[-1].year)]\n", + "\n", "year = []\n", "yearly_incidence = []\n", - "for week1, week2 in zip(first_august_week[:-1],\n", - " first_august_week[1:]):\n", + "for week1, week2 in zip(first_august_week[:-1], first_august_week[1:]):\n", " one_year = sorted_data['inc'][week1:week2-1]\n", - " assert abs(len(one_year)-52) < 2\n", + " assert abs(len(one_year) - 52) < 2\n", " yearly_incidence.append(one_year.sum())\n", " year.append(week2.year)\n", "yearly_incidence = pd.Series(data=yearly_incidence, index=year)" @@ -337,15 +352,6 @@ "source": [ "yearly_incidence.hist(xrot=20)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] } ], "metadata": { @@ -364,7 +370,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.1" + "version": "3.6.4" } }, "nbformat": 4,