例如,我有:
arr = np.array[[10 30 20],
[30 20 10]]
indices = np.array[[2 1 0],
[2 1 0]]我要:
[[20 30 10],
[10 20 30]]非常感谢!!
发布于 2021-11-01 12:23:32
import numpy as np
arr = np.array([[10, 30, 20],
[30, 20, 10]])
indices = np.array([[2, 1, 0],
[2, 1, 0]])
res = np.take_along_axis(arr, indices, axis=1)
print(res)输出
[[20 30 10]
[10 20 30]]https://stackoverflow.com/questions/69796834
复制相似问题