[Numpy-discussion] is it safe to change the dtype without rebuilding the array?
Fri Jan 1 17:49:31 CST 2010
2010/1/1 Ernest Adrogué <firstname.lastname@example.org>:
> I find myself doing this:
> In : x
> array([[0, 1, 2],
> [3, 4, 5],
> [6, 7, 8]])
> In : y=x.copy()
> In : y.dtype.char
> Out: 'l'
> In : dt=np.dtype([('a','l'),('b','l'),('c','l')])
> In : y.dtype=dt
> Is it okay?
> The problem is that it's not easy to rebuild the array.
> I tried with:
> np.array(y, dt)
> np.array(y.tolist(), dt)
> None worked.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion