Cumulative Operations
cumsum and cumprod give running totals. diff gives differences between neighbours.
Example
import numpy as np
a = np.array([1, 2, 3, 4])
print(np.cumsum(a), np.cumprod(a))
print(np.diff([1, 4, 9, 16]))Result
[ 1 3 6 10] [ 1 2 6 24] [3 5 7]
Exercise
Running total.
np.(a)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.