keep unique words in a pandas dataframe row

Viewed 1788

Dataframe:

> df
>type(df)
pandas.core.frame.DataFrame

ID      Property Type                                Amenities
1952043 Apartment, Villa, Apartment                  Park, Jogging Track, Park
1918916 Bungalow, Cottage House, Cottage, Bungalow   Garden, Play Ground

How can I keep just the unique words separated by "comma" in the dataframe row? In this case it must not consider "Cottage House" and "Cottage" same. It must check this for all columns of the dataframe. So my desired output should look like below: Desired Output :

    ID      Property Type                      Amenities
    1952043 Apartment, Villa                   Park, Jogging Track
    1918916 Bungalow, Cottage House, Cottage   Garden, Play Ground
2 Answers
Related