import pandas as pd
import numpy as np
%pylab inline
figsize(5, 5)
Populating the interactive namespace from numpy and matplotlib
x = np.random.normal(0, 10, 10000)
y = np.random.normal(0, 10, 10000)
df = pd.DataFrame( { 'x' : x, 'y' : y } )
df['y'].hist(bins=30)
<matplotlib.axes.AxesSubplot at 0x106c18d10>
df.head(10)
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 |
df.plot(x='x', y='y', style='o', alpha=.02)
<matplotlib.axes.AxesSubplot at 0x10966cd90>
plt.hexbin(df['x'], df['y'], bins='log', gridsize=50, cmap=plt.cm.hot)
<matplotlib.collections.PolyCollection at 0x109716f10>
df = pd.read_csv('taxirides.csv')
df.head(5)
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 |
figsize(15, 15)
df.plot(x='PICKUP_LONG', y='PICKUP_LAT', style='o', alpha=.02)
<matplotlib.axes.AxesSubplot at 0x108e47d10>
plt.hexbin(df['PICKUP_LONG'], df['PICKUP_LAT'], bins='log', gridsize=400, cmap=plt.cm.hot)
<matplotlib.collections.PolyCollection at 0x108e5e450>