Skip to content

Instantly share code, notes, and snippets.

@venuktan
Last active October 7, 2015 20:40
Show Gist options
  • Save venuktan/910b25bc5cd6c1bf3065 to your computer and use it in GitHub Desktop.
Save venuktan/910b25bc5cd6c1bf3065 to your computer and use it in GitHub Desktop.
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