我有一个二维数组大小(2,3)和一个列表
输入:
a=['airplane','automobile','bird','cat','deer','dog','frog','horse','ship','truck']
b=[[4 2 8][1 7 0]] #2D numpy array shape (2,3) containing indices of list a
输出:
c = [['deer','bird','ship'],['automobile','horse','airplane']]
有没有什么方法或快捷方式可以在不迭代每个索引值的情况下实现输出?你知道吗
这就是工作:
如果您也将您的列表设为
np.array
,那么您只需要a[b]
:相关问题 更多 >
编程相关推荐