I am trying to find values in an np.array corresponding to an index and then those that are not in the index. In R, I would do
> x <- c(1,2,3,4,5)
> ind = c(1,4)
> x[ind]
[1] 1 4
> x[-ind]
[1] 2 3 5
In Python, I can index and get the values in the index in the following manner
import numpy as np
x = np.array([1,2,3,4,5])
ind = [0,3]
x[ind]
However, in Python how can I get the values NOT in my index as I show in the R code using x[-ind]
?
I found the SO post below and have replicated this, but is this indeed the "right" or best approach? NumPy array, change the values that are NOT in a list of indices