可以用np.argwhere + advanced indexing
写个例子:
arr = np.array([[3,2,11,7,4,22,56], [0]*7]).T idx = np.argwhere(np.logical_and(0<=arr[:,0], arr[:,0]<=10)).squeeze() arr[idx] # output the 0-10 class
提一下里面的几个点:
np.where
np.argwhere