1

I have 2 dataframes; dataframe main and dataframe mini, with exactly the same headers but with different values in them however there is some overlap. How would I get the duplicate values within a single column (e.g. Column 'Name').

Example:

dataframe main

Name    size    length
foo      1         2
foo2     3         4
foo3     5         6  
foo4     7         8

dataframe mini

Name     size     length
foox      60       70
foo3       3        4
fooy      50       60
foo4      7        8

psuedo code: intersect(column='Name', of='dataframe mini', against='dataframe main')

proposed out : (foo3,foo4)

1 Answer 1

1

You can use isin to mask the row values that are in another df:

In [52]:
main.loc[main['Name'].isin(mini['Name']), 'Name']

Out[52]:
2    foo3
3    foo4
Name: Name, dtype: object
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.