Created
October 24, 2016 14:05
-
-
Save emmanuellyautomated/8698147d6dbb1d88ff8a1a4107d7d43f to your computer and use it in GitHub Desktop.
For dictionaries having arrays as values, this function merges arrays of different dictionaries belonging to the same key. It *does* overwrite the first one though so beware!
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
def merge_dicts_arrs(d1, d2): | |
for k,v in d2.items(): | |
if k in d1.keys(): | |
d1[k] = d1[k] + d2[k] | |
else: | |
d1.update({k:v}) | |
return d1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment