For example, I have a numpy array a = np.arange(10), and I need to assign the values in ignore = [2,3,4] to be number 255, like this:
a = np.arange(10)
ignore_value = [3,4,5]
a[a in ignore_value] = 255 # what is the correct way to implement this?
The last line in the program above cannot be accepted by Python3.5 but it shows what I want to do.
Edit:
I found a solution, but it's not vectorized.
for el in ignore_value:
a[a == el] = 255
This looks really ugly and is very slow since there is a for loop here, so do I have a better way ?
[0,1,2,255,255,255,6,7,8,9]?