Sum, Mean, and the Axis Trick
Aggregating down rows or across columns.
Summaries in One Call
NumPy can collapse a whole array into a single number. Methods like sum and mean turn many values into one quick summary.
a = np.array([2, 4, 6])
total = a.sum() # 12Mean Is the Average
The mean divides the total by the count. For the array above it returns 4.0, the everyday average you already know.
avg = a.mean() # 4.0All lessons in this course
- Reshape and Flatten Arrays
- Sum, Mean, and the Axis Trick
- Boolean Masks for Selection
- Random Numbers and Seeds