0

I have two numpy arrays with different length.

array([['A', 'B'],
       ['C', 'D'],
       ['E', 'F']])


array([['B', 'A'],
       ['C', 'E']])

What I want is to see is if they have common rows, BUT not consider the order. So in the above two arrays, 'A' 'B' and 'B' 'A' are duplicates.

1 Answer 1

1

A possible solution, where a1 and a2 are the first and second arrays, respectively:

a1[np.isin(a1, a2).all(axis=1)]

Output:

array([['A', 'B']], dtype='<U1')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.