NumPy ufuncLesson 37Free preview
ufunc Summations
This lesson is part of NumPy · All levels
Summary
Np.sum sums all of the elements of the array or along a particular axis, whereas np.cumsum results in a cumulative running from each position. A similar concept applies to multiplication by np.prod and np.cumprod. The axis parameter specifies the direction of the calculation: 0 per column and 1 per line.
Key points
- Np.sum sums all the elements or along a given axis.
- Np.cumsum produces a series of cumulative running numbers.
- The parameter axis = 0 counts per column, axis = 1 per line.
- The dtype parameter can be used to make the addition of a particular type.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.