pydata / pydata/xarray

Support nested dicts in DataTree.from_dict() and to_dict()

Open
#10,659 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

topic-DataTree
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What is your issue?

It would be nice to natively support nested data in from_dict() and to_dict(), rather only than the current "flat" format, e.g., DataTree.from_dict({'a': {'b': {'c': None}}}) instead of DataTree.from_dict({'/a/b/c': None}).

For from_dict(), we could support this by automatically expanding dictionary arguments.

For to_dict(), we could add a new argument nested=True for indicating that a nested dict of names should be returned instead of the current flat structure.

Contributor guide

Open the contributing guide

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

Start by locating the DataTree.from_dict() and to_dict() entry points and reading how they currently handle the flat format. Define the behavior for nested dictionaries and the proposed nested=True option, then verify that nested input and output work while the existing flat behavior remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.