I'm curious if there is a built in function to transform an array of values into a cumulative array of values.
Example:
input = np.asarray([0.000,1.500,2.100,5.000])
into
[0.000,1.500,3.600,8.600]
Thanks!
Use in-built cumsum
from NumPy to get the cumulative sum of your array inputt
as
inputt = np.asarray([0.000,1.500,2.100,5.000])
print (np.cumsum(inputt))
# [0. 1.5 3.6 8.6]
I renamed your array because input
is already an in-built function in python to get the user input from the keyboard