[Numpy-discussion] Rename record array fields
Stefan van der Walt
stefan at sun.ac.za
Wed Feb 20 18:08:25 EST 2008
Hi Sameer
On Wed, Feb 20, 2008 at 03:10:16PM -0600, Sameer DCosta wrote:
> Is there a way to rename record array fields without making a copy of
> the whole record array?
>
> Thanks in advance for your replies.
Simply view the array as a new dtype:
In [2]: x
Out[2]:
array([(1, 2), (3, 4)],
dtype=[('a', '<i4'), ('b', '<i4')])
In [3]: x.view([('other',int),('names',int)])
Out[3]:
array([(1, 2), (3, 4)],
dtype=[('other', '<i4'), ('names', '<i4')])
Regards
Stéfan
More information about the NumPy-Discussion
mailing list