A Monday 09 February 2009, Nils Wagner escrigué: > Hi all, > > I have two integer arrays of different shape, e.g. > > >>> a > > array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) > > >>> b > > array([ 3, 4, 5, 6, 7, 8, 9, 10]) > > How can I extract the values that belong to the array a > exclusively i.e. array([1,2]) ?
One possible, fast solution is using Python sets: In [45]: np.array(list(set(a) ^ set(b))) Out[45]: array([1, 2]) Although this is suboptimal for very large arrays as it needs temporary space. Cheers, -- Francesc Alted _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
