0
我真的想避免循环这个简单的问题...numpy的矩阵最小应用于第二阵列
import numpy as np
x = np.array([[1,2,3,4], [5,6,1,2], [7,4,9,1]])
y = np.array([[2,5,6,7], [1,2,3,4], [1,2,3,4]])
print(x)
[[1 2 3 4]
[5 6 1 2]
[7 4 9 1]]
maxidx = np.argmax(x, axis=0)
print(maxidx)
[2 1 2 0]
到目前为止好。现在我只需要y数组中的这些索引条目。由于我只能得到每列的索引,所以我不确定如何正确应用它,而无需循环或创建列表......谢谢!
什么是你期望的输出? – Kasramvd
输出应该是[1 2 3 7] – HansSnah