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 -

python - Error: Unresolved reference 'selenium' What is the reason? -

asp.net ajax - Jquery scroll to element just goes to top of page -