pandas.core.resample.Resampler.var #

最终 重采样器。var ( ddof = 1 , numeric_only = False , * args , ** kwargs ) [来源] #

计算组的方差,排除缺失值。

参数
ddof int,默认1

自由程度。

numeric_only布尔值,默认 False

仅包含floatintboolean数据。

1.5.0 版本中的新增内容。

在版本 2.0.0 中更改: numeric_only 现在默认为False.

返回
数据框或系列

每组内值的方差。

例子

>>> ser = pd.Series([1, 3, 2, 4, 3, 8],
...                 index=pd.DatetimeIndex(['2023-01-01',
...                                         '2023-01-10',
...                                         '2023-01-15',
...                                         '2023-02-01',
...                                         '2023-02-10',
...                                         '2023-02-15']))
>>> ser.resample('MS').var()
2023-01-01    1.0
2023-02-01    7.0
Freq: MS, dtype: float64
>>> ser.resample('MS').var(ddof=0)
2023-01-01    0.666667
2023-02-01    4.666667
Freq: MS, dtype: float64