[Numpy-discussion] howto exclude elements from sorted array which are present in other sorted array

dmitrey openopt at ukr.net
Tue May 29 09:14:44 EDT 2007


thanks all, I have solved the problem
dmitrey wrote:
> hi all,
> I have 2 sorted arrays arr1 & arr2 (ascending order, for example 
> [1,2,5,8] and [3,5], but length may be thousands, so I need simpliest 
> way, not costly).
> Howto obtain arr3 that consists of elements present in arr1 but absent 
> in arr2?
> Of course, I can write something by myself, like
> arr3 = [x for x in arr1 if not x in arr2]
> but maybe already written routines are present in numpy? (that use sort)
>
> Usually arr2 is much more small than arr1, typical former size is 10-20 
> and typical latter size can be 1000-10000
>
> Thank you in advance, D.
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
>   




More information about the NumPy-Discussion mailing list