Let's suppose a and b are given as below:-
a = np.arange(5)
b = [0,1,2]
What I want is that for indices excluding those in b ,values in a should be equal to -1.
So in the above case
a will be equal to
a = array([0, 1, 2, -1, -1])
There is a method which I am aware of i.e.
a[list(set(a)-set(b))] = -1
but takes too much time, and leads to too much complexity when actually writing the code. As always I am looking out for better methods than the above one. Feel free to use any tools required. Another example (just in case):- if
a = np.arange(12)
b = [3,5,6]
Then what I really want is
a = array([-1, -1, -1, 3, -1, 5, 6, -1, -1, -1, -1, -1])
P.S. Don't worry a will always be of the form np.arange(int) and no value of b exceeds the length of a