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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -