Registry / data / tdigest

tdigest

JSON →
library0.5.2.2pypypi✓ verified 85d ago

The `tdigest` library is a Python implementation of Ted Dunning's t-digest data structure, designed for efficient and accurate percentile and quantile estimation from streaming or distributed data. It enables computations like percentiles, quantiles, and trimmed means. The current official PyPI version is 0.5.2.2, with releases focusing on performance improvements and bug fixes. The library is actively maintained with occasional updates.

pip install tdigest
INSTALL
IMPORT
SIG · TDIGEST
T
tdigest
datapythonv0.5.2.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TDigest
from tdigest import TDigest

Initializes a TDigest object, updates it with data either sequentially or in batches, and demonstrates how to compute percentiles and merge two digests. Requires `numpy` for random data generation.

import numpy as np from tdigest import TDigest # Create a TDigest instance digest = TDigest() # Update the digest sequentially with random data for _ in range(5000): digest.update(np.random.random()) # Or update the digest in batches another_digest = TDigest() another_digest.batch_update(np.random.random(5000)) # Compute the 15th percentile print(f"15th percentile (sequential): {digest.percentile(15)}") print(f"15th percentile (batch): {another_digest.percentile(15)}") # Sum two digests sum_digest = digest + another_digest print(f"30th percentile (summed): {sum_digest.percentile(30)}")
Debug
Known issues
breakingThe `quantile` method was renamed to `cdf` in version 0.5.0 for more accurate terminology. Calling `quantile()` on versions 0.5.0 and later will result in an AttributeError.
fix
Replace `digest.quantile(x)` with `digest.cdf(x)`.
affects: >=0.5.0
gotchaThe latest PyPI version (0.5.2.2) lags behind the latest GitHub release (v0.6.0.1). Users seeking the absolute latest features or bug fixes might need to install directly from GitHub, though this is not typically recommended for production.
fix
For the latest version, consider `pip install git+https://github.com/CamDavidsonPilon/tdigest.git` (use with caution, may not be production-ready stable).
affects: All
gotchaOlder documentation and PyPI metadata mention compatibility with Python 2. Given Python 2's end-of-life, new development and most recent versions of `tdigest` are exclusively targeting Python 3. Relying on Python 2 compatibility is strongly discouraged and likely to lead to issues.
fix
Ensure your project uses Python 3.6+ to align with modern Python practices and better library support.
affects: <0.5.0 (for implied Python 2 support), all (for outdated docs)
gotchaWhile `tdigest` objects can be serialized to and from Python dictionaries using `to_dict()` and `update_from_dict()`, direct pickling might not always be forward/backward compatible across minor versions due to internal changes in the underlying data structure (`accumulation_tree` in v0.5.0).
fix
Prefer `to_dict()` and `update_from_dict()` for robust serialization, especially when saving digests for later use or cross-version compatibility.
affects: All
Errors
Common errors & fixes
AttributeError: 'TDigest' object has no attribute 'quantile'
Attempting to call the `quantile` method on a `TDigest` object in version 0.5.0 or later, after it was renamed.
fix
Use the `cdf` method instead: `digest.cdf(x)`.
Download error on https://pypi.org/simple/cython/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION]
This error can occur with outdated `pip` versions or Python environments (often Python 2 or older Python 3.x) attempting to access PyPI mirrors with modern SSL/TLS configurations. This specific error was reported when installing `tdigest` indirectly pulling `cython`.
fix
Upgrade `pip` to the latest version (`pip install --upgrade pip`) and ensure your Python environment supports modern TLS protocols. Consider upgrading your Python version if it's very old.
TypeError: unsupported operand type(s) for +: 'TDigest' and 'NoneType'
This typically happens when trying to merge a `TDigest` object with a variable that is `None`, often due to an uninitialized digest or a failed previous operation.
fix
Ensure all `TDigest` objects involved in merge operations (`+` operator or `merge` method) are properly initialized and contain data. For example, `TDigest()` instead of `None`.
Upgrade
Version history
0.5.2.2latest on PyPI · released May 7, 2019
Audit
Dependencies
numpyoptionalCommonly used for generating sample data in examples and for batch updates.
Agent activity
18 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
tdigest — pip install tdigest · libregistry