NumPy has np.percentile().

import numpy as np
a = np.array([1,2,3,4,5])
p = np.percentile(a, 50)  # return 50th percentile, i.e. median.
>>> print(p)
3.0

SciPy has scipy.stats.scoreatpercentile(), in addition to many other statistical goodies.

Answer from Jon W on Stack Overflow
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v2.2 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False, *, weights=None, interpolation=None)[source]#
🌐
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v2.0 Manual
If q is a single percentile and axis=None, then the result is a scalar. If multiple percentiles are given, first axis of the result corresponds to the percentiles. The other axes are the axes that remain after the reduction of a. If the input contains integers or floats smaller than float64, ...
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v2.5.dev0 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False, *, weights=None)[source]#
🌐
SciPy
docs.scipy.org › doc › numpy-1.9.2 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v1.9 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=False)[source]¶ · Compute the qth percentile of the data along the specified axis. Returns the qth percentile of the array elements. See also · mean, median ·
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v2.4 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False, *, weights=None)[source]#
🌐
SciPy
docs.scipy.org › doc › numpy-1.10.1 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v1.10 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=False)[source]¶ · Compute the qth percentile of the data along the specified axis. Returns the qth percentile of the array elements. See also · mean, median ·
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v2.1 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False, *, weights=None, interpolation=None)[source]#
Find elsewhere
🌐
SciPy
docs.scipy.org › doc › numpy-1.12.0 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v1.12 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=False)[source]¶ · Compute the qth percentile of the data along the specified axis. Returns the qth percentile(s) of the array elements. See also · mean, median, nanpercentile ·
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.nanpercentile.html
numpy.nanpercentile — NumPy v2.2 Manual
numpy.nanpercentile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=<no value>, *, weights=None, interpolation=None)[source]# Compute the qth percentile of the data along the specified axis, while ignoring nan values.
🌐
Jorisvandenbossche
jorisvandenbossche.github.io › numpy › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v1.18.dev0 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=False)[source]¶ · Compute the q-th percentile of the data along the specified axis. Returns the q-th percentile(s) of the array elements. Parameters · aarray_like ·
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-percentile-in-python
numpy.percentile() in python - GeeksforGeeks
June 21, 2025 - Example 2: In this example, we compute the 50th percentile (median) along each row of a 2D array using the axis parameter. ... import numpy as np a = np.array([[10, 7, 4], [3, 2, 1]]) res = np.percentile(a, 50, axis=1) print(res)
🌐
NumPy
numpy.org › doc › 1.20 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v1.20 Manual
January 31, 2021 - numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=False)[source]¶
🌐
NumPy
numpy.org › doc › 1.25 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v1.25 Manual
Given a vector V of length n, the q-th percentile of V is the value q/100 of the way from the minimum to the maximum in a sorted copy of V. The values and distances of the two nearest neighbors as well as the method parameter will determine the percentile if the normalized ranking does not ...
🌐
JAX Documentation
docs.jax.dev › en › latest › _autosummary › jax.numpy.percentile.html
jax.numpy.percentile — JAX documentation
jax.numpy.percentile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False)[source]#
🌐
SciPy
docs.scipy.org › doc › › numpy-1.8.0 › reference › generated › numpy.percentile.html
numpy.percentile — NumPy v1.8 Manual
numpy.percentile(a, q, axis=None, out=None, overwrite_input=False)[source]¶ · Compute the qth percentile of the data along the specified axis. Returns the qth percentile of the array elements. See also · mean, median · Notes · Given a vector V of length N, the qth percentile of V is the ...
🌐
Programiz
programiz.com › python-programming › numpy › methods › percentile
NumPy percentile()
Stop copy pasting code you don't actually understand ... Become a certified Python programmer. ENROLL ... Created with over a decade of experience. ... Created with over a decade of experience and thousands of feedback. ... Try Programiz PRO! ... Become a certified Python programmer. Try Programiz PRO! ... The percentile() method computes the q-th percentile of the data along the specified axis. import numpy as np # create an array array1 = np.array([0, 1, 2, 3, 4, 5, 6, 7])
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_percentile_function.htm
NumPy percentile() Function
The percentile() function performs interpolation when the desired percentile lies between two data points in the array. By default, it uses linear interpolation to estimate the result. Following is the syntax of the NumPy percentile() function −
🌐
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .percentile()
Python:NumPy | Built-in Functions | .percentile() | Codecademy
July 25, 2025 - NumPy’s .percentile() function computes the q-th percentile of data along a specified axis, making it an essential tool for statistical analysis and data exploration.