[Numpy-discussion] Another dumb structured array question

Robert Kern robert.kern@gmail....
Tue Sep 29 15:46:09 CDT 2009


On Tue, Sep 29, 2009 at 15:32, David Warde-Farley <dwf@cs.toronto.edu> wrote:
> Is there an easy way to get multiple subdtypes out? e.g. if I have a
> dtype
>
> dtype([('foo', 'i4'), ('bar', 'i8'), ('baz', 'S100')])
>
> and an array with that dtype, is there a way to only get the 'foo' and
> 'bar'?
>
> arr[('foo','bar')] doesn't seem to work.

A little bit of logic wrapped around
numpy.lib.recfunctions.drop_fields() should do the trick.

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