2

I have two numpy arrays:

[ 2.09588161 2.34243927 2.45505059 3.61549894 6.42506932 8.52095092 5.76933731 6.03952746 4.30033044 3.77862927 3.73546847 5.40022069 8.52095092 10.61683253 7.75964201 8.01668568 6.17414768 4.40489563 4.72554455 5.76933731 7.75964201 6.02187958 4.53771075 2.59319536 1.94766573 6.03952746 8.01668568 4.53771075 6.6124742 5.38450762 4.30033044 6.17414768 2.59319536 5.38450762 4.67416659 2.09588161 2.34243927 2.45505059 3.61549894 3.77862927 3.73546847 5.40022069 4.40489563 4.72554455 1.94766573] [ 2.09588161 2.34243927 2.45505059 3.61549894 3.77862927 3.73546847 5.40022069 4.40489563 4.72554455 1.94766573] 

How can I remove elements from the first array that are the same like in the second one.

I have seen the uniques method, but it removes only duplicated elements from a particular array.

1
  • how large is a dataset? I mean if it is a matter of 1k items - just use sets, otherwise you would have to explore numpy Commented May 6, 2017 at 13:16

1 Answer 1

6

I suspect you desire numpy.setdiff1d

numpy.setdiff1d(ar1, ar2, assume_unique=False)[source]¶ Find the set difference of two arrays.

Return the sorted, unique values in ar1 that are not in ar2.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.