Numpy
Numpy (14)
Jun's N
2022. 8. 5. 01:23
How to extract all numbers between a given range from a numpy array?
a = np.arange(15)
# 1
index = np.where((a >= 5) & (a <= 10))
a[index]
# 2
index = np.where(np.logical_and(a>=5, a<=10))
a[index]
# 3
a[(a >= 5) & (a <= 10)]
# output
(array([6, 9, 10]),)
728x90