[Numpy-discussion] Another dumb structured array question

Skipper Seabold jsseabold@gmail....
Wed Sep 30 09:24:30 CDT 2009


On Wed, Sep 30, 2009 at 9:51 AM, Travis Oliphant <oliphant@enthought.com> wrote:
>
> 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)
>

That's really helpful to know.  Is it too early to document this on
the wiki <http://docs.scipy.org/doc/numpy/user/basics.rec.html>?


More information about the NumPy-Discussion mailing list