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]]])

def rolling_window(self, dim, window, window_dim, center=False,
                       fill_value=dtypes.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]]])
        """
        if fill_value is dtypes.NA:  # np.nan is passed
            dtype, fill_value = dtypes.maybe_promote(self.dtype)
            array = self.astype(dtype, copy=False).data
        else:
            dtype = self.dtype
            array = self.data

        new_dims = self.dims + (window_dim, )
        return Variable(new_dims, duck_array_ops.rolling_window(
            array, axis=self.get_axis_num(dim), window=window,
            center=center, fill_value=fill_value))