Created
January 19, 2018 15:50
-
-
Save mnebuerquo/09587fb8cba781bfeb95f0323fe775b8 to your computer and use it in GitHub Desktop.
code I ripped off from someone on stack overflow
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
# https://stackoverflow.com/a/19647596/5114 | |
def flatten_dict(dd, separator='_', prefix=''): | |
return { prefix + separator + k if prefix else k : v | |
for kk, vv in dd.items() | |
for k, v in flatten_dict(vv, separator, kk).items() | |
} if isinstance(dd, dict) else { prefix : dd } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment