NumPy

2.4.3 · active · verified Wed Mar 25

Fundamental package for numerical computing in Python. Current version is 2.4.3 (Mar 2026). NumPy 2.0 (Jun 2024) was a landmark major release with ABI breakage, ~100 removed namespace members, and type promotion changes (NEP 50). Packages built against NumPy 1.x will not import with NumPy 2.x.

Warnings

Install

Imports

Quickstart

Basic array creation and operations. Use new random Generator API.

import numpy as np

# Array creation
arr = np.array([1, 2, 3, 4], dtype=np.float64)
matrix = np.zeros((3, 4), dtype=np.float32)

# Operations
result = arr * 2 + 1
dot = np.dot(matrix.T, matrix)

# Random (new API)
rng = np.random.default_rng(seed=42)
samples = rng.standard_normal((100, 10))

# Type check
print(arr.dtype)   # float64
print(arr.shape)   # (4,)

view raw JSON →