2

I have two numpy arrays or two pandas dataframes with three columns and different number of rows.

I want to find where the rows of the first array exist in the second array. Something like matlab's ismember function

[~, idx] = ismember(a, b, 'rows')

Is there a similar function in python? I do not want to use a loop.

3
  • Inner merge with dataframes merge Commented Mar 19, 2018 at 19:56
  • Thank you for your answer but I do not want to merge the two dataframes. I want to find the indices where the two dataframes have equal rows. Commented Mar 19, 2018 at 20:08
  • you could still use merge and set the argument indicator=True and then sort by the _merge column. Commented Mar 19, 2018 at 20:28

1 Answer 1

0
import numpy_indexed as npi
idx = npi.indices(a, b)
Sign up to request clarification or add additional context in comments.

1 Comment

Is there a documentation for this package? Thank you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.