On 3/27/12 6:34 PM, Francesc Alted wrote:
> Another option that occurred to me recently is to save all your
> columns as unidimensional arrays (Array object, or, if you want
> compression, a CArray or EArray), and then use them as components of a
> boolean expression using the class `tables.Expr`. For example, if a,
> b and c are unidimensional arrays of the same size, you can do:
>
> bool_cond = tables.Expr('(2*a>0) & (cos(b) < .5) & (c**3 < 1)')
> indices = [ind for ind, bool_val in bool_cond if bool_val ]
Of course, the above line needs to read:
indices = [ind for ind, bool_val in enumerate(bool_cond) if bool_val ]
> results = your_dataset[indices]
Another solution, probably faster, although you need to make sure that
you have memory enough to keep your boolean array, is this:
bool_cond = tables.Expr('(2*a>0) & (cos(b) < .5) & (c**3 < 1)')
bool_arr = bool_cond.eval()
results = your_dataset[bool_arr]
--
Francesc Alted
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users