Why during slicing assignment in numpy array decimals disappears? Why during slicing assignment in numpy array decimals disappears? numpy numpy

Why during slicing assignment in numpy array decimals disappears?


No, it is not a bug. From docs:

Note that assignments may result in changes if assigning higher types to lower types (like floats to ints) or even exceptions (assigning complex to floats or ints)


The behavior seems intuitive to me, array b remains the same dtype before and after the assignment, so dtype of a needs to be changed to dtype of b.

>>> a.astype(b.dtype) # and when you convert a to dtype of b you get:array([0, 0, 0])>>> >>> b[:, 1] = a.astype(b.dtype) # I believe this is what is going on under the hood.>>> barray([[1, 0],       [2, 0],       [3, 0]])