[Numpy-discussion] [ANN] NumPy 1.0b4 now available

Robert Kern robert.kern at gmail.com
Sat Aug 26 14:28:20 CDT 2006


Les Schaffer wrote:

> 4. last year i made a case for the old records to return a list of the
> column names. it looks like the column names are now attributes of the
> record object, any chance of getting a list of them
> recarrayObj.get_colNames() or some such? yes, in working code, we know
> what the names are, but in test code we are creating recarrays from
> parsing of Excel spreadsheets, and for testing purposes, its nice to
> know what records THINKS are the names of all the columns.

In [2]: from numpy import *

In [3]: rec.fromarrays(ones(10, dtype=float)
Display all 628 possibilities? (y or n)

In [3]: a = rec.fromarrays([ones(10, dtype=float), ones(10, dtype=int)], 
names='float,int', formats=[float, int])

In [4]: a
Out[4]:
recarray([(1.0, 1), (1.0, 1), (1.0, 1), (1.0, 1), (1.0, 1), (1.0, 1),
        (1.0, 1), (1.0, 1), (1.0, 1), (1.0, 1)],
       dtype=[('float', '>f8'), ('int', '>i4')])

In [6]: a.dtype.names
Out[6]: ('float', 'int')

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco





More information about the Numpy-discussion mailing list