Skip to content

Instantly share code, notes, and snippets.

@masiarek
Created June 1, 2022 14:26
Show Gist options
  • Save masiarek/52b61910c83bb19845e9c23111242479 to your computer and use it in GitHub Desktop.
Save masiarek/52b61910c83bb19845e9c23111242479 to your computer and use it in GitHub Desktop.
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