NumPy’s module structure — NumPy v2.6.dev0 Manual

NumPy has a large number of submodules. Most regular usage of NumPy requires only the main namespace and a smaller set of submodules. The rest either have special-purpose or niche namespaces.

Main namespaces

#

Regular/recommended user-facing namespaces for general use:

numpy

numpy.exceptions

numpy.fft

numpy.linalg

numpy.polynomial

numpy.random

numpy.strings

numpy.testing

numpy.typing

Special-purpose namespaces

#

numpy.ctypeslib

- interacting with NumPy objects with

ctypes

numpy.dtypes

- dtype classes (typically not used directly by end users)

numpy.emath

- mathematical functions with automatic domain

numpy.lib

- utilities & functionality which do not fit the main namespace

numpy.rec

- record arrays (largely superseded by dataframe libraries)

numpy.version

- small module with more detailed version info

Legacy namespaces

#

Prefer not to use these namespaces for new code. There are better alternatives and/or this code is deprecated or isn’t reliable.

numpy.char

- legacy string functionality, only for fixed-width strings

numpy.f2py

- Fortran binding generation (usually used from the command line only)

numpy.ma

- masked arrays (not very reliable, needs an overhaul)

numpy.matlib

(pending deprecation) - functions supporting matrix instances