In [30]:
import pandas as pd
import numpy as np

%pylab inline

figsize(5, 5)


Populating the interactive namespace from numpy and matplotlib

In [31]:
x = np.random.normal(0, 10, 10000)
y = np.random.normal(0, 10, 10000)

In [32]:
df = pd.DataFrame( { 'x' : x, 'y' : y } )

In [33]:
df['y'].hist(bins=30)


Out[33]:
<matplotlib.axes.AxesSubplot at 0x106c18d10>

In [34]:
df.head(10)


Out[34]:
x y
0 11.255542 -10.895887
1 -18.348279 2.776466
2 0.714115 2.774420
3 -5.617024 -6.166744
4 18.045067 21.617985
5 21.826769 1.260872
6 -6.976635 -10.330302
7 4.163109 -3.359381
8 4.103767 -16.370349
9 11.980980 5.356135

In [35]:
df.plot(x='x', y='y', style='o', alpha=.02)


Out[35]:
<matplotlib.axes.AxesSubplot at 0x10966cd90>

In [36]:
plt.hexbin(df['x'], df['y'], bins='log', gridsize=50, cmap=plt.cm.hot)


Out[36]:
<matplotlib.collections.PolyCollection at 0x109716f10>

In [37]:
df = pd.read_csv('taxirides.csv')

In [38]:
df.head(5)


Out[38]:
ID PICKUP_TIME PICKUP_ADDRESS PICKUP_LONG PICKUP_LAT
0 230216 2012-05-11 00:00:00 317 Washington St Boston Ma 02135 -71.152022 42.349030
1 230217 2012-05-11 00:00:00 Unnamed Road Boston Ma -71.018663 42.369197
2 230218 2012-05-11 00:00:00 Beacon St @ Commonwealth Ave Boston Ma -71.097962 42.348598
3 230219 2012-05-11 00:00:00 Commonwealth Ave @ Beacon St Boston Ma 02215 -71.096017 42.348735
4 230228 2012-05-11 00:00:00 400 Boylston St Boston Ma 02116 -71.072253 42.351457

In [40]:
figsize(15, 15)

In [42]:
df.plot(x='PICKUP_LONG', y='PICKUP_LAT', style='o', alpha=.02)


Out[42]:
<matplotlib.axes.AxesSubplot at 0x108e47d10>

In [41]:
plt.hexbin(df['PICKUP_LONG'], df['PICKUP_LAT'], bins='log', gridsize=400, cmap=plt.cm.hot)


Out[41]:
<matplotlib.collections.PolyCollection at 0x108e5e450>

In [ ]: