[Numpy-discussion] Another dumb structured array question

Travis Oliphant oliphant@enthought....
Wed Sep 30 08:51:56 CDT 2009

On Sep 29, 2009, at 3:32 PM, David Warde-Farley 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.

Try  (with a later version of NumPy --- possibly trunk):

arr[['foo', 'bar']]

(i.e. with a list instead of a tuple)


More information about the NumPy-Discussion mailing list