spartacus8w2039
spartacus8w2039

Reputation: 79

Python Drop duplicates to ignore case sensitive

I want to delete duplicates from the below df, preserving the case sensitivity.

Input df

df = pd.DataFrame({
    'company_name': ['Apple', 'apple','apple', 'BlackBerry', 
    'blackberry','Blackberry']
})

Expected df

        company_name
0   Apple
1   apple
2   BlackBerry
3   blackberry
4   Blackberry

Upvotes: 1

Views: 108

Answers (1)

BrokenBenchmark
BrokenBenchmark

Reputation: 19252

You can use drop_duplicates with ignore_index=True:

df.drop_duplicates(ignore_index=True)

This outputs:

  company_name
0        Apple
1        apple
2   BlackBerry
3   blackberry
4   Blackberry

Upvotes: 1

Related Questions