我是,使用python numpy数组。我想求出指定x坐标的点的所有y坐标。我用这个:
[it[1] for it in arrP if it[0] == specX]
有更好的方法吗?
arr = np.array([[1,2],[1,3],[2,3]])
# select x in arr with x[0] == 1, and slice out x[1]
arr[arr[:, 0] == 1][:, 1]
输出array([2, 3])