Numpy

Numpy (4)

알 수 없는 사용자 2022. 7. 24. 23:06
728x90

How to extract items that satisfy a given condition from 1D array?

# Input
arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

# Solution
arr[arr % 2 == 1]