Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
python left outer join and right outer join of dictonaries
d1={"foo": 3, "baz": -1, "bar": 5}
d2={"foo": 3, "ven": 10, "bar": 5}
d_1_2= dict(list(d1.items()) + list(d2.items()))
dict([[k, d2.get(k, 0)] for k in d_1_2] )#right outer join
dict([[k, d1.get(k, 0)] for k in d_1_2] )#left outer join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment