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

4x4 Matrix in Python -

python - String indices must be integers and while issue -

wso2is - WSO2 IS 5.0.0 SP1 After restart there is authentication error -