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.0 โ€บ reference โ€บ generated โ€บ numpy.percentile.html
numpy.percentile โ€” NumPy v2.0 Manual
An array of weights associated with the values in a. Each value in a contributes to the percentile according to its associated weight. The weights array can either be 1-D (in which case its length must be the size of a along the given axis) or of the same shape as a.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ numpy-percentile-in-python
numpy.percentile() in python - GeeksforGeeks
June 21, 2025 - numpy.percentile() compute the q-th percentile of data along the specified axis. A percentile is a measure indicating the value below which a given percentage of observations in a group falls.
Find elsewhere
๐ŸŒ
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 ...
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 1.26 โ€บ reference โ€บ generated โ€บ numpy.percentile.html
numpy.percentile โ€” NumPy v1.26 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 ...
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ numpy โ€บ methods โ€บ percentile
NumPy percentile()
The percentile() method returns the q-th percentile(s) of the input array along the specified axis.
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ python:numpy โ€บ built-in functions โ€บ .percentile()
Python:NumPy | Built-in Functions | .percentile() | Codecademy
July 25, 2025 - The np.percentile() is a built-in method of Numpy, a statistical measure that indicates the value below which a given percentage of observations in a dataset falls.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 1.24 โ€บ reference โ€บ generated โ€บ numpy.percentile.html
numpy.percentile โ€” NumPy v1.24 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 ...