Skip to content
Advertisement

pandas, access a series of lists as a set and take the set difference of 2 set series

Given 2 pandas series, both consisting of lists (i.e. each row in the series is a list), I want to take the set difference of 2 columns

For example, in the dataframe…

JavaScript

I want to create a new column C, that is set(A) – set(B)…

JavaScript

Advertisement

Answer

Thanks to: https://www.geeksforgeeks.org/python-difference-two-lists/

JavaScript

Output

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