[Numpy-discussion] dtype field renaming

Stéfan van der Walt stefan@sun.ac...
Wed Apr 8 17:47:18 CDT 2009

2009/4/9 Pierre GM <pgmdevlist@gmail.com>:
>> a.dtype.names = ('c', 'd')
> Now that's wicked neat trick ! I love it ! Faster than taking a view
> for sure.
> Note that rename_fields should work also w/ nested fields (not that
> common, true).

Yes, that is slightly more effort:

In [30]: arr = np.array(((2,3),), dtype=[('x',[('a',int),('b',int)])])
In [31]: arr['x'].dtype.names = ('p','q')

No all-in-one solution for renaming all the fields, but if you wanted
to do that a view would probably be the cleanest.


More information about the Numpy-discussion mailing list