您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

绘制pandas系列数据的平滑曲线

绘制pandas系列数据的平滑曲线

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

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

使用插值数据.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

使用绘制它tsint.plot()。这是原始版本tsgroup和的比较tsint

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

其他 2022/1/1 18:25:03 有521人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶