no commit message

parent 6de3309d
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
}, },
"outputs": [], "outputs": [],
"source": [ "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 @@ ...@@ -65,7 +66,19 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "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" "raw_data"
] ]
}, },
...@@ -278,12 +291,14 @@ ...@@ -278,12 +291,14 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "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", "year = []\n",
"yearly_incidence = []\n", "yearly_incidence = []\n",
"for week1, week2 in zip(first_august_week[:-1],\n", "for week1, week2 in zip(first_august_week[:-1], first_august_week[1:]):\n",
" first_august_week[1:]):\n",
" one_year = sorted_data['inc'][week1:week2-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", " yearly_incidence.append(one_year.sum())\n",
" year.append(week2.year)\n", " year.append(week2.year)\n",
"yearly_incidence = pd.Series(data=yearly_incidence, index=year)" "yearly_incidence = pd.Series(data=yearly_incidence, index=year)"
...@@ -337,15 +352,6 @@ ...@@ -337,15 +352,6 @@
"source": [ "source": [
"yearly_incidence.hist(xrot=20)" "yearly_incidence.hist(xrot=20)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
...@@ -364,7 +370,7 @@ ...@@ -364,7 +370,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.1" "version": "3.6.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
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