python - Pandas、SciPy 或 NumPy 是否提供累积标准差函数?

标签 python numpy pandas scipy

我有一个 Pandas 系列。我需要获取 sigma_i,它是索引为 i 的系列的标准差。是否存在可以有效计算该值的现有函数?

我注意到有 cummaxcummin 函数。

最佳答案

参见pandas.expanding_std

例如:

import numpy as np
import matplotlib.pyplot as plt
import pandas
%matplotlib inline

data = pandas.Series(np.random.normal(size=37))

full_std = np.std(data)
expand_std = pandas.expanding_std(data, min_periods=1)

fig, ax = plt.subplots()
expand_std.plot(ax=ax, color='k', linewidth=1.5, label='Expanded Std. Dev.')
ax.axhline(y=full_std, color='g', label='Full Value')
ax.legend()

Enter image description here

关于python - Pandas、SciPy 或 NumPy 是否提供累积标准差函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24369663/

相关文章:

python - 在 python 中绘制轨道轨迹

python - Pandas:使用 groupby 计算添加标志

Pandas 和 AWS Lambda

python - 是否可以对分块数据使用 DictVectorizer?

python - Django、django oscar 和 digital ocean

python - 如何在 Pandas 中选择某些列索引(连续的和单独的)

python - Python 中使用 json.dumps 时出现 KeyError

python - 如何(自动)配置存储库/项目脚手架 Azure DevOps/GitHub?

numpy - TypeError : can't convert np. numpy.object_ 类型的 ndarray

python - 矩阵索引,为每一行提取不同的列