CINXE.COM
NumPy -
<!doctype html><html lang=en data-colorscheme=light><head><meta name=generator content="Hugo 0.134.3"><meta name=description content="Why NumPy? Powerful n-dimensional arrays. Numerical computing tools. Interoperable. Performant. Open source."><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta http-equiv=x-ua-compatible content="ie=edge"><title>NumPy - </title><link rel=icon href=/images/favicon.ico><link rel=stylesheet type=text/css href=/theme-css/sphinx-design/index.scss.min.36ff85d5815ecbee58c1ba27bcc5efe301092254f8ab00f2f53a72e4222d58ee.css integrity="sha256-Nv+F1YFey+5YwbonvMXv4wEJIlT4qwDy9Tpy5CItWO4="><link rel=stylesheet type=text/css href=/theme-css/pst/bootstrap.scss.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css integrity="sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="><link rel=stylesheet type=text/css href=/theme-css/pst/pydata-sphinx-theme.scss.min.d56da9e1c2ce262f021256dca409e85bd992cb0994a6aaf1b4fe85d6074447c5.css integrity="sha256-1W2p4cLOJi8CElbcpAnoW9mSywmUpqrxtP6F1gdER8U="><link rel=stylesheet type=text/css href=/theme-css/spht/index.scss.min.ad03de1683bb39a0d1b31395797b97188e59cda6d778c0671a99db0b4fb799a9.css integrity="sha256-rQPeFoO7OaDRsxOVeXuXGI5ZzabXeMBnGpnbC0+3mak="><link rel=stylesheet type=text/css href=/css/tabs.scss.min.549aba196cc14bca7747a312ff35df0aa1f486b740c19ee0c88aaa721fb8c2e1.css integrity="sha256-VJq6GWzBS8p3R6MS/zXfCqH0hrdAwZ7gyIqqch+4wuE="><link rel=stylesheet href=/theme-css/backtotop.min.b5f58df56ca9d2f2b749b8d5eb4ab2b5a1724c63cbd24b2f8a0b0c2268e1eca4.css integrity="sha256-tfWN9Wyp0vK3SbjV60qytaFyTGPL0ksvigsMImjh7KQ="><link rel=stylesheet href=/theme-css/bulma.min.f488b160722c9b7a2a760c03808dc8df5173e6c9dd25cb7481451ddb3c4f35dc.css integrity="sha256-9IixYHIsm3oqdgwDgI3I31Fz5sndJct0gUUd2zxPNdw="><link rel=stylesheet href=/theme-css/code-highlight.min.d0bd96ff1dbeb4b62536da5935b92af5cd7edb6d6f52b316d721e62078d9f089.css integrity="sha256-0L2W/x2+tLYlNtpZNbkq9c1+221vUrMW1yHmIHjZ8Ik="><link rel=stylesheet href=/theme-css/content.min.1de9b096ffc099fee4b538589fea6b622be33d69de64c451e11f2c91476029c5.css integrity="sha256-Hemwlv/Amf7ktThYn+prYivjPWneZMRR4R8skUdgKcU="><link rel=stylesheet href=/theme-css/dark-mode.min.1a7d04742ddf658331233b701507a0124657cbf45e02c672c061955181de6dde.css integrity="sha256-Gn0EdC3fZYMxIztwFQegEkZXy/ReAsZywGGVUYHebd4="><link rel=stylesheet href=/theme-css/footer.min.4be63c4d5628cb485efcfa5c9475fa1daa18933eb83741a2ca2bcd444ec270a2.css integrity="sha256-S+Y8TVYoy0he/PpclHX6HaoYkz64N0GiyivNRE7CcKI="><link rel=stylesheet href=/theme-css/hero.min.aa8286fd7d31d78e297e71594436c47b17d4f28660fd16f2b252e3f55fa500be.css integrity="sha256-qoKG/X0x144pfnFZRDbEexfU8oZg/RbyslLj9V+lAL4="><link rel=stylesheet href=/theme-css/lists.min.83821789384ebadc1a1ff75ef9f4b29ba53fe45eb30a46a228aa55772a393396.css integrity="sha256-g4IXiThOutwaH/de+fSym6U/5F6zCkaiKKpVdyo5M5Y="><link rel=stylesheet href=/theme-css/navbar.min.c15f7eadb5a7e1532309c04d94e1b0099d4fa75aaded30829bbfd21ebdb51ad5.css integrity="sha256-wV9+rbWn4VMjCcBNlOGwCZ1Pp1qt7TCCm7/SHr21GtU="><link rel=stylesheet href=/theme-css/news.min.8875ffae62ae22741a27025581fcb3341c18442be06bf132e45f8d6027692876.css integrity="sha256-iHX/rmKuInQaJwJVgfyzNBwYRCvga/Ey5F+NYCdpKHY="><link rel=stylesheet href=/theme-css/posts.min.9505f87d5973f3f08c99c613c0781b3a42411f4795657e8da7ef29c7ad37c23d.css integrity="sha256-lQX4fVlz8/CMmcYTwHgbOkJBH0eVZX6Np+8px603wj0="><link rel=stylesheet href=/theme-css/search.min.ee3423de82ad5535fd375aa47bc4fe618ecaa5d10eb0b68fe6dfc85a78790676.css integrity="sha256-7jQj3oKtVTX9N1qke8T+YY7KpdEOsLaP5t/IWnh5BnY="><link rel=stylesheet href=/theme-css/shortcuts.min.f90addf0a2a3c4e075eb5c3c78e4cc27d9b4fba18a02a17808695212762224c1.css integrity="sha256-+Qrd8KKjxOB161w8eOTMJ9m0+6GKAqF4CGlSEnYiJME="><link rel=stylesheet href=/theme-css/styles.min.00c75e5e25cb21123ca151cb4f4a130891157870829d91cefa425316ecf23de2.css integrity="sha256-AMdeXiXLIRI8oVHLT0oTCJEVeHCCnZHO+kJTFuzyPeI="><link rel=stylesheet href=/theme-css/tables.min.7a44b6bd698323dd3d379b714bd534132e76bf4ba0d3dec61997a8d9ba9db5fb.css integrity="sha256-ekS2vWmDI909N5txS9U0Ey52v0ug097GGZeo2bqdtfs="><link rel=stylesheet href=/theme-css/tabs.min.8884c317231b5f2331b2fd9f65e4f7900fe9124aafae93b78cef175960289683.css integrity="sha256-iITDFyMbXyMxsv2fZeT3kA/pEkqvrpO3jO8XWWAoloM="><link rel=stylesheet href=/theme-css/vars.min.3d537d14ea6e6fb59012fa9d357adf4b209dab8c2535fb94ab37afb6a37020fd.css integrity="sha256-PVN9FOpub7WQEvqdNXrfSyCdq4wlNfuUqzevtqNwIP0="><link rel=stylesheet href=/theme-css/videos.min.41c135abe8361308f9258975985342fc3107ddc6440698251dd72e2b909cdaaa.css integrity="sha256-QcE1q+g2Ewj5JYl1mFNC/DEH3cZEBpglHdcuK5Cc2qo="><link rel=stylesheet href=/css/casestudies.min.92b0bafc1e58181b02c23f14b861767269e505eadc85a123b4eb79e2527bf2e0.css integrity="sha256-krC6/B5YGBsCwj8UuGF2cmnlBerchaEjtOt54lJ78uA="><link rel=stylesheet href=/css/custom.min.cf0f0187caa046832f55197d09d0ad54a98eebc7758bbb354fb1c8fb8541b5bb.css integrity="sha256-zw8Bh8qgRoMvVRl9CdCtVKmO68d1i7s1T7HI+4VBtbs="><link rel=stylesheet href=/css/mailchimp.min.96f403ea4c8be10747beb4c33a219da2fa8234a3b98882983bd2569da8eeb9e1.css integrity="sha256-lvQD6kyL4QdHvrTDOiGdovqCNKO5iIKYO9JWnajuueE="><link rel=stylesheet href=/css/shell.min.173478d133f6f5990705f3ed2f48714422de15754d813df6aa2a047bf62a51da.css integrity="sha256-FzR40TP29ZkHBfPtL0hxRCLeFXVNgT32qioEe/YqUdo="><script src=https://code.jquery.com/jquery-3.7.1.min.js></script><link rel=alternate hreflang=pt href=/pt/ title=Português><link rel=alternate hreflang=ja href=/ja/ title="日本語 (Japanese)"><link rel=alternate hreflang=es href=/es/ title=Español><meta name=twitter:card content="summary_large_image"><meta name=twitter:image content="https://numpy.org/images/numpy-image.jpg"><meta name=twitter:title content="NumPy"><meta name=twitter:description content=" 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. Open source Distributed under a liberal BSD license, NumPy is developed and maintained publicly on GitHub by a vibrant, responsive, and diverse community. 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. "></head><body><nav id=nav class=navbar role=navigation aria-label="main navigation"><div class=container><div class=navbar-brand><a role=button class=navbar-burger aria-label=menu aria-expanded=false data-target=navbar-menu><span aria-hidden=true></span> <span aria-hidden=true></span> <span aria-hidden=true></span></a></div><div id=navbar-menu class=navbar-menu><div class=navbar-end><a href=/install class=navbar-item>Install </a><a href=https://numpy.org/doc/stable class=navbar-item>Documentation </a><a href=/learn class=navbar-item>Learn </a><a href=/community class=navbar-item>Community </a><a href=/about class=navbar-item>About Us </a><a href=/news class=navbar-item>News </a><a href=/contribute class=navbar-item>Contribute</a><div class="navbar-item has-dropdown"><a aria-label="Select language" class=navbar-link>English</a><div class=navbar-dropdown><a href=/pt/ class=navbar-item>Português </a><a href=/ja/ class=navbar-item>日本語 (Japanese) </a><a href=/es/ class=navbar-item>Español</a></div></div></div></div></div></nav><section class=hero><div class=hero-container><div class=hero-content><div class=hero-title-content><div class=hero-title>NumPy <img class=hero-logo src=/images/logo.svg alt="NumPy logo. "></div><div class=flex-column><div class=hero-subtitle>The fundamental package for scientific computing with Python</div><div class=hero-cta><a href=/news/#releases><button class=cta-button>Latest release: NumPy 2.0. View all releases</button></a></div></div></div></div></div></section><div class=news-container><div class=news-title><a href=/news>NumPy 2.1 released!</a></div><div class=news-date><a href=/news>2024-08-18</a></div></div><section class=content-padding><div class=content-container><div class="sd-container-fluid sd-mb-4 false"><div class="sd-row sd-row-cols-1 sd-row-cols-xs-1 sd-row-cols-sm-2 sd-row-cols-md-2 sd-row-cols-lg-3 sd-g-2 sd-g-xs-1 sd-g-sm-2 sd-g-md-2 sd-g-lg-3"><div class="sd-col sd-d-flex-row"><div class="sd-card sd-w-100 sd-shadow-sm"><div class=sd-card-body><div class="sd-card-title sd-font-weight-bold">Powerful N-dimensional arrays</div>Fast and versatile, the NumPy vectorization, indexing, and broadcasting concepts are the de-facto standards of array computing today.</div></div></div><div class="sd-col sd-d-flex-row"><div class="sd-card sd-w-100 sd-shadow-sm"><div class=sd-card-body><div class="sd-card-title sd-font-weight-bold">Numerical computing tools</div>NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more.</div></div></div><div class="sd-col sd-d-flex-row"><div class="sd-card sd-w-100 sd-shadow-sm"><div class=sd-card-body><div class="sd-card-title sd-font-weight-bold">Open source</div>Distributed under a liberal <a href=https://github.com/numpy/numpy/blob/main/LICENSE.txt>BSD license</a>, NumPy is developed and maintained <a href=https://github.com/numpy/numpy>publicly on GitHub</a> by a vibrant, responsive, and diverse <a href=/community/>community</a>.</div></div></div><div class="sd-col sd-d-flex-row"><div class="sd-card sd-w-100 sd-shadow-sm"><div class=sd-card-body><div class="sd-card-title sd-font-weight-bold">Interoperable</div>NumPy supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.</div></div></div><div class="sd-col sd-d-flex-row"><div class="sd-card sd-w-100 sd-shadow-sm"><div class=sd-card-body><div class="sd-card-title sd-font-weight-bold">Performant</div>The core of NumPy is well-optimized C code. Enjoy the flexibility of Python with the speed of compiled code.</div></div></div><div class="sd-col sd-d-flex-row"><div class="sd-card sd-w-100 sd-shadow-sm"><div class=sd-card-body><div class="sd-card-title sd-font-weight-bold">Easy to use</div>NumPy’s high level syntax makes it accessible and productive for programmers from any background or experience level.</div></div></div></div></div></div></section><div class=hero-right><div class="flex-column shell-title-container"><div class=shell-title>Try NumPy</div><div class=shell-content-message><p>Use the interactive shell to try NumPy in the browser</p></div></div><div class=numpy-shell-canvas><div class=numpy-shell-container><div class="shell-lesson shell-content"><div class=highlight><pre class=chroma><code><span style=display:flex><span><span style=color:#e6db74>""" </span></span></span><span style=display:flex><span><span style=color:#e6db74>To try the examples in the browser: </span></span></span><span style=display:flex><span><span style=color:#e6db74>1. Type code in the input cell and press </span></span></span><span style=display:flex><span><span style=color:#e6db74> Shift + Enter to execute </span></span></span><span style=display:flex><span><span style=color:#e6db74>2. Or copy paste the code, and click on </span></span></span><span style=display:flex><span><span style=color:#e6db74> the "Run" button in the toolbar </span></span></span><span style=display:flex><span><span style=color:#e6db74>"""</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#75715e># The standard way to import NumPy:</span> </span></span><span style=display:flex><span><span style=color:#f92672>import</span> numpy <span style=color:#66d9ef>as</span> np </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#75715e># Create a 2-D array, set every second element in</span> </span></span><span style=display:flex><span><span style=color:#75715e># some rows and find max per row:</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span>x <span style=color:#f92672>=</span> np<span style=color:#f92672>.</span>arange(<span style=color:#ae81ff>15</span>, dtype<span style=color:#f92672>=</span>np<span style=color:#f92672>.</span>int64)<span style=color:#f92672>.</span>reshape(<span style=color:#ae81ff>3</span>, <span style=color:#ae81ff>5</span>) </span></span><span style=display:flex><span>x[<span style=color:#ae81ff>1</span>:, ::<span style=color:#ae81ff>2</span>] <span style=color:#f92672>=</span> <span style=color:#f92672>-</span><span style=color:#ae81ff>99</span> </span></span><span style=display:flex><span>x </span></span><span style=display:flex><span><span style=color:#75715e># array([[ 0, 1, 2, 3, 4],</span> </span></span><span style=display:flex><span><span style=color:#75715e># [-99, 6, -99, 8, -99],</span> </span></span><span style=display:flex><span><span style=color:#75715e># [-99, 11, -99, 13, -99]])</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span>x<span style=color:#f92672>.</span>max(axis<span style=color:#f92672>=</span><span style=color:#ae81ff>1</span>) </span></span><span style=display:flex><span><span style=color:#75715e># array([ 4, 8, 13])</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#75715e># Generate normally distributed random numbers:</span> </span></span><span style=display:flex><span>rng <span style=color:#f92672>=</span> np<span style=color:#f92672>.</span>random<span style=color:#f92672>.</span>default_rng() </span></span><span style=display:flex><span>samples <span style=color:#f92672>=</span> rng<span style=color:#f92672>.</span>normal(size<span style=color:#f92672>=</span><span style=color:#ae81ff>2500</span>) </span></span><span style=display:flex><span>samples</span></span></code></pre></div></div><iframe class=numpy-shell src="https://jupyterlite.github.io/demo/repl/?toolbar=1&kernel=python&code=import%20numpy%20as%20np"></iframe></div></div></div><section class=tabs-section><div class=container><h1 class=tabs-title>ECOSYSTEM</h1><div class=tabs><div role=tablist class=automatic><button id=0-tab-0 type=button role=tab aria-selected=true aria-controls=0-tabpanel-0> Scientific Domains </button> <button id=0-tab-1 type=button role=tab aria-selected=false aria-controls=0-tabpanel-1> Array Libraries </button> <button id=0-tab-2 type=button role=tab aria-selected=false aria-controls=0-tabpanel-2> Data Science </button> <button id=0-tab-3 type=button role=tab aria-selected=false aria-controls=0-tabpanel-3> Machine Learning </button> <button id=0-tab-4 type=button role=tab aria-selected=false aria-controls=0-tabpanel-4> Visualization</button></div><div id=0-tabpanel-0 role=tabpanel tabindex=0 aria-labelledby=$0-tab-0><section class="scientific-domains container"><p>Nearly every scientist working in Python draws on the power of NumPy.</p><p>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.</p><ul><li><header>Quantum Computing</header><ul><img src=/images/content_images/sc_dom_img/quantum_computing.svg alt="A computer chip."><li><a href=http://qutip.org>QuTiP</a></li><li><a href=https://pyquil-docs.rigetti.com/en/stable>PyQuil</a></li><li><a href=https://qiskit.org>Qiskit</a></li><li><a href=https://pennylane.ai>PennyLane</a></li></ul></li><li><header>Statistical Computing</header><ul><img src=/images/content_images/sc_dom_img/statistical_computing.svg alt="A line graph with the line moving up."><li><a href=https://pandas.pydata.org/>Pandas</a></li><li><a href=https://www.statsmodels.org/>statsmodels</a></li><li><a href=https://xarray.pydata.org/en/stable/>Xarray</a></li><li><a href=https://seaborn.pydata.org/>Seaborn</a></li></ul></li><li><header>Signal Processing</header><ul><img src=/images/content_images/sc_dom_img/signal_processing.svg alt="A bar chart with positive and negative values."><li><a href=https://www.scipy.org/>SciPy</a></li><li><a href=https://pywavelets.readthedocs.io/>PyWavelets</a></li><li><a href=https://python-control.org/>python-control</a></li><li><a href=https://hyperspy.org/>HyperSpy</a></li></ul></li><li><header>Image Processing</header><ul><img src=/images/content_images/sc_dom_img/image_processing.svg alt="An photograph of the mountains."><li><a href=https://scikit-image.org/>Scikit-image</a></li><li><a href=https://opencv.org/>OpenCV</a></li><li><a href=https://mahotas.rtfd.io/>Mahotas</a></li></ul></li><li><header>Graphs and Networks</header><ul><img src=/images/content_images/sc_dom_img/sd6.svg alt="A simple graph."><li><a href=https://networkx.org/>NetworkX</a></li><li><a href=https://graph-tool.skewed.de/>graph-tool</a></li><li><a href=https://igraph.org/python/>igraph</a></li><li><a href=https://pygsp.rtfd.io/>PyGSP</a></li></ul></li><li><header>Astronomy</header><ul><img src=/images/content_images/sc_dom_img/astronomy_processes.svg alt="A telescope."><li><a href=https://www.astropy.org/>AstroPy</a></li><li><a href=https://sunpy.org/>SunPy</a></li><li><a href=https://spacepy.github.io/>SpacePy</a></li></ul></li><li><header>Cognitive Psychology</header><ul><img src=/images/content_images/sc_dom_img/cognitive_psychology.svg alt="A human head with gears."><li><a href=https://www.psychopy.org/>PsychoPy</a></li></ul></li><li><header>Bioinformatics</header><ul><img src=/images/content_images/sc_dom_img/bioinformatics.svg alt="A strand of DNA."><li><a href=https://biopython.org/>BioPython</a></li><li><a href=http://scikit-bio.org/>Scikit-Bio</a></li><li><a href=https://github.com/openvax/pyensembl>PyEnsembl</a></li><li><a href=http://etetoolkit.org/>ETE</a></li></ul></li><li><header>Bayesian Inference</header><ul><img src=/images/content_images/sc_dom_img/bayesian_inference.svg alt="A graph with a bell-shaped curve."><li><a href=https://pystan.readthedocs.io/en/latest/>PyStan</a></li><li><a href=https://docs.pymc.io/>PyMC3</a></li><li><a href=https://arviz-devs.github.io/arviz/>ArviZ</a></li><li><a href=https://emcee.readthedocs.io/>emcee</a></li></ul></li><li><header>Mathematical Analysis</header><ul><img src=/images/content_images/sc_dom_img/mathematical_analysis.svg alt="Four mathematical symbols."><li><a href=https://www.scipy.org/>SciPy</a></li><li><a href=https://www.sympy.org/>SymPy</a></li><li><a href=https://www.cvxpy.org/>cvxpy</a></li><li><a href=https://fenicsproject.org/>FEniCS</a></li></ul></li><li><header>Chemistry</header><ul><img src=/images/content_images/sc_dom_img/chemistry.svg alt="A test tube."><li><a href=https://cantera.org/>Cantera</a></li><li><a href=https://www.mdanalysis.org/>MDAnalysis</a></li><li><a href=https://github.com/rdkit/rdkit>RDKit</a></li><li><a href=https://www.pybamm.org/>PyBaMM</a></li></ul></li><li><header>Geoscience</header><ul><img src=/images/content_images/sc_dom_img/geoscience.svg alt="The Earth."><li><a href=https://pangeo.io/>Pangeo</a></li><li><a href=https://simpeg.xyz/>Simpeg</a></li><li><a href=https://github.com/obspy/obspy/wiki>ObsPy</a></li><li><a href=https://www.fatiando.org/>Fatiando a Terra</a></li></ul></li><li><header>Geographic Processing</header><ul><img src=/images/content_images/sc_dom_img/GIS.svg alt="A map."><li><a href=https://shapely.readthedocs.io/>Shapely</a></li><li><a href=https://geopandas.org/>GeoPandas</a></li><li><a href=https://python-visualization.github.io/folium>Folium</a></li></ul></li><li><header>Architecture & Engineering</header><ul><img src=/images/content_images/sc_dom_img/robotics.svg alt="A microprocessor development board."><li><a href=https://compas.dev/>COMPAS</a></li><li><a href=https://cityenergyanalyst.com/>City Energy Analyst</a></li><li><a href=https://nortikin.github.io/sverchok/>Sverchok</a></li></ul></li></ul></section></div><div id=0-tabpanel-1 role=tabpanel tabindex=0 aria-labelledby=$0-tab-1><section class=array-libraries><p>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.</p><table><tr class=highlight-th><td class=bold-text></td><td class=bold-text>Array Library</td><td class=bold-text>Capabilities & Application areas</td></td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/dask.png alt=Dask></td><td class=full-center-text><a href=https://dask.org/>Dask</a></td><td class=left-text>Distributed arrays and advanced parallelism for analytics, enabling performance at scale.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/cupy.png alt=CuPy></td><td class=full-center-text><a href=https://cupy.dev>CuPy</a></td><td class=left-text>NumPy-compatible array library for GPU-accelerated computing with Python.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/jax_logo_250px.png alt=JAX></td><td class=full-center-text><a href=https://jax.readthedocs.io/>JAX</a></td><td class=left-text>Composable transformations of NumPy programs: differentiate, vectorize, just-in-time compilation to GPU/TPU.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/xarray.png alt=xarray></td><td class=full-center-text><a href=https://xarray.pydata.org/en/stable/index.html>Xarray</a></td><td class=left-text>Labeled, indexed multi-dimensional arrays for advanced analytics and visualization.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/sparse.png alt=sparse></td><td class=full-center-text><a href=https://sparse.pydata.org/en/latest/>Sparse</a></td><td class=left-text>NumPy-compatible sparse array library that integrates with Dask and SciPy's sparse linear algebra.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/pytorch-logo-dark.svg alt=PyTorch></td><td class=full-center-text><a href=https://pytorch.org/>PyTorch</a></td><td class=left-text>Deep learning framework that accelerates the path from research prototyping to production deployment.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/tensorflow-logo.svg alt=TensorFlow></td><td class=full-center-text><a href=https://www.tensorflow.org>TensorFlow</a></td><td class=left-text>An end-to-end platform for machine learning to easily build and deploy ML powered applications.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/arrow.png alt=arrow></td><td class=full-center-text><a href=https://arrow.apache.org/>Arrow</a></td><td class=left-text>A cross-language development platform for columnar in-memory data and analytics.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/xtensor.png alt=xtensor></td><td class=full-center-text><a href=https://github.com/xtensor-stack/xtensor-python>xtensor</a></td><td class=left-text>Multi-dimensional arrays with broadcasting and lazy computing for numerical analysis.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/awkward.svg alt=awkward></td><td class=full-center-text><a href=https://awkward-array.org/>Awkward Array</a></td><td class=left-text>Manipulate JSON-like data with NumPy-like idioms.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/uarray.png alt=uarray></td><td class=full-center-text><a href=https://uarray.org/en/latest/>uarray</a></td><td class=left-text>Python backend system that decouples API from implementation; unumpy provides a NumPy API.</td></tr><tr><td style=text-align:center><img class=first-column-layout src=/images/content_images/arlib/tensorly.png alt=tensorly></td><td class=full-center-text><a href=http://tensorly.org/stable/home.html>tensorly</a></td><td class=left-text>Tensor learning, algebra and backends to seamlessly use NumPy, PyTorch, TensorFlow or CuPy.</td></tr></table></section></div><div id=0-tabpanel-2 role=tabpanel tabindex=0 aria-labelledby=$0-tab-2><section class=data-science><div class=grid-container><div><a href=/images/content_images/ds-landscape.png target=_blank><img src=/images/content_images/ds-landscape.png alt="Diagram of Python Libraries. The five catagories are 'Extract, Transform, Load', 'Data Exploration', 'Data Modeling', 'Data Evaluation' and 'Data Presentation'." align=left></a></div><div><p>NumPy lies at the core of a rich ecosystem of data science libraries. A typical exploratory data science workflow might look like:<ul class=content-tab><li><b>Extract, Transform, Load: </b><a href=https://pandas.pydata.org>Pandas</a>, <a href=https://intake.readthedocs.io>Intake</a>, <a href=https://pyjanitor-devs.github.io/pyjanitor/>PyJanitor</a></li><li><b>Exploratory analysis: </b><a href=https://jupyter.org>Jupyter</a>, <a href=https://seaborn.pydata.org>Seaborn</a>, <a href=https://matplotlib.org>Matplotlib</a>, <a href=https://altair-viz.github.io>Altair</a></li><li><b>Model and evaluate: </b><a href=https://scikit-learn.org>scikit-learn</a>, <a href=https://www.statsmodels.org/stable/index.html>statsmodels</a>, <a href=https://docs.pymc.io>PyMC3</a>, <a href=https://spacy.io>spaCy</a></li><li><b>Report in a dashboard: </b><a href=https://plotly.com/dash>Dash</a>, <a href=https://panel.holoviz.org>Panel</a>, <a href=https://voila.readthedocs.io/>Voila</a></li></ul></p></div></div><div class=grid-container><div><p></p><p>For high data volumes, <a href=https://dask.org>Dask</a> and <a href=https://ray.io/>Ray</a> are designed to scale. Stable deployments rely on data versioning (<a href=https://dvc.org>DVC</a>), experiment tracking (<a href=https://mlflow.org>MLFlow</a>), and workflow automation (<a href=https://airflow.apache.org>Airflow</a>, <a href=https://dagster.io>Dagster</a> and <a href=https://www.prefect.io>Prefect</a>).</p></p></div><div><img src=/images/content_images/data-science.png alt="Diagram of three overlapping circles. The circles are labeled 'Mathematics', 'Computer Science' and 'Domain Expertise'. In the middle of the diagram, which has the three circles overlapping it, is an area labeled 'Data Science'." align=centre width=75%></a></div></div></section></div><div id=0-tabpanel-3 role=tabpanel tabindex=0 aria-labelledby=$0-tab-3><section class=machine-learning><div class=grid-container><div class=animation-holder><a href=https://ai.googleblog.com/2016/12/open-sourcing-embedding-projector-tool.html><img src=/images/content_images/ml_img/tensorflow-ml-anim.gif alt="An animated gif showing a three-dimensional graph of embeddings made in Tensorflow." align=middle class=animation-img></a><p><i style=font-size:80%><a href=https://ai.googleblog.com/2016/12/open-sourcing-embedding-projector-tool.html>Source: Google AI Blog</a></i></p></div><div><p>NumPy forms the basis of powerful machine learning libraries like <a href=https://scikit-learn.org>scikit-learn</a> and <a href=https://www.scipy.org>SciPy</a>. As machine learning grows, so does the list of libraries built on NumPy. <a href=https://www.tensorflow.org>TensorFlow’s</a> deep learning capabilities have broad applications — among them speech and image recognition, text-based applications, time-series analysis, and video detection. <a href=https://pytorch.org>PyTorch</a>, another deep learning library, is popular among researchers in computer vision and natural language processing.</p></div></div><div><div><p>Statistical techniques called <a href=https://towardsdatascience.com/ensemble-methods-bagging-boosting-and-stacking-c9214a10a205>ensemble</a> methods such as binning, bagging, stacking, and boosting are among the ML algorithms implemented by tools such as <a href=https://xgboost.readthedocs.io/>XGBoost</a>, <a href=https://lightgbm.readthedocs.io/en/latest/>LightGBM</a>, and <a href=https://catboost.ai>CatBoost</a> — one of the fastest inference engines. <a href=https://www.scikit-yb.org/en/latest/>Yellowbrick</a> and <a href=https://eli5.readthedocs.io/en/latest/>Eli5</a> offer machine learning visualizations.</p></div></div></section></div><div id=0-tabpanel-4 role=tabpanel tabindex=0 aria-labelledby=$0-tab-4><section class=visualization><div class=grid-container><div class=visualization-images><div class=image-grid><div><a href=https://www.fusioncharts.com/blog/best-python-data-visualization-libraries><img src=/images/content_images/v_matplotlib.png alt="A streamplot made in matplotlib" align=middle></a></div><div><a href=https://github.com/yhat/ggpy><img src=/images/content_images/v_ggpy.png alt="A scatter-plot graph made in ggpy" align=middle></a></div><div><a href=https://www.journaldev.com/19692/python-plotly-tutorial><img src=/images/content_images/v_plotly.png alt="A box-plot made in plotly" align=middle></a></div><div><a href=https://altair-viz.github.io/gallery/streamgraph.html><img src=/images/content_images/v_altair.png alt="A streamgraph made in altair" align=middle></a></div><div><a href=https://seaborn.pydata.org><img src=/images/content_images/v_seaborn.png alt='A pairplot of two types of graph, a plot-graph and a frequency graph made in seaborn"' align=middle></a></div><div><a href=https://docs.pyvista.org/><img src=/images/content_images/v_pyvista.png alt="A 3D volume rendering made in PyVista." align=middle></a></div><div><a href=https://napari.org><img src=/images/content_images/v_napari.png alt="A multi-dimensionan image made in napari." align=middle></a></div><div><a href=https://vispy.org/gallery/index.html><img src=/images/content_images/v_vispy.png alt="A Voronoi diagram made in vispy." align=middle></a></div></div></div><div><p>NumPy is an essential component in the burgeoning <a href=https://pyviz.org/overviews/index.html>Python visualization landscape</a>, which includes <a href=https://matplotlib.org>Matplotlib</a>, <a href=https://seaborn.pydata.org>Seaborn</a>, <a href=https://plot.ly>Plotly</a>, <a href=https://altair-viz.github.io>Altair</a>, <a href=https://docs.bokeh.org/en/latest/>Bokeh</a>, <a href=https://holoviz.org>Holoviz</a>, <a href=http://vispy.org>Vispy</a>, <a href=https://napari.org/>Napari</a>, and <a href=https://docs.pyvista.org/>PyVista</a>, to name a few.</p><p>NumPy’s accelerated processing of large arrays allows researchers to visualize datasets far larger than native Python could handle.</p></div><div></div></div></section></div></div></div></section><section class=casestudies><div class=container><h1 class=casestudies-title>CASE STUDIES</h1><div class=casestudies-box-container><a class="casestudies-box-content casestudies-underline" href=/case-studies/blackhole-image><div class=casestudies-box-title>First Image of a Black Hole</div><img src=/images/content_images/case_studies/blackhole.png alt="First image of a black hole. It is an orange circle in a black background."><div class=casestudies-box-text>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</div></a><a class="casestudies-box-content casestudies-underline" href=/case-studies/gw-discov><div class=casestudies-box-title>Detection of Gravitational Waves</div><img src=/images/content_images/case_studies/gravitional.png alt="Two orbs orbiting each other. They are displacing gravity around them."><div class=casestudies-box-text>In 1916, Albert Einstein predicted gravitational waves; 100 years later their existence was confirmed by LIGO scientists using NumPy.</div></a><a class="casestudies-box-content casestudies-underline" href=/case-studies/cricket-analytics><div class=casestudies-box-title>Sports Analytics</div><img src=/images/content_images/case_studies/sports.jpg alt="Cricket ball on green field."><div class=casestudies-box-text>Cricket Analytics is changing the game by improving player and team performance through statistical modelling and predictive analytics. NumPy enables many of these analyses.</div></a><a class="casestudies-box-content casestudies-underline" href=/case-studies/deeplabcut-dnn><div class=casestudies-box-title>Pose Estimation using deep learning</div><img src=/images/content_images/case_studies/deeplabcut.png alt="Cheetah pose analysis"><div class=casestudies-box-text>DeepLabCut uses NumPy for accelerating scientific studies that involve observing animal behavior for better understanding of motor control, across species and timescales.</div></a></div></div></section><div id=backtotop><a href=# id=backtotop-color><i class="fa-solid fa-arrow-up"></i></a></div><footer id=footer><div class=container><div id=footer-columns><div id=footer-logo-column><img id=footer-logo src=/images/logo.svg alt="NumPy logo. "></div><div class=footer-column><div class=footer-item><a href=/install>Install</a></div><div class=footer-item><a href=https://numpy.org/doc/stable>Documentation</a></div><div class=footer-item><a href=/learn>Learn</a></div><div class=footer-item><a href=/citing-numpy>Citing Numpy</a></div><div class=footer-item><a href=https://numpy.org/neps/roadmap.html>Roadmap</a></div></div><div class=footer-column><div class=footer-item><a href=/about>About us</a></div><div class=footer-item><a href=/community>Community</a></div><div class=footer-item><a href=/user-surveys>User surveys</a></div><div class=footer-item><a href=/contribute>Contribute</a></div><div class=footer-item><a href=/code-of-conduct>Code of conduct</a></div></div><div class=footer-column><div class=footer-item><a href=/gethelp>Get help</a></div><div class=footer-item><a href=/terms>Terms of use</a></div><div class=footer-item><a href=/privacy>Privacy</a></div><div class=footer-item><a href=/press-kit>Press kit</a></div></div><div class=footer-actions>Sign up for the latest NumPy news, resources, and more<form action="https://numpy.us4.list-manage.com/subscribe/post?u=5ddd0d1d6e807900a8212481a&id=287fa4253c" method=post id=mc-embedded-subscribe-form name=mc-embedded-subscribe-form class="validate sign-up-container" target=_blank novalidate><div class=sign-up-image><svg class="icon mail-icon" viewBox="0 0 24 24" viewBox="0 0 24 24"><path d="M22 6c0-1.1-.9-2-2-2H4c-1.1.0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1.0 2-.9 2-2V6zm-2 0-8 5-8-5h16zm0 12H4V8l8 5 8-5v10z"/></svg></div><input type=email name=EMAIL class="required email sign-up-input" id=mce-EMAIL aria-label="Input for email, press enter to submit" onkeypress='(event.which===13||event.keyCode===13||event.key==="Enter")&&sendThankYou()'><div class=submission-instructions>Press Enter</div><button class=signup-button onclick=sendThankYou() aria-label=Submit><svg class="icon sent-icon" viewBox="0 0 24 24" viewBox="0 0 24 24"><path d="M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"/></svg></button><div id=mce-responses class=clear><div class=response id=mce-error-response style=display:none></div><div class=response id=mce-success-response style=display:none></div></div><div style=position:absolute;left:-5000px aria-hidden=true><input type=text name=b_5ddd0d1d6e807900a8212481a_287fa4253c tabindex=-1></div><div class=clear><input type=submit value=Subscribe name=subscribe id=mc-embedded-subscribe class=button style=display:none></div></form><div class=thank-you>Thank you! 🎉</div><div class=community-icons><a href=https://github.com/numpy/numpy aria-label=https://github.com/numpy/numpy><svg class="icon github-icon" viewBox="0 0 24 24" viewBox="0 0 24 24"><path d="M12 .297c-6.63.0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577.0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93.0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176.0.0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22.0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22.0 1.606-.015 2.896-.015 3.286.0.315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg> </a><a href=https://www.youtube.com/channel/UCguIL9NZ7ybWK5WQ53qbHng aria-label=https://www.youtube.com/channel/UCguIL9NZ7ybWK5WQ53qbHng><svg class="icon youtube-icon" viewBox="0 0 24 24" viewBox="0 0 24 24"><path d="M23.498 6.186A3.016 3.016.0 0021.376 4.05C19.505 3.545 12 3.545 12 3.545s-7.505.0-9.377.505A3.017 3.017.0 00.502 6.186C0 8.07.0 12 0 12s0 3.93.502 5.814a3.016 3.016.0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505.0 9.377-.505a3.015 3.015.0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg></a></div><div class=copyright>© 2024 NumPy team. All rights reserved.</div></div></div></div></footer></body><link rel=stylesheet href=https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin=anonymous referrerpolicy=no-referrer><link rel=stylesheet href=https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin=anonymous referrerpolicy=no-referrer><script type=text/javascript src=/js/bundle.min.js></script><script type=text/javascript>setupShortcuts(maxLevel=2)</script><script defer data-domain=numpy.org src=https://views.scientific-python.org/js/script.js></script></html>