Skip to content

Commit 2572a02

Browse files
committed
Merge pull request #31 from BCSharp/ipython4_ch01
Upgraded Chapter 01 recipes to IPython 4.0.0
2 parents b3bd10f + 7f02e3d commit 2572a02

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ data
22
_old
33
word
44
.ipynb_checkpoints
5+
__pycache__
56
matplotlibrc
67
*.bat
78
*.json
8-
*.txt
9+
*.txt

notebooks/chapter01_basic/01_notebook.ipynb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@
367367
"source": [
368368
"from collections import OrderedDict\n",
369369
"from IPython.display import display, clear_output\n",
370-
"from IPython.html.widgets import DropdownWidget"
370+
"from ipywidgets import Dropdown\n",
371+
"#from IPython.html.widgets import DropdownWidget # IPython < 4.x"
371372
]
372373
},
373374
{
@@ -378,10 +379,11 @@
378379
},
379380
"outputs": [],
380381
"source": [
381-
"# We create a DropdownWidget, with a dictionary containing\n",
382+
"# We create a Dropdown widget, with a dictionary containing\n",
382383
"# the keys (video name) and the values (Youtube identifier) \n",
383384
"# of every menu item.\n",
384-
"dw = DropdownWidget(values=OrderedDict([\n",
385+
"dw = Dropdown(options=OrderedDict([\n",
386+
"# dw = DropdownWidget(values=OrderedDict([ # IPython < 4.x\n",
385387
" ('SciPy 2012', 'iwVvqwLDsJo'), \n",
386388
" ('PyCon 2012', '2G5YTlheCbw'),\n",
387389
" ('SciPy 2013', 'j9YpkSX7NNM')]))\n",
@@ -395,7 +397,8 @@
395397
"# contains the value of the selected item.\n",
396398
"dw.on_trait_change(on_value_change, 'value')\n",
397399
"# We choose a default value.\n",
398-
"dw.value = dw.values['SciPy 2013']\n",
400+
"dw.value = dw.options['SciPy 2013']\n",
401+
"# dw.value = dw.values['SciPy 2013'] # IPyhon < 4.x\n",
399402
"# Finally, we display the widget.\n",
400403
"display(dw)"
401404
]
@@ -433,7 +436,7 @@
433436
"name": "python",
434437
"nbconvert_exporter": "python",
435438
"pygments_lexer": "ipython3",
436-
"version": "3.4.2"
439+
"version": "3.5.0"
437440
}
438441
},
439442
"nbformat": 4,

notebooks/chapter01_basic/02_pandas.ipynb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
"outputs": [],
5959
"source": [
60-
"url = \"http://donnees.ville.montreal.qc.ca/storage/f/2014-01-20T20%3A48%3A50.296Z/2013.csv\""
60+
"url = \"https://github.com/ipython-books/cookbook-data/raw/master/bikes.csv\""
6161
]
6262
},
6363
{
@@ -256,7 +256,8 @@
256256
},
257257
"outputs": [],
258258
"source": [
259-
"from IPython.html.widgets import interact\n",
259+
"from ipywidgets import interact\n",
260+
"#from IPython.html.widgets import interact # IPython < 4.x\n",
260261
"@interact\n",
261262
"def plot(n=(1, 30)):\n",
262263
" plt.figure(figsize=(8,4));\n",
@@ -280,6 +281,18 @@
280281
"display_name": "Python 3",
281282
"language": "python",
282283
"name": "python3"
284+
},
285+
"language_info": {
286+
"codemirror_mode": {
287+
"name": "ipython",
288+
"version": 3
289+
},
290+
"file_extension": ".py",
291+
"mimetype": "text/x-python",
292+
"name": "python",
293+
"nbconvert_exporter": "python",
294+
"pygments_lexer": "ipython3",
295+
"version": "3.5.0"
283296
}
284297
},
285298
"nbformat": 4,

0 commit comments

Comments
 (0)