skillfed

dtw-python

A comprehensive implementation of dynamic time warping (DTW) algorithms.

dtw-python v1.7.5 250.9K downloads/30d#8,609 on PyPI343
Copyleft license GPL-3.0-or-later Active released

What it is and what it does

dtw-python is a comprehensive implementation of Dynamic Time Warping algorithms for computing optimal alignments between time series. It measures how much temporal stretching or compression is needed to map one sequence onto another, outputting both the cumulative distance and the warping function (alignment path) itself. The package is widely used for time series classification, clustering, and pattern matching in domains like econometrics, chemistry, and bioinformatics.

The implementation supports arbitrary local constraints (symmetric, asymmetric, slope-limited step patterns) and global windowing constraints (Sakoe-Chiba band, Itakura parallelogram), partial matches (open-begin, open-end, substring), and proper normalization. It wraps fast native C code and depends on numpy and scipy for numerical operations. The package is a faithful Python port of R's established DTW package.

Use it for:

  • Classify or cluster financial time series (stock prices, economic indicators) by measuring temporal similarity.
  • Match speech or audio signals with different playback speeds or durations for speaker recognition or phoneme alignment.
  • Align medical time series (ECG, EEG, rehabilitation motion data) to detect patterns despite temporal variations.
  • Compare DNA or protein sequences with variable-length insertions/deletions in bioinformatics workflows.
  • Detect anomalies in sensor data by computing DTW distance to a reference normal pattern.
  • Perform real-time sequence matching with open-end constraints for streaming or incomplete time series.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Computes Dynamic Time Warping alignments between time series, measuring optimal temporal correspondence and cumulative distance with support for windowing and step-pattern constraints.

Yes, if you need time series alignment or distance computation. Active maintenance, no known vulnerabilities, broad Python version support (3.9–3.13), and prebuilt wheels minimize friction. GPL-3.0-or-later copyleft is a blocker only if you cannot open-source your code. The package is production-stable and widely cited in academic literature.

Install

dtw-python on PyPI

pip

pip install dtw-python

uv

uv add dtw-python

poetry

poetry add dtw-python

Installing dtw-python

Before you install

Medium install friction due to compiled wheels; prebuilt binaries available for Python 3.9–3.13 on macOS (x86_64, arm64), Linux (x86_64, aarch64), and Windows. Actively maintained with recent releases.

License in practice

GPL-3.0-or-later copyleft license; use in proprietary software requires either licensing negotiation or release of your own code under GPL-3.0 or later.

Quickstart

import numpy as np
from dtw import dtw

query = np.array([1, 2, 3, 4, 5])
reference = np.array([1, 2, 2, 3, 4, 5])
dist, cost_matrix, acc_cost_matrix, path = dtw(query, reference)

Requires numpy and scipy; Python >= 3.9.

Verify before relying

  • Performance characteristics (speed, memory usage) for typical time series lengths and multivariate data.
  • Availability and quality of visualization/plotting functions mentioned in description.
  • Whether all Rabiner-Juang, Sakoe-Chiba, and Rabiner-Myers step patterns are fully implemented.

Package facts

License GPL-3.0-or-later (copyleft)
Python support supports the current Python release (>=3.9)
Install friction medium — platform-specific wheel
Runtime dependencies 2 — numpy, scipy
Maintenance actively maintained — 63 days since the last release
Last repo commit
First released
Downloads 250,950/month — #8,609 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: dtw_python-1.7.5-cp310-cp310-macosx_10_9_x86_64.whl; dtw_python-1.7.5-cp310-cp310-macosx_11_0_arm64.whl; dtw_python-1.7.5-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dtw_python-1.7.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; dtw_python-1.7.5-cp310-cp310-win_amd64.whl; dtw_python-1.7.5-cp311-cp311-macosx_10_9_x86_64.whl; dtw_python-1.7.5-cp311-cp311-macosx_11_0_arm64.whl; dtw_python-1.7.5-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dtw_python-1.7.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; dtw_python-1.7.5-cp311-cp311-win_amd64.whl; dtw_python-1.7.5-cp312-cp312-macosx_10_13_x86_64.whl; dtw_python-1.7.5-cp312-cp312-macosx_11_0_arm64.whl; dtw_python-1.7.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dtw_python-1.7.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; dtw_python-1.7.5-cp312-cp312-win_amd64.whl; dtw_python-1.7.5-cp313-cp313-macosx_10_13_x86_64.whl; dtw_python-1.7.5-cp313-cp313-macosx_11_0_arm64.whl; dtw_python-1.7.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dtw_python-1.7.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; dtw_python-1.7.5-cp313-cp313-win_amd64.whl

Keywords: timeseries, alignment

Development Status :: 5 - Production/StableIntended Audience :: Science/ResearchNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Scientific/Engineering

Tags

dynamic time warping alignmenttime series distance matchingdtw algorithm pythontemporal sequence alignmenttime series warping functionsequence matching with constraintstime series classification dtw
time-series-analysissequence-alignmentscientific-computing

More Scientific/Engineering packages