Python: Uniqueness for list of lists

后端 未结 6 1028
慢半拍i
慢半拍i 2020-11-29 00:37

I am curious what would be an efficient way of uniquefying such data objects:

testdata =[ [\'9034968\', \'ETH\'], [\'14160113\', \'ETH\'], [\'9034968\', \'ETH         


        
6条回答
  •  孤城傲影
    2020-11-29 01:00

    You can use a set:

    unique_data = [list(x) for x in set(tuple(x) for x in testdata)]
    

    You can also see this page which benchmarks a variety of methods that either preserve or don't preserve order.

提交回复
热议问题