I have a pandas dataframe that looks something like this:
| ID | Value |
|---|---|
| 00001 | value 1 |
| 00001 | value 2 |
| 00002 | value 3 |
| 00003 | value 4 |
| 00004 | value 5 |
| 00004 | value 6 |
What I want to do is remove it so that I am left with this:
| ID | Value |
|---|---|
| 00001 | value 1 |
| 00002 | value 3 |
| 00003 | value 4 |
| 00004 | value 5 |
What’s the best way to achieve this?
>Solution :
As per my understanding you want to remove duplicates using only first row as criteria, you can using following code
df.drop_duplicates(subset=["ID"], keep='first')