Opposite of numpy.delete

numpy

Solution

Use fancy indexing:

>>> a = np.array([3,65,7,83,2,4])
>>> a[[1, 3, 5]]
array([65, 83,  4])

Problem

I have a numpy array which looks like: `[3,65,7,83,2,4]` and I want to keep indices `[1,3,5]`. Which would give me `[65, 83, 4]`. Is there a way to do this in Numpy? This would essentially be the opposite of the `numpy.delete` function.

Original source