Nº20 · Analysis
NumPy
Python's numeric foundation: fast, vectorized arrays.
What is it?
NumPy introduces the ndarray (N-dimensional array), a homogeneous, memory-contiguous data structure that lets you operate on millions of numeric values without explicit Python loops. It is the foundation on which virtually the entire Python scientific stack is built: pandas, scikit-learn, SciPy, matplotlib, and TensorFlow all depend on it at their core.
What is it used for?
- Vectorized computation: apply arithmetic, logical, and aggregation operations
across full arrays in a single expression — no
forloops, orders of magnitude faster than native Python lists. - Linear algebra and statistics: matrix multiplication, SVD decomposition,
percentiles, means, correlations — all available in
numpy.linalgandnumpy.random. - Ecosystem glue: acts as the data interchange protocol between libraries
(the
__array__protocol); understanding its types (dtype) and shapes (shape) is essential for debugging issues in pandas or scikit-learn.
When to use it / when not to?
Use it when working with homogeneous numeric data: signals, images, weight matrices, simulation outputs. If you need low-level operations on raw numbers, NumPy is the right tool.
Think twice when your data is tabular with named columns of mixed types — in that case pandas or Polars provide a more expressive layer on top of NumPy without sacrificing speed. NumPy also does not replace distributed processing tools (Spark, Dask) when data does not fit in memory.
Start in 1 minute
pip install numpy
import numpy as np
# Create an array and operate on it in a vectorized way
data = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
squares = data ** 2 # [1., 4., 9., 16., 25.]
mean = data.mean() # 3.0
normalized = (data - mean) / data.std()
print(squares)
print(normalized)
Not a single for loop — every operation acts on the entire array at once.
Check the official documentation for broadcasting,
advanced indexing, and the full API reference.
Quick trivia — test what you just read.
How much do you know about NumPy?
Official documentation
The source of truth lives there. Here we orient you; the depth is up to you.
Open official docs ↗What to learn next
See alsoNº20 · Updated 2026-06-08