pytoolz / pytoolz/toolz

ENH: function to split dict over an iterable

Open
#211 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
280
Avg merge
6d 17h
Merged PRs (30d)
4

Description

One thing I found I have had to do that might be useful to include is to split a dictionary on an iterable value. The user would provide a dictionary and a key. The function would then return an iterator of dictionaries, each dictionary having one value from the key. It could be called splitvalue, perhaps.

So to give an example:

>>> a = {'key1': 1, 'key2': a, 'key3': [0, 1, 2, 3]}
>>> list(dictoolz.splitvalue(a, 'key3'))
[{'key1': 1, 'key2': 'a', 'key3': 0},
{'key1': 1, 'key2': 'a', 'key3': 1},
{'key1': 1, 'key2': 'a', 'key3': 2},
{'key1': 1, 'key2': 'a', 'key3': 3}]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points; first inspect the existing dictionary utilities and their tests to find the public API and conventions. Use the supplied splitvalue example as the target behavior, clarify edge cases such as missing or non-iterable keys, and verify the relevant tests and full suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.