I want to get the elements of a numpy array using an index array like so
import numpy
a = numpy.arange(6)
ind = [2,3]
now, a[ind] gives me the 3rd and 4th element, but I actually want all the other elements of a.
Is there a one line/ elegant way to do this?
There isn’t a straightforward way I know of to get the complement of a set of integer indices. Boolean index negation is easy, which lets you do something like this:
But it isn’t a one line solution.