Given a Numpy array x, and an array of integers y, I want to do something equivalent to:
z = np.array(x[i] for i in y)
Is there a Numpy function/method to do this efficiently without converting back to a list?
If y contains indices that are valid for x, then:
z = x[y]
>>> import numpy as np
>>> x = np.arange(100)
>>> y = np.array([1, 27, 36, 98])
>>> x[y]
array([ 1, 27, 36, 98])
[x[i] for i in y]?