[Numpy-discussion] complex numpy.ndarray dtypes

John Gu johngu@gmail....
Wed Oct 1 23:15:38 CDT 2008


Hello,

I am using numpy in conjunction with pyTables.  The data that I read in from
pyTables seem to have the following dtype:

p = hdf5.root.myTable.read()

p.__class__
<type 'numpy.ndarray'>

p[0].__class__
<type 'numpy.void'>

p.dtype
dtype([('time', '<f4'), ('obs1', '<f4'), ('obs2', '<f8'), ('obs3', '<f4')])

p.shape
(61230,)

The manner in which I access a particular column is p['time'] or p['obs1'].
I have a couple of questions regarding this data structure: 1) how do I
restructure the array into a 61230 x 4 array that can be indexed using [r,c]
notation?  2) What kind of dtype is pyTables using?  How do I create a
similar array that can be indexed by a named column?  I tried various ways:

a = array([[1,2],[3,4]], dtype=dtype([('obs1','<f4'),('obs2','<f4')]))
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

p:\AsiaDesk\johngu\projects\deltaForce\<ipython console> in <module>()

<type 'exceptions.TypeError'>: expected a readable buffer object

I did find some documentation about array type descriptors when reading from
files... it seems like these array types are specific to arrays created when
reading from some sort of file / buffer?  Any help is appreciated.  Thanks!

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081001/59a9b7dc/attachment.html 


More information about the Numpy-discussion mailing list