Python/numpy
nonzero
Gongsam
2023. 9. 23. 13:07
주어진 어레이에서 0이아닌 요소의 인덱스를 어레이로 반환
non_zero_indices = np.nonzero([1,2,0,0,4,0])
print(non_zero_indices)
(array([0, 1, 4]),)