a small update

parent adc25c52
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"I modified this computational document such that it uses a local copy of the data. If the local file does not exist, download the data and put them into the local file. And then read the local CSV file." "I modified this computational document such that it uses a local file. If the local file exists, use it. If the local file does not exist, download the file from the website of the Réseau Sentinelles. "
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
"import urllib.request\n", "import urllib.request\n",
"\n", "\n",
"local_file_for_this_task = \"local_data.csv\"\n", "local_file_for_this_task = \"local_data.csv\"\n",
"data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\"\n", "data_url = \"https://www.sentiweb.fr/datasets/all/inc-3-PAY.csv\"\n",
"\n", "\n",
"if not os.path.exists(local_file_for_this_task):\n", "if not os.path.exists(local_file_for_this_task):\n",
" urllib.request.urlretrieve(data_url, local_file_for_this_task)\n", " urllib.request.urlretrieve(data_url, local_file_for_this_task)\n",
...@@ -70,26 +70,14 @@ ...@@ -70,26 +70,14 @@
"| `geo_insee` | Identifier of the geographic area, from INSEE https://www.insee.fr |\n", "| `geo_insee` | Identifier of the geographic area, from INSEE https://www.insee.fr |\n",
"| `geo_name` | Geographic label of the area, corresponding to INSEE code. This label is not an id and is only provided for human reading |\n", "| `geo_name` | Geographic label of the area, corresponding to INSEE code. This label is not an id and is only provided for human reading |\n",
"\n", "\n",
"The first line of the CSV file is a comment, which we ignore with `skip=1`." "The first line of the CSV file is a comment, which we ignore with `skiprows=1`."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"ename": "NameError",
"evalue": "name 'pd' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-4-7c69161e8105>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mraw_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlocal_file_for_this_task\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskiprows\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[1;32m 2\u001b[0m \u001b[0mraw_data\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'pd' is not defined"
]
}
],
"source": [ "source": [
"raw_data = pd.read_csv(local_file_for_this_task, skiprows=1)\n", "raw_data = pd.read_csv(local_file_for_this_task, skiprows=1)\n",
"raw_data" "raw_data"
...@@ -148,9 +136,7 @@ ...@@ -148,9 +136,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"def convert_week(year_and_week_int):\n", "def convert_week(year_and_week_int):\n",
...@@ -179,9 +165,7 @@ ...@@ -179,9 +165,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"sorted_data = data.set_index('period').sort_index()" "sorted_data = data.set_index('period').sort_index()"
...@@ -276,9 +260,7 @@ ...@@ -276,9 +260,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"first_august_week = [pd.Period(pd.Timestamp(y, 8, 1), 'W')\n", "first_august_week = [pd.Period(pd.Timestamp(y, 8, 1), 'W')\n",
...@@ -298,9 +280,7 @@ ...@@ -298,9 +280,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"year = []\n", "year = []\n",
...@@ -366,9 +346,21 @@ ...@@ -366,9 +346,21 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true "outputs": [],
}, "source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment