# xarray.DataTree.assign

#### DataTree.assign(items=None, \*\*items_kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/datatree.py#L1167-L1207)

Assign new data variables or child nodes to a DataTree, returning a new object
with all the original items in addition to the new ones.

* **Parameters:**
  * **items** ([mapping](https://docs.python.org/3/glossary.html#term-mapping) of [hashable](../user-guide/terminology.html.md#term-name) to `Any`) – Mapping from variable or child node names to the new values. If the new values
    are callable, they are computed on the Dataset and assigned to new
    data variables. If the values are not callable, (e.g. a DataTree, DataArray,
    scalar, or array), they are simply assigned.
  * **\*\*items_kwargs** – The keyword arguments form of `variables`.
    One of variables or variables_kwargs must be provided.
* **Returns:**
  **dt** ([`DataTree`](xarray.DataTree.html.md#xarray.DataTree)) – A new DataTree with the new variables or children in addition to all the
  existing items.

### Notes

Since `kwargs` is a dictionary, the order of your arguments may not
be preserved, and so the order of the new variables is not well-defined.
Assigning multiple items within the same `assign` is
possible, but you cannot reference other variables created within the
same `assign` call.

#### SEE ALSO
[`xarray.Dataset.assign`](xarray.Dataset.assign.html.md#xarray.Dataset.assign), [`pandas.DataFrame.assign`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.assign.html#pandas.DataFrame.assign)
