Suppose i have list of numbers [3, 51, 34]. I want to add to each element the sum of the previous elements and return a new list with these new values. So here the
[3, 51, 34]
numpy.cumsum might be good choice for something like this.
numpy.cumsum
In [1]: import numpy as np In [2]: a = [3,51,34] In [3]: np.cumsum(a) Out[3]: array([ 3, 54, 88])