datatree.DataTree.from_dict#

classmethod DataTree.from_dict(d: MutableMapping[str, xarray.core.dataset.Dataset | xarray.core.dataarray.DataArray | datatree.datatree.DataTree | None], name: Optional[str] = None) datatree.datatree.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.