我有一组值
values = np.array([5, 4, 3, 2, 1])
值的索引数组
indices = np.array([[2, 3],
[1, 2],
[3, 4]])
我想使用索引值作为值的索引并得到结果
np.array([[3, 2],
[4, 3],
[2, 1])
我该怎么做?
答案 0 :(得分:3)
values[indices]
array([[3, 2],
[4, 3],
[2, 1]])