Get unique values in List of Lists in python

前端 未结 6 1440
北海茫月
北海茫月 2020-12-05 13:35

I want to create a list (or set) of all unique values appearing in a list of lists in python. I have something like this:

aList=[[\'a\',\'b\'], [\'a\', \'b\'         


        
6条回答
  •  一个人的身影
    2020-12-05 14:39

    You can use numpy.unique:

    import numpy
    import operator
    print numpy.unique(reduce(operator.add, [['a','b'], ['a', 'b','c'], ['a']]))
    # ['a' 'b' 'c']
    

提交回复
热议问题