Skip to content

Commit 367eb40

Browse files
committed
Download Taxi data if not yet cached
1 parent 95bb8ea commit 367eb40

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

notebooks/nyc_taxi_selection.ipynb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"metadata": {},
1515
"outputs": [],
1616
"source": [
17+
"import os\n",
1718
"import pandas as pd\n",
1819
"import numpy as np\n",
1920
"import plotly.graph_objs as go\n",
@@ -26,7 +27,24 @@
2627
"metadata": {},
2728
"outputs": [],
2829
"source": [
29-
"df = pd.read_pickle('data/nyc_taxi.pkl')\n",
30+
"pkl_path = 'data/nyc_taxi.pkl'\n",
31+
"if os.path.exists(pkl_path):\n",
32+
" print('Loading saved dataset file... ', end='')\n",
33+
" df = pd.read_pickle(pkl_path)\n",
34+
" print('done')\n",
35+
"else:\n",
36+
" print('Downloading and saving dataset (thanks to the datashader project for making this example dataset available!)... ', end='')\n",
37+
" df = pd.read_csv('http://s3.amazonaws.com/datashader-data/nyc_taxi.zip', compression='zip')\n",
38+
" df.to_pickle(pkl_path)\n",
39+
" print('done')"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
3048
"df.head()"
3149
]
3250
},
@@ -244,7 +262,7 @@
244262
"name": "python",
245263
"nbconvert_exporter": "python",
246264
"pygments_lexer": "ipython3",
247-
"version": "3.6.6"
265+
"version": "3.6.5"
248266
}
249267
},
250268
"nbformat": 4,

0 commit comments

Comments
 (0)