[Numpy-discussion] dtype field renaming
hi there -- for a numpy.recarray, is it possible to rename the fields in the dtype? thanks a bunch elaine ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] dtype field renaming
On Apr 8, 2009, at 5:57 PM, Elaine Angelino wrote: hi there -- for a numpy.recarray, is it possible to rename the fields in the dtype? Take a new view: a = np.array([(1,1)],dtype=[('a',int),('b',int)]) b = a.view([(A,int), ('b', int)]) or: use numpy.lib.recfunctions.rename_fields ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] dtype field renaming
2009/4/9 Pierre GM pgmdevl...@gmail.com: for a numpy.recarray, is it possible to rename the fields in the dtype? Take a new view: a = np.array([(1,1)],dtype=[('a',int),('b',int)]) b = a.view([(A,int), ('b', int)]) or: use numpy.lib.recfunctions.rename_fields Or change the names tuple: a.dtype.names = ('c', 'd') Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] dtype field renaming
On Apr 8, 2009, at 6:18 PM, Stéfan van der Walt wrote: 2009/4/9 Pierre GM pgmdevl...@gmail.com: for a numpy.recarray, is it possible to rename the fields in the dtype? Take a new view: a = np.array([(1,1)],dtype=[('a',int),('b',int)]) b = a.view([(A,int), ('b', int)]) or: use numpy.lib.recfunctions.rename_fields Or change the names tuple: 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). ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion