Powerful N-dimensional arrays

Fast and versatile, the NumPy vectorization, indexing, and broadcasting concepts are the de-facto standards of array computing today.

Numerical computing tools

NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more.

Interoperable

NumPy supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.

Performant

The core of NumPy is well-optimized C code. Enjoy the flexibility of Python with the speed of compiled code.

Easy to use

NumPy’s high level syntax makes it accessible and productive for programmers from any background or experience level.

Open source

Distributed under a liberal BSD license, NumPy is developed and maintained publicly on GitHub by a vibrant, responsive, and diverse community.

Try NumPy

```
"""
To try the examples in the browser:
1. Type code in the input cell and press
Shift + Enter to execute
2. Or copy paste the code, and click on
the "Run" button in the toolbar
"""
# The standard way to import NumPy:
import numpy as np
# Create a 2-D array, set every second element in
# some rows and find max per row:
x = np.arange(15, dtype=np.int64).reshape(3, 5)
x[1:, ::2] = -99
x
# array([[ 0, 1, 2, 3, 4],
# [-99, 6, -99, 8, -99],
# [-99, 11, -99, 13, -99]])
x.max(axis=1)
# array([ 4, 8, 13])
# Generate normally distributed random numbers:
rng = np.random.default_rng()
samples = rng.normal(size=2500)
samples
```

Nearly every scientist working in Python draws on the power of NumPy.

NumPy brings the computational power of languages like C and Fortran to Python, a language much easier to learn and use. With this power comes simplicity: a solution in NumPy is often clear and elegant.

Quantum Computing Statistical Computing Signal Processing Image Processing Graphs and Networks Astronomy Processes Cognitive Psychology QuTiP Pandas SciPy Scikit-image NetworkX AstroPy PsychoPy PyQuil statsmodels PyWavelets OpenCV graph-tool SunPy Qiskit Xarray python-control Mahotas igraph SpacePy PennyLane Seaborn PyGSP Bioinformatics Bayesian Inference Mathematical Analysis Chemistry Geoscience Geographic Processing Architecture & Engineering BioPython PyStan SciPy Cantera Pangeo Shapely COMPAS Scikit-Bio PyMC3 SymPy MDAnalysis Simpeg GeoPandas City Energy Analyst PyEnsembl ArviZ cvxpy RDKit ObsPy Folium Sverchok ETE emcee FEniCS Fatiando a Terra NumPy's API is the starting point when libraries are written to exploit innovative hardware, create specialized array types, or add capabilities beyond what NumPy provides.

Array Library Capabilities & Application areas Dask Distributed arrays and advanced parallelism for analytics, enabling performance at scale. CuPy NumPy-compatible array library for GPU-accelerated computing with Python. JAX Composable transformations of NumPy programs: differentiate, vectorize, just-in-time compilation to GPU/TPU. Xarray Labeled, indexed multi-dimensional arrays for advanced analytics and visualization Sparse NumPy-compatible sparse array library that integrates with Dask and SciPy's sparse linear algebra. PyTorch Deep learning framework that accelerates the path from research prototyping to production deployment. TensorFlow An end-to-end platform for machine learning to easily build and deploy ML powered applications. MXNet Deep learning framework suited for flexible research prototyping and production. Arrow A cross-language development platform for columnar in-memory data and analytics. xtensor Multi-dimensional arrays with broadcasting and lazy computing for numerical analysis. XND Develop libraries for array computing, recreating NumPy's foundational concepts. uarray Python backend system that decouples API from implementation; unumpy provides a NumPy API. tensorly Tensor learning, algebra and backends to seamlessly use NumPy, MXNet, PyTorch, TensorFlow or CuPy. NumPy lies at the core of a rich ecosystem of data science libraries. A typical exploratory data science workflow might look like:

**Extract, Transform, Load:**Pandas, Intake, PyJanitor**Exploratory analysis:**Jupyter, Seaborn, Matplotlib, Altair**Model and evaluate:**scikit-learn, statsmodels, PyMC3, spaCy**Report in a dashboard:**Dash, Panel, Voila

NumPy forms the basis of powerful machine learning libraries like scikit-learn and SciPy. As machine learning grows, so does the list of libraries built on NumPy. TensorFlow’s deep learning capabilities have broad applications — among them speech and image recognition, text-based applications, time-series analysis, and video detection. PyTorch, another deep learning library, is popular among researchers in computer vision and natural language processing. MXNet is another AI package, providing blueprints and templates for deep learning.

NumPy is an essential component in the burgeoning Python visualization landscape, which includes Matplotlib, Seaborn, Plotly, Altair, Bokeh, Holoviz, Vispy, Napari, and PyVista, to name a few.

NumPy’s accelerated processing of large arrays allows researchers to visualize datasets far larger than native Python could handle.

First Image of a Black Hole

How NumPy, together with libraries like SciPy and Matplotlib that depend on NumPy, enabled the Event Horizon Telescope to produce the first ever image of a black hole

Detection of Gravitational Waves

In 1916, Albert Einstein predicted gravitational waves; 100 years later their existence was confirmed by LIGO scientists using NumPy.

Sports Analytics

Cricket Analytics is changing the game by improving player and team performance through statistical modelling and predictive analytics. NumPy enables many of these analyses.

Pose Estimation using deep learning

DeepLabCut uses NumPy for accelerating scientific studies that involve observing animal behavior for better understanding of motor control, across species and timescales.