You are viewing documentation about an older version (1.21.0). View latest version

modin.pandas.Rolling.varΒΆ

Rolling.var(ddof: int = 1, numeric_only: bool = False, *args: Any, engine: Optional[Literal['cython', 'numba']] = None, engine_kwargs: Optional[dict[str, bool]] = None, **kwargs: Any)[source]ΒΆ

Compute the rolling var.

Parameters:
  • numeric_only (bool, default False) – Include only float, int, boolean columns.

  • ddof (int, default 1) – Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.

  • *args (tuple) – Positional arguments to pass to func.

  • engine (str, default None None) –

    • 'cython' : Runs the operation through C-extensions from cython.

    • 'numba' : Runs the operation through JIT compiled code from numba.

    • None : Defaults to 'cython' or globally setting compute.use_numba

    This parameter is ignored in Snowpark pandas. The execution engine will always be Snowflake.

  • engine_kwargs (dict, default None None) –

    • For 'cython' engine, there are no accepted engine_kwargs

    • For 'numba' engine, the engine can accept nopython, nogil

      and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}.

    This parameter is ignored in Snowpark pandas. The execution engine will always be Snowflake.

  • **kwargs (dict) – Keyword arguments to be passed into func.

Returns:

Computed rolling var of values.

Return type:

Series or DataFrame

Examples

>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
>>> df
     B
0  0.0
1  1.0
2  2.0
3  NaN
4  4.0
>>> df.rolling(2, min_periods=1).var()
     B
0  NaN
1  0.5
2  0.5
3  NaN
4  NaN
>>> df.rolling(2, min_periods=1).var(ddof=0)
      B
0  0.00
1  0.25
2  0.25
3  0.00
4  0.00
>>> df.rolling(3, min_periods=1, center=True).var()
     B
0  0.5
1  1.0
2  0.5
3  2.0
4  NaN
Copy