我想根据列表中的索引交换2D numpy数组的行。
import numpy as np
###Input
order = [3,0,2,1] ###This list mentions the order
data = [[0,0,1,0],
[0,1,1,1],
[0,0,1,1],
[0,0,0,0]]
data = np.asarray(data)
###Expected output
data = [[0,0,0,0],
[0,0,1,0],
[0,0,1,1],
[0,1,1,1]]
我提到的输入只是一个例子。实际上,我有一个208 x 5000大的矩阵,因此我的订单清单的长度为208。因此,我需要一个快速的解决方案。见识将不胜感激。