Data structures & formats · reviewed in July 2026
NumPy array
A NumPy array (ndarray) is a data structure that stores elements of the same type in a grid of one or more dimensions, optimized for vectorized mathematical operations. It's the foundation pandas and most of Python's scientific libraries are built on.
import numpy as np prices = np.array([10.0, 20.0, 30.0]) prices_with_tax = prices * 1.19
Frequently asked questions
How is a NumPy array different from a Python list?
A Python list can mix types and grows flexibly, but is slow for numerical work. A NumPy array requires a single data type and stores values contiguously in memory, enabling much faster mathematical operations.
What is vectorization?
It's applying an operation to the whole array at once (for example array * 2) instead of looping over each element — NumPy runs that operation in optimized low-level code, far faster than a Python for loop.
Do you use NumPy directly, or always through pandas?
Both are common: pandas is used more for labeled tabular data, and NumPy directly for pure numerical computing, linear algebra, or when performance is critical.