fork download
  1. from collections import defaultdict
  2.  
  3. rowdata = [['100004100', 'ABC1234AS', '45.96'], ['100004101', 'ABC1234AS', '104.95'], ['100004103','453SDFAS', '24.52']]
  4.  
  5. bucket = defaultdict(list)
  6. for col1, col2, col3 in rowdata:
  7. bucket[col2].append((col1,col3))
  8.  
  9. duplicates = {key:value for key, value in bucket.items() if len(value) > 1}
  10.  
  11. print (duplicates)
Success #stdin #stdout 0.14s 10256KB
stdin
Standard input is empty
stdout
{'ABC1234AS': [('100004100', '45.96'), ('100004101', '104.95')]}