def bug_timeseries2seqs(data, timestamps, length=3, T=48):
# have a bug
if type(timestamps[0]) != pd.Timestamp:
timestamps = string2timestamp(timestamps, T=T)
offset = pd.DateOffset(minutes=24 * 60 // T)
breakpoints = [0]
for i in range(1, len(timestamps)):
if timestamps[i-1] + offset != timestamps[i]:
breakpoints.append(i)
X = []
Y = []
for b in range(1, len(breakpoints)):
print('breakpoints: ', breakpoints[b-1], breakpoints[b])
idx = range(breakpoints[b-1], breakpoints[b])
for i in range(len(idx) - 3):
x = np.vstack(data[idx[i:i+3]])
y = data[idx[i+3]]
X.append(x)
Y.append(y)
X = np.asarray(X)
Y = np.asarray(Y)
print("X shape: ", X.shape, "Y shape:", Y.shape)
return X, Y
评论列表
文章目录