Compute EWMA over sparse/irregular TimeSeries in Pandas

删除回忆录丶 提交于 2019-12-06 02:59:57

You can use reindex to align the ewma result with your original series.

pd.ewma(ts, halflife=5, freq='ms').reindex(ts.index)

2015-08-01 09:00:00.000     0.0000
2015-08-01 09:00:00.001     0.5346
2015-08-01 09:00:00.002     1.0921
2015-08-01 09:00:00.003     1.6724
2015-08-01 09:00:00.004     2.2750
2015-08-01 09:00:00.005     2.8996
2015-08-01 09:00:00.006     3.5458
2015-08-01 09:00:00.007     4.2131
2015-08-01 09:00:00.008     4.9008
2015-08-01 09:00:00.009     5.6083
2015-08-01 09:00:10.000    10.0000
2015-08-01 09:00:10.001    10.5346
2015-08-01 09:00:10.002    11.0921
2015-08-01 09:00:10.003    11.6724
2015-08-01 09:00:10.004    12.2750
2015-08-01 09:00:10.005    12.8996
2015-08-01 09:00:10.006    13.5458
2015-08-01 09:00:10.007    14.2131
2015-08-01 09:00:10.008    14.9008
2015-08-01 09:00:10.009    15.6083
dtype: float64
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!