Note
Numpy (6) 본문
728x90
How to replace items that satisfy a condition without affecting the original array?
arr = np.arange(10)
out = np.where(arr % 2 == 1, -1, arr)
arr
#> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
out
#> array([ 0, -1, 2, -1, 4, -1, 6, -1, 8, -1])
Comments