python-numpy提取满足条件的数据

import numpy as np

#ndarray 的条件选取
array = np.arange(100).reshape(10,10)
logicalData0 = np.logical_and(array[:,1]>5,array[:,1]<100)
logicalData1 = np.logical_and(array[:,2]>5,array[:,2]<100)
logicalData = np.logical_and(logicalData0,logicalData1)
print(logicalData)

#直接报错
#ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
print(array[:,1]>5 and array[:,1]<100 and array[:,2]>5 and array[:,2]<100)

#如果采用and ,结果不对
#即使是and ,也不能直接使用and,需要对list中每个元素进行and操作
data = (array[:,1]>5).tolist() and (array[:,1]<100).tolist() and (array[:,2]>5).tolist() and (array[:,2]<100).tolist()
print(data)