xarray.NamedArray.expand_dims#
- NamedArray.expand_dims(dim=Default.token)[source]#
Expand the dimensions of the NamedArray.
This method adds new dimensions to the object. The new dimensions are added at the beginning of the array.
- Parameters:
dim (
Hashable
, optional) β Dimension name to expand the array to. This dimension will be added at the beginning of the array.- Returns:
NamedArray
β A new NamedArray with expanded dimensions.
Examples
>>> data = np.asarray([[1.0, 2.0], [3.0, 4.0]]) >>> array = xr.NamedArray(("x", "y"), data)
# expand dimensions by specifying a new dimension name >>> expanded = array.expand_dims(dim=βzβ) >>> expanded.dims (βzβ, βxβ, βyβ)