I have a numpy array and a list that list that defines the rows I want to select. What is the best way to do this operation?
import numpy as np
a = np.array([[1,2,3],
[4,5,6],
[7,8,9]])
b = np.array([[1],
[0],
[2]])
Desired result
np.array([[2],
[4],
[9]])
I have tried np.take() but this does not work.
Kind regards
EDIT: as this needs to be done repeatedly on a large array, I'm looking for a vectorized approach (without loops)
ayou select the element at the column defined byba, the 0th element of the second row and the 2nd element of the last row (as defined inb)