Overwriting An Array In Numpy Function Python
I am trying to write a numpy function that iterates with itself to update the values of its function. If for example Random_numb was equal to [50, 74, 5, 69, 50]. So the calculatio
Solution 1:
IIUC you're looking for prod
:
import numpy as np
Starting_val = 10
Random_numb = np.array([50, 74, 5, 69, 50])
Random_numb.prod(initial=Starting_val)
#638250000
If you're interested in the multiplied values of the array it'll be cumprod
:
Starting_val * Random_numb.cumprod()
# array([ 500, 37000, 185000, 12765000, 638250000])
Post a Comment for "Overwriting An Array In Numpy Function Python"