ContinuumIO/blaze — pull request #440 by mrocklin (2014-07-30 19:35:04+00:00)
Title: PyTables computational backend

Introduces a PyTables backend. Currently it just implements head, discover, and selection and then dumps to a numpy array. Still, should be nice to use `tables.read_where`. This also serves as a prototype for other similar projects.

```Python
In [1]: from blaze import *
impo
In [2]: import tables

In [3]: btc = tables.openFile('btc.hdf5').getNode('/user_edges')

In [4]: btc
Out[4]:
/user_edges (Table(37450461,)) ''
description := {
"transaction": Int64Col(shape=(), dflt=0, pos=0),
"sender": Int64Col(shape=(), dflt=0, pos=1),
"recipient": Int64Col(shape=(), dflt=0, pos=2),
"timestamp": Int64Col(shape=(), dflt=0, pos=3),
"value": Float64Col(shape=(), dflt=0.0, pos=4)}
byteorder := 'little'
chunkshape := (256,)

In [5]: t = Table(btc)

In [6]: t
Out[6]:
transaction sender recipient timestamp value
0 1 2 2 20130410142250 24.375000
1 1 2 782477 20130410142250 0.770900
2 2 620423 4571210 20111227114312 614.174951
3 2 620423 3 20111227114312 128.040520
4 3 3 782479 20130410142250 47.140520
5 3 3 4 20130410142250 150.000000
6 4 39337 39337 20120617120202 0.310818
7 4 39337 3 20120617120202 69.100000
8 5 2071196 2070358 20130304143805 61.602352
9 5 2071196 5 20130304143805 100.000000
...

In [7]: t[t.sender == 2]
Out[7]:
transaction sender recipient timestamp value
0 1 2 2 20130410142250 24.375000
1 1 2 782477 20130410142250 0.770900
2 18049 2 801493 20130410114545 23.218832
3 18049 2 2128 20130410114545 1.156168
4 23718 2 2 20130410120846 24.375000
5 23718 2 782477 20130410120846 1.257030
6 25983 2 801096 20130410114545 20.821057
7 25983 2 3068 20130410114545 3.553943
8 26616 2 2 20130409124938 24.375000
9 26616 2 782477 20130409124938 1.019900
...

In [8]: t[(t.sender == 2) & (t.value > 20)].sort('value', ascending=False)
Out[8]:
transaction sender recipient timestamp value
0 669480 2 75 20130401082135 38.349483
1 227025 2 6641 20130408075807 28.124734
2 816764 2 1297832 20130331182307 25.720272
3 1191264 2 2 20130325185621 24.375000
4 1168798 2 2 20130326040757 24.375000
5 1136657 2 2 20130326115133 24.375000
6 1101021 2 2 20130327090035 24.375000
7 1064881 2 2 20130327212847 24.375000
8 1044216 2 2 20130328011602 24.375000
9 1044204 2 2 20130328002541 24.375000
```