Aggregations
sum, mean, min, max, std and var summarise an array. Pass axis to summarise rows or columns.
Example
import numpy as np
m = np.array([[1, 2, 3], [4, 5, 6]])
print(m.sum(), m.mean(), m.max())
print(m.sum(axis=0))
print(m.sum(axis=1))Result
21 3.5 6 [5 7 9] [ 6 15]
Exercise
Sum each column.
m.sum(axis=)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.