I am trying to effectively change:
[{'text': 'hallo world', 'num': 1}, {'text': 'hallo world', 'num': 2}, {'text': 'hallo world', 'num': 1}, {'text': 'haltlo world', 'num': 1}, {'text': 'hallo world', 'num': 1}, {'text': 'hallo world', 'num': 1}, {'text': 'hallo world', 'num': 1}]
to the list of dictionaries without duplicates and the number of duplicates:
[{'text': 'hallo world', 'num': 2, 'count':1}, {'text': 'hallo world', 'num': 1, 'count':5}, {'text': 'haltlo world', 'num': 1, 'count':1}]
So far, I have the following to find duplicates:
result = [dict(tupleized) for tupleized in set(tuple(item.items()) for item in li)]
and it returns:
[{'text': 'hallo world', 'num': 2}, {'text': 'hallo world', 'num': 1}, {'text': 'haltlo world', 'num': 1}]
THANKS!