-
Notifications
You must be signed in to change notification settings - Fork 266
Consider adding a zipdict()
function
#291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
zipdict()
fnctionzipdict()
function
Interesting suggestion. If you knew the keys in the dict are identical, one could simply do: >>> import toolz
>>> da = {'a': 1, 'b': 2, 'c': 3}
>>> db = {'a': 4, 'b': 5, 'c': 6}
>>> toolz.merge_with(tuple, da, db)
{'a': (1, 4), 'c': (3, 6), 'b': (2, 5)} If the keys aren't identical, then the operation seems weird to me. Should you only include the intersection of keys, use a default for missing values, or make this an option? Should this be left for the user to spell out explicitly using My inclination would be to have |
Typically the keys partly overlap; but actually it shouldn't matter.
I had also given thought on that. |
Any progress on that? |
ping?? |
This is interesting. |
Please consider adding a
zipdict()
function that mimics thezip()
function but on dictionaries This utility allows to iterate the items(key,value)
of a list of dictionaries based on their common keys.The necessity for such a function is described in this SO question: http://stackoverflow.com/questions/16458340/python-equivalent-of-zip-for-dictionaries
A starting implementation would be based on @Volatilty's suggestion in the above question:
The text was updated successfully, but these errors were encountered: