Created
June 1, 2022 14:26
-
-
Save masiarek/52b61910c83bb19845e9c23111242479 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from collections import defaultdict | |
from pprint import pp | |
left = [{1: ["10", "11"]}, {2: ["20", "21"]}] | |
right = [ | |
{"10": ["a", "b"]}, | |
{"11": ["a", "b"]}, | |
{"20": ["x", "y"]}, | |
{"21": ["x", "z"]}, # <== here is a difference! | |
] | |
""" | |
1) join tables 'left' and 'right'. | |
2) Find the differences between both tables: | |
Expected output: {2: ["20", "21"]} | |
""" | |
# pp(left) | |
dd = defaultdict(list) | |
for e in left: | |
print(e) | |
for row in right: | |
dd.update(row) | |
pp(dd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment