绘制熊猫系列数据的平滑曲线

绘制熊猫系列数据的平滑曲线,第1张

绘制熊猫系列数据的平滑曲线

得到它了。在这个问题的帮助下,我做了以下工作:

  1. tsgroup
    从几分钟到几秒重新采样。

     >>> tsres = tsgroup.resample('S')

    >>> tsres
    2014-11-08 10:30:00 3
    2014-11-08 10:30:01 NaN
    2014-11-08 10:30:02 NaN
    2014-11-08 10:30:03 NaN

    2014-11-08 10:54:58 NaN
    2014-11-08 10:54:59 NaN
    2014-11-08 10:55:00 2
    频率:S,长度:1501


  2. 使用插值数据

    .interpolate(method='cubic')
    。这会将数据传递给
    scipy.interpolate.interp1d
    使用
    cubic
    类型,因此您需要安装scipy(
    pip install scipy
    )1。

     >>> tsint = tsres.interpolate(method ='cubic')

    >>> tsint
    2014-11-08 10:30:00 3.000000
    2014-11-08 10:30:01 3.043445
    2014-11-08 10:30:02 3.085850
    2014-11-08 10:30:03 3.127220

    2014-11-08 10:54:58 2.461532
    2014-11-08 10:54:59 2.235186
    2014-11-08 10:55:00 2.000000
    频率:S,长度:1501

  3. 使用绘制

    tsint.plot()
    。这是原始版本
    tsgroup
    和的比较
    tsint

1如果由于

.interpolate(method='cubic')
告诉您即使已安装Scipy也未安装而出现错误,请打开
/usr/lib64/python2.6/site-packages/scipy/interpolate/polyint.py
文件或将文件放在任何位置,然后将第二行从更改
from scipy importfactorial
from scipy.misc import factorial



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4920314.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-12
下一篇2022-11-12

发表评论

登录后才能评论

评论列表(0条)

    保存