得到它了。在这个问题的帮助下,我做了以下工作:
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 importfactorial
为from scipy.misc import factorial
。