NumPy
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
NumPy is the array library that the rest of the Python scientific stack builds on: pandas, SciPy, scikit-learn and
Matplotlib all store and exchange their numbers as NumPy arrays. This sub-section is a practical reference to the
library, from the first ndarray to memory layout, threading and the C API. It belongs to the
Data Science section, which also holds the pandas and scikit-learn sub-sections, and a
condensed summary of the commands most used day to day is on the
NumPy part of the cheat sheet.
Version baseline
Every page targets NumPy 2.5, and the facts were checked against the official documentation in October 2026. Examples target Python 3.13 or 3.14 and were run on Python 3.13. NumPy 2.5 itself needs Python 3.12 or later. Code written for NumPy 1.x often needs small changes; the Migrating to NumPy 2.x page lists them, and What’s New in NumPy 2.1 to 2.5 follows the releases one by one.
How to read this sub-section
-
New to NumPy: read The Absolute Basics of NumPy, then array creation, basic indexing, broadcasting and reductions, in that order.
-
Coming from NumPy 1.x: start with Migrating to NumPy 2.x, Type Promotion (NEP 50) and Strings, Bytes and StringDType.
-
Chasing speed or surprising results: the memory layout, copies and views, floating-point and threading pages explain most of them.
Concept-to-page map
Getting started
| Page | Concept |
|---|---|
Installing with pip, uv or conda, checking the version, release cadence and supported Python versions. |
|
A first tour of the |
|
Release-by-release changes, deprecations and the upcoming 2.6. |
|
Renamed and removed names, behaviour changes and how to adapt older code. |
Creating arrays and choosing types
| Page | Concept |
|---|---|
|
|
|
|
The dtype system, sizes, casting and character codes. |
|
How operands of different types are combined under the NumPy 2 rules. |
|
Text in arrays, fixed-width strings and the variable-width |
|
Dates, timestamps, units and time deltas. |
|
Record-like dtypes with named fields. |
|
Arrays with missing or invalid entries. |
Selecting, reshaping and combining
| Page | Concept |
|---|---|
Integer indices, slices, |
|
Integer-array and boolean selection, assignment and result shapes. |
|
When an operation shares memory and when it copies. |
|
|
|
Sorting, |
|
|
Computing
| Page | Concept |
|---|---|
Element-wise functions, |
|
The shape-matching rules for operations on arrays of different shapes. |
|
|
|
Descriptive statistics, correlation and histograms. |
|
Matrix products, decompositions, solvers and the |
|
The |
|
The |
|
Overflow, underflow, invalid values and how to control the warnings. |
Random numbers
| Page | Concept |
|---|---|
|
|
Seeds, |
Input, output and display
| Page | Concept |
|---|---|
|
|
Print options, formatting and string conversion. |
Internals, performance and interoperability
| Page | Concept |
|---|---|
C and Fortran order, strides and contiguity. |
|
Thread safety, free-threaded builds and speed. |
|
Array protocols, |
|
Writing code that runs on several array libraries. |
|
Type annotations for arrays and dtypes. |
|
Extending NumPy with compiled code. |
Related material on this site
The Statistics & Histograms page covers the array-level functions, while Statistics Fundamentals explains the underlying ideas. The pandas sub-section builds on arrays through labelled data structures, and the scikit-learn sub-section expects NumPy arrays as its input format.
See also Math for ML: Linear Algebra, Calculus & Probability, NumPy & DLPack Interop and NumPy Interop & tf.experimental.numpy in the ML (Machine Learning) section.
NumPy sources
-
NumPy manual (user guide and reference)
-
NumPy Enhancement Proposals (NEP 50, NEP 55 and NEP 56 are used on several pages)
Bibliography
All official links were opened on 2026-10-30.
NumPy and Python
-
NumPy News — https://numpy.org/news/
-
Install NumPy — https://numpy.org/install/
-
NumPy manual — https://numpy.org/doc/stable/
-
Release notes — https://numpy.org/doc/stable/release.html and https://numpy.org/devdocs/release.html
-
NumPy 2.0 migration guide — https://numpy.org/doc/stable/numpy_2_0_migration_guide.html
-
NumPy Enhancement Proposals (NEP 50, 55, 56) — https://numpy.org/neps/
-
Scientific Python — https://scientific-python.org/ and SPEC 0 — https://scientific-python.org/specs/spec-0000/
-
Python Packaging User Guide — https://packaging.python.org/en/latest/tutorials/installing-packages/
-
PEP 790 — https://peps.python.org/pep-0790/
-
conda — https://docs.conda.io/projects/conda/en/latest/ and conda-forge — https://conda-forge.org/download/
-
Miniforge — https://github.com/conda-forge/miniforge
-
SciPy — https://scipy.org/
-
Matplotlib — https://matplotlib.org/stable/
-
xarray — https://xarray.dev/
-
Apache Arrow — https://arrow.apache.org/
-
PyTorch — https://pytorch.org/
-
NIST/SEMATECH e-Handbook of Statistical Methods — https://www.itl.nist.gov/div898/handbook/
Open references
-
Python Data Science Handbook — https://github.com/jakevdp/PythonDataScienceHandbook
-
Computational and Inferential Thinking — https://inferentialthinking.com/
-
The Turing Way — https://book.the-turing-way.org/
Books
Books are linked to the publisher’s page. They were used only to decide which topics to cover, and no text or figure is reproduced.
-
Wes McKinney, Python for Data Analysis, 2nd ed., O’Reilly, 2017 — https://www.oreilly.com/library/view/python-for-data/9781491957653/ (3rd ed., open access: https://wesmckinney.com/book/)
-
Laura Igual and Santi Seguí, Introduction to Data Science, Springer, 2017 — https://link.springer.com/book/10.1007/978-3-319-50017-1
-
Steven S. Skiena, The Data Science Design Manual, Springer, 2017 — https://link.springer.com/book/10.1007/978-3-319-55444-0
-
John Hunt, Advanced Guide to Python 3 Programming, Springer, 2019 — https://link.springer.com/book/10.1007/978-3-030-25943-3
-
Aurélien Géron, Hands-On Machine Learning with Scikit-Learn and PyTorch, O’Reilly, 2025 — https://www.oreilly.com/library/view/-/9798341607972/
-
Stephen Marsland, Machine Learning: An Algorithmic Perspective, 2nd ed., CRC Press, 2015 — https://www.routledge.com/Machine-Learning-An-Algorithmic-Perspective-Second-Edition/Marsland/p/book/9781466583283