I've two data sets in array:
arr1 = [
['2011-10-10', 1, 1],
['2007-08-09', 5, 3],
...
]
arr2 = [
['2011-10-10', 3, 4],
['2007-09-05', 1, 1],
...
]
I want to combine them into one array like this:
arr3 = [
['2011-10-10', 1, 1, 3, 4],
...
]
I mean, just combine those lines with the same date
column.
Thanks everyone, Just for clarification, I don't need those lines which not appear in both array, just drop them.
Organize your data differently (you can easily convert what you already have to two dict
s):
d1 = { '2011-10-10': [1, 1],
'2007-08-09': [5, 3]
}
d2 = { '2011-10-10': [3, 4],
'2007-09-05': [1, 1]
}
Then:
d3 = { k : d1[k] + d2[k] for k in d1 if k in d2 }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With