def handle_rolling(agg, granularity, timestamps, values, is_aggregated,
references, window):
if window > len(values):
raise exceptions.UnAggregableTimeseries(
references,
"Rolling window '%d' is greater than serie length '%d'" %
(window, len(values))
)
timestamps = timestamps[window - 1:]
values = values.T
# rigtorp.se/2011/01/01/rolling-statistics-numpy.html
shape = values.shape[:-1] + (values.shape[-1] - window + 1, window)
strides = values.strides + (values.strides[-1],)
new_values = AGG_MAP[agg](as_strided(values, shape=shape, strides=strides),
axis=-1)
return granularity, timestamps, new_values.T, is_aggregated
评论列表
文章目录