[Numpy-discussion] How to change the dtype of a structured or record array
Mon Sep 14 09:52:32 CDT 2009
I would like to change the dtype of just one field of a structured or
record array without copying the original array. I can not change the
creation of the original array because it was created using genfromtxt.
r=np.rec.array([(1, 1.0), (1, 1.0), (1, 1.0)],dtype=[('foo', int),
('bar', float)]) # illustrative example
r=r.astype([('foo', int), ('bar', int)]) # works this creates as copy
Is there alternative way to avoid this extra copying?
More information about the NumPy-Discussion