NumPy array (ndarray)

Applies to: python

A NumPy ndarray is a fast, fixed-type, N-dimensional array. Operations are vectorized: they apply to whole arrays at once in optimized C, far faster than Python loops. It is the foundation of scientific Python.

import numpy as np
a = np.array([1, 2, 3])
a * 2          # array([2,4,6])  (vectorized, no loop)
a.sum()        # 6

See also: array, broadcasting, slicing