I'm a newbie to python, so please bear with me as I learn.
I have two defaultdicts, one with nested values:
d1 = defaultdict(dd_list)
d1 = {'a': {'b1': 12, 'c21': 41}, 'ff': {'h1': 2, 'b1': 32}}
d2 = defaultdict(dd_list)
d2 = {'a': 22, 'b1': 77, 'g8': 10, 'h1': 37}
I would like to filter d1 to return just the key-value pairs for the keys that are present in d2:
{'a': {'b1': 12}, 'ff': {'b1': 32, 'h1': 2}}
I tried using the approach described here but was unable to adapt it to this situation.
Thank you in advance!