quantile-python
raw JSON → 1.1 verified Fri May 01 auth: no python
Python Implementation of Graham Cormode and S. Muthukrishnan's Effective Computation of Biased Quantiles over Data Streams in ICDE'05. Version 1.1 is the latest stable release. The library has a low release cadence with no recent updates; it provides an efficient algorithm for computing biased quantiles over data streams.
pip install quantile-python Common errors
error ModuleNotFoundError: No module named 'quantile-python' ↓
cause Importing the package using hyphens instead of underscores.
fix
Use 'import quantile_python' instead of 'import quantile-python'.
error AttributeError: module 'quantile_python' has no attribute 'QuantileEstimator' ↓
cause Misspelled class name (e.g., quantileestimator) or wrong import style.
fix
Use 'from quantile_python import QuantileEstimator'.
Warnings
gotcha The import path uses underscores (quantile_python), not hyphens. Importing with hyphens (quantile-python) will raise ModuleNotFoundError. ↓
fix Use 'from quantile_python import QuantileEstimator'.
gotcha The epsilon parameter controls the memory-accuracy tradeoff; very small epsilon (e.g., 0.0001) may cause excessive memory usage or slow insertions. ↓
fix Start with epsilon=0.01 or higher for large streams.
deprecated The library has not been updated since 1.1 (released ~2022). It depends on Python standard libraries only but may not support newer Python versions if breaking changes occur. ↓
fix Test with your Python version; consider switching to alternative libraries like tdigest if compatibility issues arise.
Imports
- QuantileEstimator
from quantile_python import QuantileEstimator - StreamSummary
from quantile_python import StreamSummary
Quickstart
from quantile_python import QuantileEstimator
# Create an estimator with a desired error epsilon (epsilon = 0.001 means about 0.1% error)
estimator = QuantileEstimator(epsilon=0.001)
for value in range(1000):
estimator.insert(value)
# Get quantiles: 0.5 (median), 0.9, 0.99
print("Median:", estimator.query(0.5))
print("90th percentile:", estimator.query(0.9))
print("99th percentile:", estimator.query(0.99))