What is the best way to merge two lists into one and also combine double values? For example:
list_01 = [['2020-01-02', '2020-01-03', '2020-01-04', '2020-01-06'],
['10', '20', '30', '40']]
list_02 = [['2020-01-04', '2020-01-05', '2020-01-06', '2020-01-07'],
['10', '20', '30', '40']]
The final list should look like this:
list_03 = [['2020-01-02', '2020-01-03', '2020-01-04', '2020-01-05', '2020-01-06', '2020-01-07'],
['10', '20', '40', '30', '70', '40']]
Whenever the dates have matched, the integer-values in the second column have been summed together.
Right now, my only real solution is to pass both lists trough several loops, but I wonder if there might be a better solution.
Thanks and a great evening for all of you.
20
? As it is the value associated with2020-01-05
inlist_02