Forgive me if this has been asked before, I couldn't find it. I am trying to progressively sum a numpy array into a new numpy array using vector operations. What I mean by this is that the 2nd index of the new array is equal to the 1st + 2nd index of the old array. or A[n] = B[0] + B[1] ... + B[n]. I know how to do this using a for loop but I'm looking for a vectorized solution.
Here is my non-vectorized solution:
import numpy as np
A = np.arange(10)
B = np.empty(10)
for i in range(len(A)):
B[i] = sum(A[0:i+1])
print(B)