Moving window object for DataArray. You should use DataArray.rolling() method to construct this object instead of the class constructor. Parameters ---------- obj : DataArray Object to window. windows : mapping of hashable to int
(
self,
obj: DataArray,
windows: Mapping[Any, int],
min_periods: int | None = None,
center: bool | Mapping[Any, bool] = False,
)
| 262 | __slots__ = ("window_labels",) |
| 263 | |
| 264 | def __init__( |
| 265 | self, |
| 266 | obj: DataArray, |
| 267 | windows: Mapping[Any, int], |
| 268 | min_periods: int | None = None, |
| 269 | center: bool | Mapping[Any, bool] = False, |
| 270 | ) -> None: |
| 271 | """ |
| 272 | Moving window object for DataArray. |
| 273 | You should use DataArray.rolling() method to construct this object |
| 274 | instead of the class constructor. |
| 275 | |
| 276 | Parameters |
| 277 | ---------- |
| 278 | obj : DataArray |
| 279 | Object to window. |
| 280 | windows : mapping of hashable to int |
| 281 | A mapping from the name of the dimension to create the rolling |
| 282 | window along (e.g. `time`) to the size of the moving window. |
| 283 | min_periods : int, default: None |
| 284 | Minimum number of observations in window required to have a value |
| 285 | (otherwise result is NA). The default, None, is equivalent to |
| 286 | setting min_periods equal to the size of the window. |
| 287 | center : bool, default: False |
| 288 | Set the labels at the center of the window. The default, False, |
| 289 | sets the labels at the right edge of the window. |
| 290 | |
| 291 | Returns |
| 292 | ------- |
| 293 | rolling : type of input argument |
| 294 | |
| 295 | See Also |
| 296 | -------- |
| 297 | xarray.DataArray.rolling |
| 298 | xarray.DataArray.groupby |
| 299 | xarray.Dataset.rolling |
| 300 | xarray.Dataset.groupby |
| 301 | """ |
| 302 | super().__init__(obj, windows, min_periods=min_periods, center=center) |
| 303 | |
| 304 | # TODO legacy attribute |
| 305 | self.window_labels = self.obj[self.dim[0]] |
| 306 | |
| 307 | def __iter__(self) -> Iterator[tuple[DataArray, DataArray]]: |
| 308 | if self.ndim > 1: |