[Numpy-discussion] Renaming a field of an object array

Pierre GM pgmdevlist@gmail....
Wed Feb 4 16:50:38 CST 2009

I'm a tad puzzled by the following behavior (I'm trying to correct a  
bug in genfromtxt):

I'm creating an empty structured ndarray, using np.object as dtype.

 >>> a = np.empty(1,dtype=[('',np.object)])
       dtype=[('f0', '|O4')])

Now, I'd like to rename the field:
 >>> a.view([('NAME',np.object)])
TypeError: Cannot change data-type for object array.

I understand why I can't change the *type* of the field, but not why I  
can't change its name that way. What would be an option that wouldn't  
involve creating a new array ?
Thx in advance.

More information about the Numpy-discussion mailing list