0

I feel like this may be a really easy question but I can't figure it out I have a data frame that looks like this

one two three

1   2  3

2   3  3

3   4  4

The third column has duplicates if I want to keep the first row but drop the second row because there is a duplicate on row two how would I do this.

Stephen Mason
  • 337
  • 2
  • 12
  • 1
    Does this answer your question? [python pandas: Remove duplicates by columns A, keeping the row with the highest value in column B](https://stackoverflow.com/questions/12497402/python-pandas-remove-duplicates-by-columns-a-keeping-the-row-with-the-highest) – Peacepieceonepiece Sep 30 '21 at 01:41

1 Answers1

1

Pandas DataFrame objects have a method for this; assuming df is your dataframe, df.drop_duplicates(subset='name_of_third_column') returns the dataframe with any rows containing duplicate values in the third column removed.

Elijah Cox
  • 106
  • 7