datatree.DataTree.from_dict

Attention

This repository has been archived. Please use xarray.DataTree instead.

datatree.DataTree.from_dict#

classmethod DataTree.from_dict(d: MutableMapping[str, Dataset | DataArray | DataTree | None], name: str | None = None) DataTree[source][source]#

Create a datatree from a dictionary of data objects, organised by paths into the tree.

Parameters:
  • d (dict-like) – A mapping from path names to xarray.Dataset, xarray.DataArray, or DataTree objects.

    Path names are to be given as unix-like path. If path names containing more than one part are given, new tree nodes will be constructed as necessary.

    To assign data to the root node of the tree use “/” as the path.

  • name (Hashable, optional) – Name for the root node of the tree. Default is None.

Returns:

DataTree

Notes

If your dictionary is nested you will need to flatten it before using this method.