I have a dataframe with two columns containing lists. I want to combine these columns into a single column and merge the lists into a single list. Also this list should only contain unique values from the original lists.
I've tried merging them using df['E']=df[['B','C']].values.tolist()
.
However this creates a single column with values comprising two lists.
The dataframe looks something like this:
A B C D
a1 [b1,b2] [c1,b1] d1
a2 [b1,b1] [b3] d2
a3 [b2] [b2,b2] d3
The final dataframe should look like this:
A B C D E
a1 [b1,b2] [c1,b1] d1 [b1,b2,c1]
a2 [b1,b1] [b3] d2 [b1,b3]
a3 [b2] [b2,b2] d3 [b2]
Edit: The values within the lists of the dataframe are strings.