我在Pandas的时间序列中遇到了Lomb Scargle的问题。我使用datetime索引获取数据,我想对我的数据进行Lomb Scargle转换。我的数据如下所示:
1993-01-01 NaN
1993-02-01 NaN
1993-03-01 NaN
1993-04-01 NaN
1993-05-01 NaN
1993-06-01 NaN
1993-07-01 NaN
1993-08-01 270.050000
1993-09-01 281.746667
1993-10-01 283.950000
1993-11-01 276.165385
1993-12-01 263.510345
1994-01-01 255.803226
1994-02-01 254.784091
1994-03-01 256.736207
1994-04-01 254.211667
1994-05-01 250.385000
1994-06-01 250.281667
1994-07-01 251.145161
1994-08-01 262.219355
1994-09-01 276.787037
1994-10-01 281.126667
1994-11-01 276.345000
1994-12-01 267.536207
1995-01-01 265.230000
1995-02-01 263.682692
1995-03-01 262.801724
1995-04-01 258.081034
1995-05-01 251.637500
1995-06-01 255.075000
.
.
.
2014-07-01 260.993548
2014-08-01 274.343548
2014-09-01 283.983333
2014-10-01 290.995161
2014-11-01 286.183333
我尝试了这样的代码:
import numpy as np
from astroML.time_series import lomb_scargle, search_frequencies
def lomb(data):
t = np.arange(0, len(data), 1)
dy = 0.5 + 0.5 * np.random.random(len(data))
omega = (2*np.pi)/t
PS = lomb_scargle(t, data.values, dy, omega, generalized=True)
return pd.Series(PS, index = omega)
但我想介绍一下我的时间指数,以获得一个月份在x轴上的Lomb Scargle周期图。我不确定我的omega et t变量是否正确作为输入。