python – pandas.DataFrame.resample的高斯核密度平滑?

我正在使用pandas.DataFrame.resample将随机事件重新采样为1小时间隔,并且看到非常随机的结果,如果我将间隔增加到2或4小时,似乎不会消失.这让我想知道Pandas是否有任何类型的方法来生成平滑密度内核,如高斯核密度方法,带有可调节带宽来控制平滑.我没有在文档中看到任何内容,但我想在发布到开发人员列表服务器之前发布此处,因为这是他们的偏好. Scikit-Learn有
precisely the Gaussian kernel density function that I want,所以我会尝试使用它,但这对Pandas来说是一个很棒的补充.

任何帮助是极大的赞赏!

hourly[0][344:468].plot()

最佳答案 Pandas能够在滚动窗口上应用聚合. win_type参数控制窗口的形状.可以设置中心参数,以便将标签设置在窗口的中心,而不是右边缘.做高斯平滑:

hrly = pd.Series(hourly[0][344:468])
smooth = hrly.rolling(window=5, win_type='gaussian', center=True).mean(std=0.5)

http://pandas.pydata.org/pandas-docs/stable/computation.html#rolling

点赞