I have a 2d array (n x m) from which I would like to produce a 1d array (length n) using a list of row-indices of length n.
For instance:
2d = ([a,b,c],[d,e,f],[g,h,i]) # input array
1d = ([0,2,1]) # row numbers
result = ([a,e,h]) # array of the first row of first column, third row of second column, second row of third column
I have found a way to do this using a list comprehension (iterating over the columns and the indices simultaneously and picking out the value), but there's surely a numpy function that does this?