-4

I have 1 dataframe and I want to select all rows that don't have duplicates

My df:

Name     Age
Jp       4
Anna     15
Jp       4
John     10

My output should be :

Name    Age
Anna     15
John     10

I am using Pandas dataframe

any suggestions?

  • 1
    `df.drop_duplicates(keep=False)`. – Quang Hoang Feb 15 '21 at 21:52
  • 3
    Stack Overflow is not intended to replace existing tutorials and documentation. See [How much research](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) and the [Question Checklist](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) – Prune Feb 15 '21 at 21:56
  • @Prune: bad as this question is, it's not about duplicate **indices**, so not a dupe of that target. It's about **duplicates in multiple columns.** – smci Feb 16 '21 at 06:57

1 Answers1

1

You want to drop duplicates across multiple columns:

df.drop_duplicates(['Name','Age'])

Please see the pandas documentation on basic methods of dataframes.

smci
  • 32,567
  • 20
  • 113
  • 146