In [1]:
%matplotlib inline

IPython Notebook

Brief Introduction and Unexpected use cases

Presenter: Kirill Kouzoubov

REPL

  • Read Evaluate Print Loop
  • Enables rapid iteration
  • Increases programmer productivitiy
  • Encourages experimentation

Built-in REPL

basic repl

IPython REPL

  • Better history management
  • Enhanced introspection
  • Tab completion
  • Access to documentation

ipython repl

IPython History

  • Main Author: Fernando Perez
  • Scientific Computing
  • 2001-2005: early efforts, enhanced REPL
  • 21-Dec-2011: First notebook release
  • Inspirations include
    • Maple Worksheets
    • Mathematica notebooks
  • 2014: Jupyter Project

IPython Notebook

  • REPL
  • Literrate Programming
  • For Data Science

Getting Started

  • Included with Anaconda
  • Ubuntu
    • sudo apt-get install ipython-notebook
    • sudo apt-get install ipython3-notebook
  • PIP
    • pip install ipython tornado pyzmq jinja2 jsonschema

Run

cd folder-with-notebooks
ipython notebook

Fancy Plots

Enable with

%matplotlib inline
In [2]:
import numpy as np
import matplotlib.pyplot as plt
Y, X = np.mgrid[-3:3:100j, -3:3:100j]
U = -1 - X**2 + Y
V = 1 + X - Y**2
plt.figure(figsize=(5,4))
plt.streamplot(X, Y, U, V, color=U, linewidth=2, cmap=plt.cm.autumn)
plt.colorbar()
plt.show()

Embed equations with ease

Markdown like this:

$$
S_{xx} = \sum^{N}_{i=1}{x_i^2}
$$

Renders as you would expect:

$$ S_{xx} = \sum^{N}_{i=1}{x_i^2} $$
In [3]:
img_url='https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Malevici06.jpg/480px-Malevici06.jpg'
svg_url='https://upload.wikimedia.org/wikipedia/commons/4/43/Average_daily_maximum_temperature_in_July_in_Australia.svg'

Embed External Media

Images

In [4]:
from IPython.display import Image
Image(url=img_url)
Out[4]:

SVG

In [5]:
from IPython.display import SVG
SVG(url=svg_url)
Out[5]:

Whole Webpage

In [6]:
from IPython.display import IFrame
IFrame('http://www.bom.gov.au/products/IDR403.loop.shtml', width=900, height=800)
Out[6]:

Even YouTube

In [7]:
from IPython.display import YouTubeVideo
YouTubeVideo('dQw4w9WgXcQ')
Out[7]:

Sharing Notebooks

Live Demo