I have a list of dictionaries as follows
[
{'sex': 2, 'newspaper_sheet__country': 'ML', 'n': 7},
{'sex': 1, 'newspaper_sheet__country': 'ML', 'n': 5},
{'sex': 2, 'newspaper_sheet__country': 'ML', 'n': 10}
]
I then have 2 Counters
from collections import Counter
counts = Counter()
counts1 = Counter()
I'm updating the two counters in the following formats
for row in rows:
counts.update({(row['sex'], row['newspaper_sheet__country']): row['n']})
and
counts1.update({(row['sex'], row['newspaper_sheet__country']): row['n'] for row in rows})
I would expect the values of the 2 counts to be the same since the only difference is 1 is using a for loop and the other one a dict comprehension.
Why are the 2 values different?