Skip to content
Learn Netverks

Lesson

Step 15/36 42% through track

aggregations

Aggregations

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Aggregations: NumPy ndarray operations, vectorization, and numerical patterns used across the Python scientific stack.

Teams apply Aggregations in every serious NumPy project—skipping it leaves blind spots in analysis and reviews.

You will apply Aggregations in contexts like: Notebooks, feature engineering pipelines, and custom numerical code.

Read the narrative, run `import numpy as np` snippets in the playground (install NumPy with pip if the runner lacks it), tweak shapes and dtypes, and complete MCQs.

When you can explain the previous lesson's ideas in your own words.

Aggregation functions collapse values to statistics: sum, mean, min, max, std, var, argmin, argmax, and percentile.

Method vs function

Both work: arr.mean() and np.mean(arr). Methods are convenient; functions accept axis, dtype, and out parameters uniformly.

Multi-axis aggregation

import numpy as np
a = np.arange(24).reshape(2, 3, 4)
print(a.mean(axis=(1, 2)))  # one mean per outer slice

NaN-aware variants

np.nanmean, np.nansum ignore NaN—essential for real-world missing sensor readings (see NaN lesson).

Important interview questions and answers

  1. Q: argmax?
    A: Index of maximum element—useful for classification predicted class.
  2. Q: std vs var?
    A: Variance is squared deviation; std is square root of variance (same units as data).

Self-check

  1. Find index of minimum value in 1D array.
  2. Which function ignores NaN in mean?

Tip: Use nanmean when missing values appear in real data.

Interview prep

argmax?

Index of maximum—classification predicted class index.

nanmean?

Mean skipping NaN values.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • np.mean vs average?
  • Weighted mean?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump