3

I have 2 columns which contains duplicate entries. See example below. I want to remove duplicates from both columns Original Column

MatchN  Striker
1000887 DA Warner
1000887 DA Warner
1000887 TM Head
1000887 TM Head

I would like to finally get the result as

MatchN  Striker
1000887 DA Warner
1000887 TM Head

I tried using

np.df[["MatchN"],["Striker"]].unique()

but it does not work.

Can anyone please suggest best way to get to the desired result?

1 Answer 1

4

IIUC you need DataFrame.drop_duplicates() method:

In [69]: df = df.drop_duplicates(['MatchN','Striker'])

In [70]: df
Out[70]:
    MatchN    Striker
0  1000887  DA Warner
2  1000887    TM Head
Sign up to request clarification or add additional context in comments.

3 Comments

df.drop_duplicates(["MatchN"],["Striker"]) does not work
@AnoopMahajan, you should have posted a reproducible data set... Pleaase check updated answer
@AnoopMahajan, glad i could help :)

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.