MCPcopy Index your code
hub / github.com/pydata/xarray / expand_dims

Method expand_dims

xarray/namedarray/core.py:1123–1159  ·  view source on GitHub ↗

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 dimens

(
        self,
        dim: _Dim | Default = _default,
    )

Source from the content-addressed store, hash-verified

1121 return self._new(data=data, dims=ordered_dims)
1122
1123 def expand_dims(
1124 self,
1125 dim: _Dim | Default = _default,
1126 ) -> NamedArray[Any, _DType_co]:
1127 """
1128 Expand the dimensions of the NamedArray.
1129
1130 This method adds new dimensions to the object. The new dimensions are added at the beginning of the array.
1131
1132 Parameters
1133 ----------
1134 dim : Hashable, optional
1135 Dimension name to expand the array to. This dimension will be added at the beginning of the array.
1136
1137 Returns
1138 -------
1139 NamedArray
1140 A new NamedArray with expanded dimensions.
1141
1142
1143 Examples
1144 --------
1145
1146 >>> data = np.asarray([[1.0, 2.0], [3.0, 4.0]])
1147 >>> array = xr.NamedArray(("x", "y"), data)
1148
1149
1150 # expand dimensions by specifying a new dimension name
1151 >>> expanded = array.expand_dims(dim="z")
1152 >>> expanded.dims
1153 ('z', 'x', 'y')
1154
1155 """
1156
1157 from xarray.namedarray._array_api import expand_dims
1158
1159 return expand_dims(self, dim=dim)
1160
1161
1162_NamedArray = NamedArray[Any, np.dtype[_ScalarType_co]]

Callers 1

expand_dimsFunction · 0.45

Calls 1

expand_dimsFunction · 0.90

Tested by

no test coverage detected