--- id: dtaidistance version: "2.4.0" license: Apache-2.0 license_treatment: permissive maintenance: active --- # dtaidistance — Distance measures for time series (Dynamic Time Warping, fast C implementation) License: permissive · Maintenance: active · Downloads: 138.7K/mo ## What it is and what it does dtaidistance is a library for computing distance measures between time series, centered on Dynamic Time Warping (DTW) and related algorithms. It offers a pure Python implementation and a fast C implementation (with Cython as the build-time dependency). The library is designed to work seamlessly with NumPy and Pandas while avoiding unnecessary data copies. The package supports a range of DTW variants and optimizations: windowed alignment, pruning strategies, multi-dimensional sequences, barycenter averaging for clustering, and subsequence search. It can compute distances between pairs of series, full distance matrices across sets of series, or partial blocks for distributed computation. The C implementation includes parallelization via OpenMP when available. Use it for: - Measure similarity between sensor time series or financial price sequences to detect anomalies or patterns. - Build distance matrices for time series clustering using hierarchical or other clustering methods. - Align and compare sequences of different lengths in speech recognition, gesture analysis, or bioinformatics. - Accelerate large-scale time series comparisons using the fast C backend with optional pruning. - Compute warping paths and visualize alignment between two time series for exploratory analysis. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Computes distance measures between time series using Dynamic Time Warping (DTW) and related algorithms, with both pure Python and optimized C implementations. Yes. dtaidistance is actively maintained, has no known vulnerabilities, and offers a well-tested implementation of DTW with both accessibility (pure Python) and performance (C with OpenMP). The Apache-2.0 license is permissive. Install friction is moderate due to C compilation, but pre-built wheels for Python 3.11–3.14 on major platforms mitigate this. Suitable for time series analysis, clustering, and similarity tasks. ## Install pip install dtaidistance uv add dtaidistance poetry add dtaidistance ## Installing dtaidistance Before you install: Medium install friction due to C compilation, but pre-built wheels cover modern Python versions (3.11–3.14) and major platforms. Last release was 183 days ago with active repository maintenance and 1241 stars. License in practice: Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions. Quickstart: pip install dtaidistance from dtaidistance import dtw import numpy as np s1 = np.array([0.0, 0, 1, 2, 1, 0, 1, 0, 0]) s2 = np.array([0.0, 1, 2, 0, 0, 0, 0, 0, 0]) d = dtw.distance_fast(s1, s2) Requires numpy at runtime; C implementation benefits from OpenMP but falls back to pure Python if unavailable. Verify before relying: - Whether the C implementation is automatically selected or requires explicit configuration on all platforms. - Performance scaling characteristics for very large time series or high-dimensional data. - Compatibility with recent versions of scipy for clustering workflows mentioned in the description. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 138.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags dynamic time warping distance, time series similarity, dtw algorithm, sequence alignment distance, time series clustering, temporal distance metrics, time-series-analysis, distance-metrics, clustering [View on SkillFed](https://skillfed.io/packages/dtaidistance) · [View on PyPI](https://pypi.org/project/dtaidistance/)