snowflake.snowpark.modin.plugin.extensions.resample_overrides.Resampler.var

Resampler.var(ddof: int = 1, numeric_only: ~typing.Union[bool, ~typing.Literal[<no_default>]] = _NoDefault.no_default, *args: ~typing.Any, **kwargs: ~typing.Any) Union[DataFrame, Series][source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/modin/plugin/extensions/resample_overrides.py#L594-L616)

Compute variance of resample bins.

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

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

  • min_count (int, default 0) – The required number of valid values to perform the operation. If fewer than min_count non-NA values are present, the result will be NA.

  • engine (str, default None) – This parameter is ignored in Snowpark pandas. The execution engine will always be Snowflake.

  • engine_kwargs (dict, default None) – This parameter is ignored in Snowpark pandas. The execution engine will always be Snowflake.

Returns:

Computed variance of values within each resample bin.

Return type:

Series or DataFrame

Examples

For Series:

>>> lst1 = pd.date_range('2020-01-01', periods=4, freq='1D')
>>> ser1 = pd.Series([1, 2, 3, 4], index=lst1)
>>> ser1
2020-01-01    1
2020-01-02    2
2020-01-03    3
2020-01-04    4
Freq: None, dtype: int64
Copy
>>> ser1.resample('2D').var()
2020-01-01    0.5
2020-01-03    0.5
Freq: None, dtype: float64
Copy
>>> lst2 = pd.date_range('2020-01-01', periods=4, freq='S')
>>> ser2 = pd.Series([1, 2, np.nan, 4], index=lst2)
>>> ser2
2020-01-01 00:00:00    1.0
2020-01-01 00:00:01    2.0
2020-01-01 00:00:02    NaN
2020-01-01 00:00:03    4.0
Freq: None, dtype: float64
Copy
>>> ser2.resample('2S').var()
2020-01-01 00:00:00    0.5
2020-01-01 00:00:02    NaN
Freq: None, dtype: float64
Copy

For DataFrame:

>>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]]
>>> df = pd.DataFrame(data,
...      columns=["a", "b", "c"],
...      index=pd.date_range('2020-01-01', periods=4, freq='1D'))
>>> df
            a  b  c
2020-01-01  1  8  2
2020-01-02  1  2  5
2020-01-03  2  5  8
2020-01-04  2  6  9
Copy
>>> df.resample('2D').var()
              a     b    c
2020-01-01  0.0  18.0  4.5
2020-01-03  0.0   0.5  0.5
Copy
Language: English