-
Notifications
You must be signed in to change notification settings - Fork 353
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
tracking some ideas #347
Comments
I've used this in 5 places now, I think there's definitely a handy primitive here, although I'm not sure if I got the name quite right: def dict_zip(*dicts):
for key in set().union(*dicts):
yield tuple([key] + [d.get(key) for d in dicts]) |
Looks like a full join to me. If using the zip name, I'd prefer In terms of a motivating example for docs, anything you can share about where the dicts are coming from / going to? |
May you provide some examples for your ideas? |
a cousin of bucketize, but instead of def key_nest(dict_: dict[K, V], category: Callable[[K], K2]) -> dict[K2, dict[K, V]]:
"""Given a dict, return a dict-of-dicts split up by category(key) in the original dict"""
categorized: dict[K2, dict[K, V]] = {}
for key, val in dict_.items():
category_key = category(key)
categorized.setdefault(category_key, {})[key] = val
return categorized |
These need gardening but I'll just put them here to keep track.
But I had another take on
get_any()
here, so need to resolve that.#266
Another one is a multi-partition, where predicates cascade:
(this could be an extension of iterutils.partition to accept any number of predicates instead of just one)
The text was updated successfully, but these errors were encountered: