Skip to main content

Import the library

Or import individual functions:

Create your first array

All creation functions accept an optional dtype parameter: np.zeros([3, 3], 'float32') or np.array([1, 2, 3], 'int32').

Basic operations

numpy-ts supports element-wise arithmetic on arrays of any shape:

Method chaining

When you import from numpy-ts (the full entry point), arrays are NDArray instances that support method chaining. This lets you write fluent, readable pipelines:
Every operation that exists as a standalone function (np.add, np.reshape, etc.) is also available as a method on NDArray.

Standalone functions (core)

If you use numpy-ts/core for tree-shaking, the same operations are available as standalone functions:
NDArrayCore returned from numpy-ts/core still has properties like .shape, .dtype, .T, and .toString(). It only lacks the chainable operation methods (.add(), .reshape(), etc.). See the Tree-Shaking guide for a full comparison.

Reductions

Reduce arrays along axes to compute statistics:

Indexing and slicing

numpy-ts uses string-based slicing to emulate NumPy’s bracket syntax:
Slicing syntax mirrors NumPy: 'start:stop:step'. Omitted values default to the full range, just like in Python.

Reshaping and manipulation

Linear algebra

Random numbers

Broadcasting

Operations automatically broadcast arrays with compatible shapes, just like NumPy:

FFT (Fast Fourier Transform)

Next steps

Array Basics

Deep dive into NDArray properties, views, and copies.

Data Types

Learn about the 13 supported dtypes including complex numbers and BigInt.

Broadcasting

Understand how operations work across arrays of different shapes.