1

I have seen that there are similar questions, but the answers did not quite fit my exact needs. I have a dataframe that contains rows with different values. Some of the rows however have exactly the same value.

     Column1 Column2 Column3
0       a       x       x
1       a       x       x
2       a       x       x
3       d       y       y
4       d       y       y

What I would like to have is:

     Column1 Column2 Column3
0       a       x       x
1       d       y       y

So basically I want to merge all rows with the same values in all columns into one row. What is the most decent way to do that in python?

Thank you in advance!

1 Answer 1

2

Call drop_duplicates:

In [214]:
df.drop_duplicates()

Out[214]:
  Column1 Column2 Column3
0       a       x       x
3       d       y       y
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.