0
我有一個點(3D)的矩陣(2d numpy數組)。獲取2d數組的行,其中最小值在第一列
m = np.array([[x1, y1, z1],
[x2, y2, z2],
...,
[xn, yn, zn]])
我想找到在第一列(x值)的最小元素(x_min
)並獲得矩陣的整行,其中這x_min
是。例如,如果x_min
是在第三排,它將返回我,其中x_min == x_3
):
vector = [x_min, y_3, z_3]
我有這個,但想知道是否有更好的解決方案:
min = np.min(m[:, 0])
pos = np.where(min==m[:, 0])
m[pos, :]