I have a df:
Column A | Column B |
---|---|
John | Doe |
Tom | Tom |
Sally | Mae |
Mark | Mark |
Jack | Jack |
I want to extract all the names that appear in Column A and Column B as duplicates. For example, the final df should look like:
Column A | Column B |
---|---|
Tom | Tom |
Mark | Mark |
Jack | Jack |
I have tried .duplicated(subset=[“Column A”, “Column B”]) and .drop_duplicates, but these only present the duplicates from each row, not each column.
New contributor
thomas.py is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.