I want to get the c array as result, but I don't know how:
import numpy as np
a = xrange(10)
b = np.array([3,2,1,9])
c is made of elements of a that are not in b:
c = np.array([0,4,5,6,7,8])
Perhaps a more straightforward solution is the following:
import numpy as np
a = xrange(10)
b = np.array([3,2,1,9])
c = np.setdiff1d(a,b)
Which results in:
In [7]: c
Out[7]: array([0, 4, 5, 6, 7, 8])
You can find all of the set-like operations for numpy arrays in the documentation: http://docs.scipy.org/doc/numpy/reference/routines.set.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With