pandas.core.window.rolling.Window.var #

窗户。var ( ddof = 1 , numeric_only = False , ** kwargs ) [来源] #

计算滚动加权窗口方差。

参数
numeric_only布尔值,默认 False

仅包含 float、int、boolean 列。

1.5.0 版本中的新增内容。

**夸格

用于配置加权窗口类型的关键字参数SciPy

返回
系列或数据框

返回类型与具有 dtype 的原始对象相同np.float64

也可以看看

pandas.Series.rolling

使用系列数据进行滚动调用。

pandas.DataFrame.rolling

使用 DataFrame 调用滚动。

pandas.Series.var

聚合系列的变量。

pandas.DataFrame.var

聚合 DataFrame 的 var。

例子

>>> ser = pd.Series([0, 1, 5, 2, 8])

要获取 的实例,Window我们需要传递参数win_type

>>> type(ser.rolling(2, win_type='gaussian'))
<class 'pandas.core.window.rolling.Window'>

为了使用SciPy高斯窗口,我们需要提供参数 Mstd。在我们的示例中,参数M对应于 2。我们将第二个参数std作为以下方法的参数传递:

>>> ser.rolling(2, win_type='gaussian').var(std=3)
0     NaN
1     0.5
2     8.0
3     4.5
4    18.0
dtype: float64