For each row of y I would like to get element whose indexes are specified in m.
>>> y = np.arange(15).reshape(3,5)
[[ 0 1 2 3 4]
[ 5 6 7 8 9]
[10 11 12 13 14]]
>>> m = np.array([[0, 1], [1, 2], [2, 3]])
Expected output:
[[0, 1]
[6, 7]
[12, 13]]
Solution with for cycle
>>> np.stack([y[i, cols] for i, cols in enumerate(m)])
Is there a way how to do it without a for cycle?