gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:47:40 25 4
gpt4 key购买 nike

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

非常感谢任何帮助!

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

enter image description here

最佳答案

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

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

关于python - pandas.DataFrame.resample 的高斯核密度平滑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27099555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com