Last active
October 7, 2015 20:40
python left outer join and right outer join of dictonaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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