[Numpy-discussion] Rename record array fields

Stefan van der Walt stefan@sun.ac...
Wed Feb 20 17:08:25 CST 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
array([(1, 2), (3, 4)], 
      dtype=[('a', '<i4'), ('b', '<i4')])

In [3]: x.view([('other',int),('names',int)])
array([(1, 2), (3, 4)], 
      dtype=[('other', '<i4'), ('names', '<i4')])


More information about the Numpy-discussion mailing list