numpy获取列索引,其中所有元素都大于阈值

She*_*hew 0 python numpy

我想找到一个numpy数组的列索引,其中列的所有元素都大于阈值.

例如,

 X = array([[ 0.16,  0.40,  0.61,  0.48,  0.20],
            [ 0.42,  0.79,  0.64,  0.54,  0.52],
            [ 0.64,  0.64,  0.24,  0.63,  0.43],
            [ 0.33,  0.54,  0.61,  0.43,  0.29],
            [ 0.25,  0.56,  0.42,  0.69,  0.62]])
Run Code Online (Sandbox Code Playgroud)

在上述情况下,如果阈值为0.4,我的结果应为1,3.

hil*_*lem 6

您可以min使用np.where以下方法与每列进行比较:

large = np.where(X.min(0) >= 0.4)[0]
Run Code Online (Sandbox Code Playgroud)