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.
CodePudding user response:
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.