[Numpy-discussion] Tabular data package

Robert Kern robert.kern@gmail....
Mon Oct 5 17:36:11 CDT 2009


On Mon, Oct 5, 2009 at 17:16, Elaine Angelino <elaine.angelino@gmail.com> wrote:
> hey pierre -- good question. this is something we debated a while ago (we
> actually sent a couple of emails over the numpy list about this very topic)
> when coming up with our design.  at the time, there did not seem to be
> strong opinions either way about using ndarray vs. recarray
>
> the main reason we went with the recarray over the ndarray is because the
> recarray has a couple of useful construction functions (e.g.
> np.rec.fromrecords and np.rec.fromarrays).  not only are these functions
> convenient to use, they have nice data type inference properties which we'd
> have to rebuild ourselves if we wanted to avoid recarrays entirely.

Try np.rec.fromrecords(...).view(np.ndarray).

Most likely, we should have versions of those functions that return
plain ndarrays. They are quite useful.

Perhaps

def fromarrays(..., type=None):
    ...
    if type is not None:
        _array = _array.view(type)
    return _array

-- 
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