'How to remove duplicate values from the python dataframe?

I have a dataframe with duplicate values in either list or string format.

df = Name                  Email                            years        score 
     john           [[email protected],[email protected], [email protected]]                8           good
               
     
     [devan,smith ,devan]   [[email protected]]                   [8,6,8]           good

I want to remove duplicate values within that particular cell, not to compare corresponding to different cells.

df_updated = Name                  Email                      years        score
             john           [[email protected],[email protected]]                 8            good
               
     
          [devan,smith]          [[email protected]]                   [8,6]         good


Solution 1:[1]

Without the main dataframe, it is hard to guess how your dataframe functions. Anyway, here is what you probably need:

df["Email"].apply(set)

Note that Email column should be list. If you are interested in removing duplicated from other columns, let's say Name column, try replacing Name in place of Email in the abovementioned cell.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amirhossein Kiani