Reputation: 426
I have a dataframe:
df = pd.Dataframe({'src':['A','B','C'],'trg':['A','C','B'],'wgt':[1,3,7]})
I want to drop the duplicates from this dataframe for columns src
and trg
df = df.drop_duplicates(subset=['src','trg'],keep='first',inplace=False)
This should drop the first row where src=A
and trg='A'
But this is not happening. There is no change in the dataframe. What am I doing wrong ?
Upvotes: 0
Views: 85
Reputation: 31
TO remove the duplicate, you can refer to the following example which I have solved on pyNb
Or use df = df[df['src'] != df['trg']]
Upvotes: 1