🍾 Xarray is now 10 years old! 🎉

xarray.DataArray.to_dataset

xarray.DataArray.to_dataset#

DataArray.to_dataset(dim=None, *, name=None, promote_attrs=False)[source]#

Convert a DataArray to a Dataset.

Parameters:
  • dim (Hashable, optional) – Name of the dimension on this array along which to split this array into separate variables. If not provided, this array is converted into a Dataset of one variable.

  • name (Hashable, optional) – Name to substitute for this array’s name. Only valid if dim is not provided.

  • promote_attrs (bool, default: False) – Set to True to shallow copy attrs of DataArray to returned Dataset.

Returns:

dataset (Dataset)