Add various notebooks

parent 5f629081
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# 1.2 Buffon's needle\n", "# Buffon's needle\n",
"Applying the method of [Buffon's needle](https://en.wikipedia.org/wiki/Buffon%27s_needle_problem), we get the **approximation**" "Applying the method of [Buffon's needle](https://en.wikipedia.org/wiki/Buffon%27s_needle_problem), we get the **approximation**"
] ]
}, },
......
This diff is collapsed.
...@@ -9,16 +9,16 @@ ...@@ -9,16 +9,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 5,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"%matplotlib inline\n", "%matplotlib inline\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import pandas as pd\n", "import pandas as pd\n",
"import isoweek" "import isoweek\n",
"\n",
"from os.path import isfile"
] ]
}, },
{ {
...@@ -30,12 +30,11 @@ ...@@ -30,12 +30,11 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# Website for initial download\n",
"data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\"" "data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\""
] ]
}, },
...@@ -63,12 +62,33 @@ ...@@ -63,12 +62,33 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# Initial download and saving a local copy\n",
"raw_data = pd.read_csv(data_url, skiprows=1)\n", "raw_data = pd.read_csv(data_url, skiprows=1)\n",
"raw_data" "fname = \"raw_influenza_incidence_data.csv\"\n",
"raw_data.to_csv(fname)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before loading the website from the internet, check if a local copy already exists. If a local copy exists, load it into a dataframe. If not, then get it from the URL. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if isfile(fname):\n",
" raw_data = pd.read_csv(fname, skiprows=1)\n",
"else:\n",
" raw_data = pd.read_csv(data_url, skiprows=1)"
] ]
}, },
{ {
...@@ -365,7 +385,7 @@ ...@@ -365,7 +385,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,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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