this will help The object shown in the question is not a list of lists of 4 data frames each so if we call that object L then to get what is described we need to create LL like this. Now using LL we can compute the 3 items requested.
>>> from collections import defaultdict
>>> data = defaultdict(int)
>>> L = [[0.5, 2], [0.5, 5], [2, 3], [2, 6], [2, 0.6], [7, 1]]
>>> for k, v in L:
... data[k] += v
>>> [[k,v] for (k,v) in data.items()]
[[0.5, 7], [2, 9.6], [7, 1]]
Is there any easy way to add elements in lists in a list to make all lists in a list has a same number of element?
By : user2606562
Date : March 29 2020, 07:55 AM
Hope this helps Honestly, I didn't find out for this question cuz... I don't know how to search or google it. So it might be the basic problem, but if anyone can helps me, I would really appreciate it. , Using zip with itertools.zip_longest: