Python Dictionary Of List Of List Aggregate
I have timeseries dictionary available, I need to count all the values of each keys, what's the most efficient way to do this? DATA = {u'604': [[1361836800, {u'14885549': 52, u'9
Solution 1:
Using sum()
with a generator:
total =sum(sum(inner[1].values()) forouterin DATA.values() forinnerinouter)
This is equivalent in behavior to the following for loop:
total =0forouterin DATA.values():
forinnerinouter:
total +=sum(inner[1].values())
Post a Comment for "Python Dictionary Of List Of List Aggregate"