[Numpy-discussion] field method in recarray

Christopher Hanley chanley at stsci.edu
Wed Feb 15 08:59:16 CST 2006


Hi Travis,

I have added a field method to recarray.  This allows field access via 
either field name or index number.

Example below:

In [1]: from numpy import rec

In [2]: r = 
rec.fromrecords([[456,'dbe',1.2],[2,'de',1.3]],names='col1,col2,col3')

In [3]: r.field('col1')
Out[3]: array([456,   2])

In [4]: r.field(0)
Out[4]: array([456,   2])

In [5]: r.field(0)[1]=1000

In [6]: r.field(0)
Out[6]: array([ 456, 1000])


Chris




More information about the Numpy-discussion mailing list