Python 3.x 如何计算滚动修剪方差/标准差?

Python 3.x 如何计算滚动修剪方差/标准差?,python-3.x,pandas,trim,variance,rolling-computation,Python 3.x,Pandas,Trim,Variance,Rolling Computation,我想计算标准偏差(最好)或滚动平均值的方差。更准确地说,我希望有一个滚动窗口,删除底部和顶部百分位,并计算标准偏差 到目前为止,我只成功地使用了一个for循环,它集成了许多连续的窗口,但速度太慢了。我想有一行这样的意思: window_length = 10 percentile = 0.1 df.rolling(window_length).apply(lambda x: trim_mean(x, percentile)) 查看@fuglede的答案-可能会有帮助

我想计算标准偏差(最好)或滚动平均值的方差。更准确地说,我希望有一个滚动窗口,删除底部和顶部百分位,并计算标准偏差

到目前为止,我只成功地使用了一个for循环,它集成了许多连续的窗口,但速度太慢了。我想有一行这样的意思:

window_length = 10
percentile = 0.1
df.rolling(window_length).apply(lambda x: trim_mean(x, percentile))
查看@fuglede的答案-可能会有帮助