在3的numpy矩阵中查找匹配的行

问题描述 投票:0回答:1

给定一个mxmxm的多维数据集,我需要知道6个面上的行,它们中的行的最小值大于给定的n。

python-3.x numpy cube
1个回答
0
投票

获得各种面孔:

faces = np.array([
    x[ 0,  :,  :],
    x[-1,  :,  :],
    x[ :,  0,  :],
    x[ :, -1,  :],
    x[ :,  :,  0],
    x[ :,  :, -1],
])

现在只需循环:

# No information on axis provided by OP so always pick axis=2
row_mins = np.min(faces, axis=2)
print(faces[row_mins > n])
© www.soinside.com 2019 - 2024. All rights reserved.