In [203]: A = np.arange(12).reshape(3,4)
In [204]: B = np.array([[0,2],[1,3],[3,0]])
Ваша итерация строки:
In [207]: A_reduced = np.zeros((3,2),int)
In [208]: for i in range(3):
...: A_reduced[i,:] = A[i, B[i,:]]
...:
In [209]: A_reduced
Out[209]:
array([[ 0, 2],
[ 5, 7],
[11, 8]])
'Векторизованная' версия:
In [210]: A[np.arange(3)[:,None], B]
Out[210]:
array([[ 0, 2],
[ 5, 7],
[11, 8]])
и усовершенствованная с помощью новой функции sh:
In [212]: np.take_along_axis(A,B,axis=1)
Out[212]:
array([[ 0, 2],
[ 5, 7],
[11, 8]])