Skip to content
Advertisement

Unique keywords on the column

I’m new to pandas and I have a question.

I have a dataframe like

JavaScript

and I should remove duplicates on “Keywords” column, no matter if the duplicates are on the same row or on 3 different rows. No matter if it is written “warehouse” or “Warehouse” Everything value duplicated is removed

The result should look like this:

JavaScript

For instance, column “D” will not have keywords at all, because all of them have duplicates on other rows

Thank you

Advertisement

Answer

One way using pandas.Series.str.split with explode:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement