I have a list of sets :
L = [set([1, 4]), set([1, 4]), set([1, 2]), set([1, 2]), set([2, 4]), set([2, 4]), set([5, 6]), set([5, 6]), set([3, 6]), set([3, 6]), set([3, 5]), set([3, 5])]
(actually in my case a conversion of a list of reciprocal tuples)
and I want to remove duplicates to get :
L = [set([1, 4]), set([1, 2]), set([2, 4]), set([5, 6]), set([3, 6]), set([3, 5])]
But if I try :
>>> list(set(L))
TypeError: unhashable type: 'set'
Or
>>> list(np.unique(L))
TypeError: cannot compare sets using cmp()
How do I get a list of sets with distinct sets?
set
tolist
oflist
and then remove the duplicates and then converting thelist
elements back toset
.set
tolist
oflist
and then remove the dupicates", we get thatlist(map(list, [{3, 11}, {11, 3}]))
outputs[[3, 11], [11, 3]]
.