Aggregation means computing a single summary value, or a row/column summary, from a batch of data in an array. sum, min, max, mean, median, std are tools you'll reach for constantly in data analysis.
import numpy as np
sales = np.array([
[120, 135, 150],
[160, 155, 180]
])
print("Total sales:", sales.sum())
print("Average sales:", sales.mean())
print("Highest sale:", sales.max())
print("Column totals:", sales.sum(axis=0))
print("Row totals:", sales.sum(axis=1))sales.sum() adds up every element. axis=0 means computing column-wise, and axis=1 means computing row-wise. Understanding axis is essential whenever you need row/column summaries.
Total sales: 900 Average sales: 150.0 Highest sale: 180 Column totals: [280 290 330] Row totals: [405 495]Info
If axis is hard to remember, think of it this way: axis=0 cuts across the rows and produces a column result. axis=1 cuts across the columns and produces a row result.