Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
2 views
by (18.4k points)

I have the dataframe like this

    Col1           Col2

['joe', 'joe']     ['joe']

['sam','bob']     ['sam'.'bob']

['mary','mary']   ['mary']

I want to use an apply function on Col1 to get my result in Col2. Meaning, I want my lists with the duplicates in Col1 to no longer have those duplicates in Col2. Tried various functions with an applying and set, no dice. Seems like it should be straightforward.

1 Answer

0 votes
by (36.8k points)

For get col two

df['ColB'] = df['Col1'].explode().groupby(level=0).unique()

 Want to be a Data Science expert? Come and join this Data Science Courses

Browse Categories

...