Why during slicing assignment in numpy array decimals disappears?
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]])