[Numpy-discussion] Casting RecArray fields?

dHering vel.accel at gmail.com
Tue Jan 31 01:47:07 CST 2006


Hi all,

I need to cast fields of type 'Bool' to type 'Int32'.
I'm not sure how to do this.

Thank you,
Dieter


import numarray.records as rec

b = rec.array([[23, 0],[45, 1]], names=' integer, boolean',formats='Int32,
Bool')

print b.field(1).type()
#  following line is not permissable
#  b.field(1) = b.field(1).astype('Int32')
b.field(1)[:] = b.field(1).astype('Int32')
print b.field(1).type()

##########################
##########################
/usr/bin/python -u

Bool
Bool
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060131/8f04c777/attachment.html 


More information about the Numpy-discussion mailing list