Python/pandas: sequence to series (transform a sequence so that each element of the series is a sum of sequence elements) -
i'm trying convert for-loop vector calculations. i'm not sure operation:
for in np.arange(int_lookback, len(items)): res.ix[i] = items.ix[(i - lookback):i].diff().abs().sum()
'i' for-loop iterator.
since haven't provided expected df
, i'm guessing want compute successive difference between cells, take it's absolute value , perform rolling summation window length vary depending on lookback
value.
res = items.diff().abs().rolling(window=lookback).sum()
Comments
Post a Comment