栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

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

  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



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/375813.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号