NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v2.1 Manual
The - 1 in the formulas for j and g accounts for Python’s 0-based indexing. The table above includes only the estimators from H&F that are continuous functions of probability q (estimators 4-9). NumPy also provides the three discontinuous estimators from H&F (estimators 1-3), where j is defined as above, m is defined as follows, and g is a function of the real-valued index = q*n + m - 1 and j. ... For backward compatibility with previous versions of NumPy, quantile provides four additional discontinuous estimators.
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.quantile.html
pandas.Series.quantile — pandas 3.0.2 documentation
The quantile(s) to compute, which can lie in range: 0 <= q <= 1.
Videos
05:06
Python - Quantiles and Quartiles - YouTube
13:26
Python - Quantiles and Quartiles (core) - YouTube
11:24
Understanding Quantiles in Python: A Step-by-Step Guide (Numpy ...
03:46
NumPy Quantile Tutorial: Calculate Quantiles in Arrays with ...
03:45
What is statistics.quantiles function in python | How to use ...
06:22
Quantile in Python (4 Examples) | Calculate Quartile, Decile & ...
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.quantile.html
pandas.DataFrame.quantile — pandas 3.0.1 documentation
Value between 0 <= q <= 1, the quantile(s) to compute.
Educative
educative.io › answers › what-is-the-statistics-quantiles-method-in-python
What is the statistics quantiles() method in Python?
The statistics.quantiles() method in Python is used to return the quantiles that correspond to the numbers n contained in the iterable containing data.
scikit-learn
scikit-learn.org › stable › auto_examples › linear_model › plot_quantile_regression.html
Quantile regression — scikit-learn 1.8.0 documentation
Download Jupyter notebook: plot_quantile_regression.ipynb · Download Python source code: plot_quantile_regression.py
Top answer 1 of 4
23
Not a ready-made function but a compact and reasonably fast snippet:
(a<value).mean()
You can (at least on my machine) squeeze out a few percent better performance by using np.count_nonzero
np.count_nonzero(a<value) / a.size
but tbh I wouldn't even bother.
2 of 4
11
There's a convenience function that does this. Note that it's not an exact inverse because the quantile/percentile functions are not exact. Given a finite array of observations, the percentiles will have discrete values; in other words, you may be specifying a q that falls between those values and the functions find the closest one.
from scipy import stats
import numpy as np
stats.percentileofscore(np.arange(0,1,0.12), .65, 'weak') / 100
SciPy
docs.scipy.org › doc › scipy › reference › generated › scipy.stats.quantile.html
quantile — SciPy v1.17.0 Manual
While numpy.quantile can only compute quantiles according to the Cartesian product of the first two arguments, this function enables calculation of quantiles at different probabilities for each axis slice by following broadcasting rules like those of scipy.stats reducing functions.
CodeSignal
codesignal.com › learn › courses › descriptive-and-inferential-statistics-with-python › lessons › exploring-quantiles-and-the-interquartile-range-with-python
Exploring Quantiles and the Interquartile Range with Python
Python's NumPy function, percentile(), calculates quantiles.
W3Schools
w3schools.com › python › pandas › ref_df_quantile.asp
Pandas DataFrame quantile() Method
The quantile() method calculates the quantile of the values in a given axis.
Kaggle
kaggle.com › code › aungdev › np-percentile-vs-np-quantile
np.percentile() vs. np.quantile()
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .quantile()
Python:NumPy | Built-in Functions | .quantile() | Codecademy
April 19, 2025 - The .quantile() function returns the qth quantile(s) of an array as a NumPy array (ndarray) or a scalar (float64) if the result is a single value.
Programiz
programiz.com › python-programming › numpy › methods › quantile
NumPy quantile()
In NumPy, the quantile() function computes the q-th quantile of data along the specified axis.
SciPy
docs.scipy.org › doc › scipy-1.16.1 › reference › generated › scipy.stats.quantile.html
quantile — SciPy v1.16.1 Manual
The -1 in the formulas for j and g accounts for Python’s 0-based indexing. The table above includes only the estimators from [1] that are continuous functions of probability p (estimators 4-9). SciPy also provides the three discontinuous estimators from [1] (estimators 1-3), where j is defined as above, m is defined as follows, and g is 0 when index = p*n + m - 1 is less than 0 and otherwise is defined below. ... A different strategy for computing quantiles from [2], method='harrell-davis', uses a weighted combination of all elements.