滚动窗口似乎向滚动数据引入偏移

滚动窗口似乎向滚动数据引入偏移

本文介绍了 pandas 滚动窗口似乎向滚动数据引入偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用熊猫rolling_window函数(窗口类型不是boxcar-最好是hamming)平滑"定期采样的30秒时间序列数据.但是,到目前为止,我尝试应用的所有窗口(从2到100的不同窗口长度)似乎都将平滑后的数据偏移为较低的值,例如:

I am looking to 'smooth' regularly-sampled 30-sec time series data using the pandas rolling_window function, with a window type other than boxcar - ideally hamming. However, so far all windows which I have tried to apply, over varying window lengths from 2 to 100, appear to offset the smoothed data to lower values, e.g.:

原始数据(浅蓝色)和数据通过pd.rolling_window(data,2,'hamming')运行.

Plot of raw data (light blue) and data run through pd.rolling_window(data,2,'hamming').

很明显,偏移量随时间变化.

Clearly, the quantity of offset varies through time.

这个结果不是我期望的-而是,我希望过滤后的数据集位于原始数据集的顶部.

This result isn't what I would expect - rather, I'd expect the filtered dataset to sit atop the raw one.

任何关于这里可能发生的情况的解释都是很好的.

Any explanations of what might be happening here would be great.

推荐答案

尝试对滚动窗口使用center=True参数.

Try the center=True argument to rolling_window.

这篇关于 pandas 滚动窗口似乎向滚动数据引入偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 00:44