For interactive sessions, start with this:

%pylab inline

The %pylab portion is basically a bunch of "from X import *" commands and sets up the global environment with a bunch of handy stuff.

  1. Mathematical functions and constants, like sin() and pi, from numpy
  2. All of numpy as np
  3. simple graph api, like plot() and pie()
  4. matplotlib.pylot as plt

The inline keyword tells it to show graphs in the notebook instead of opening them in a new window.

In [1]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib

In [3]:
months = np.linspace(1, 36)
temps = 30 * sin(months * 2*pi/12) + 50
In [27]:
#plot(months, temps)
plot(months, temps * 0.8, 'go-', label="temps")

# style it a bit
ylim([0, 100])
xlim([1,36])
ylabel('Temp')
title('Seasonal Variation')
xlabel('Months')

#step(months, temps, 'y', label='steps')
bar(months, temps, color='#aaffaa', label='bars')


# add a legend
legend(loc=3)

None
In [30]:
N = 200
%timeit np.random.uniform(0,1, [N, N]).dot(np.random.uniform(0,1, [N, N]))
%timeit linalg.inv( np.random.uniform(0,1, [N, N]) )
1000 loops, best of 3: 1.72 ms per loop
1000 loops, best of 3: 1.9 ms per loop

In [5]:
import requests

response = requests.get('http://oranlooney.com/static/images/interface-diagram.png')
response
Out[5]:
<Response [200]>
In [6]:
response.headers
Out[6]:
CaseInsensitiveDict({'content-length': '73087', 'accept-ranges': 'bytes', 'expires': 'Wed, 14 Jan 2015 01:41:51 GMT', 'server': 'Apache/2.2.20 (Ubuntu)', 'last-modified': 'Tue, 13 Dec 2011 01:02:52 GMT', 'cache-control': 'max-age=31536000', 'date': 'Tue, 14 Jan 2014 01:41:51 GMT', 'content-type': 'image/png'})
In [7]:
from IPython.display import display, Image
In [8]:
display(Image(response.content))

More Resources

Why scipy is awesome: http://www.talyarkoni.org/blog/category/statistics/

A really good series of lectures/tutorials on scipy: https://github.com/jrjohansson/scientific-python-lectures

Moving from matlab to numpy: http://sebastianraschka.com/Articles/2014_matlab_vs_numpy.html