# xarray.Variable.rolling_window

`Variable.``rolling_window`(dim, window, window_dim, center=False, fill_value=<NA>)

  Make a rolling_window along dim and add a new_dim to the last place.

  Parameters:

  - dim (str) – Dimension over which to compute rolling_window
  - window (int) – Window size of the rolling
  - window_dim (str) – New name of the window dimension.
  - center (boolean. default False.) – If True, pad fill_value for both ends. Otherwise, pad in the head of the axis.
  - fill_value – value to be filled.

  Returns:

  - Variable that is a view of the original array with a added dimension of
  - size w.
  - The return dim (self.dims + (window_dim, ))
  - The return shape (self.shape + (window, ))

  Examples

      >>> v=Variable(('a', 'b'), np.arange(8).reshape((2,4)))
      >>> v.rolling_window(x, 'b', 3, 'window_dim')
      <xarray.Variable (a: 2, b: 4, window_dim: 3)>
      array([[[nan, nan, 0], [nan, 0, 1], [0, 1, 2], [1, 2, 3]],
             [[nan, nan, 4], [nan, 4, 5], [4, 5, 6], [5, 6, 7]]])

      >>> v.rolling_window(x, 'b', 3, 'window_dim', center=True)
      <xarray.Variable (a: 2, b: 4, window_dim: 3)>
      array([[[nan, 0, 1], [0, 1, 2], [1, 2, 3], [2, 3, nan]],
             [[nan, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, nan]]])