0PricingLogin
Data Science Academy · Lesson

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()   # 12

Mean 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.0

All lessons in this course

  1. Reshape and Flatten Arrays
  2. Sum, Mean, and the Axis Trick
  3. Boolean Masks for Selection
  4. Random Numbers and Seeds
← Back to Data Science Academy