d2 = dict(t2)
res = [[k[0], d2.get(k[0], 0)] for k in t1]
How to use Python left outer join using FOR/LIST/DICTIONARY comprehensions (not SQL)?
-
15-03-2022 - |
Вопрос
I have two tuples, details below:
t1 = [
['aa'],
['ff'],
['er']
]
t2 = [
['aa', 11,],
['er', 99,]
]
and I would like to get results like these below using python method similar to SQL's LEFT OUTER JOIN:
res = [
['aa', 11,],
['ff', 0,],
['er', 99,]
]
Please help me with this.
Решение
Не связан с StackOverflow