Pandas

Series

In [25]:
from datetime import datetime
from pandas import DataFrame, Series
from pandas import DatetimeIndex
In [16]:
s = Series([1.0,2.0,3.0,4.0], index=['a', 'b', 'c', 'd'])
s.mean()
Out[16]:
2.5
In [60]:
import random
# create some data
data = [random.randint(0,10000) for x in xrange(10000)]
# create a datetime index, provide start, frequency
index = DatetimeIndex(start='01-01-2013', periods=len(data), freq='T')
s = Series(data, index=index)
In [65]:
s_daily  = s.resample('D', how='sum')
s_daily
Out[65]:
2013-01-01    7345095
2013-01-02    7198042
2013-01-03    7277135
2013-01-04    7157573
2013-01-05    7072587
2013-01-06    7381243
2013-01-07    6728651
Freq: D, dtype: int64

DataFrames

In [74]:
data1 = [random.randint(0,10) for x in xrange(10)]
data2 = [random.randint(11,10000) for x in xrange(10)]

df = DataFrame({'data1': data1, 'data2': data2})
df['sum'] = df['data1'] + df['data2']
df
Out[74]:
data1 data2 sum
0 6 8802 8808
1 2 7325 7327
2 1 3034 3035
3 10 8860 8870
4 5 3614 3619
5 7 9714 9721
6 2 1434 1436
7 8 4538 4546
8 4 4353 4357
9 9 4667 4676

Vincent

In [4]:
# setup
import vincent
from vincent.ipynb import init_d3, init_vg, display_vega
init_d3()
init_vg()

vis = vincent.Bar()
vis.tabular_data((('A', 28), ('B', 55), ('C', 43), ('D', 91), ('E', 81), 
                  ('F', 53), ('G', 19), ('H', 87), ('I', 52)))
display_vega(vis)