Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Largest-Triangle-Three-Buckets algorithm for downsampling time series–like data

Project description

Numpy implementation of Steinarsson’s Largest-Triangle-Three-Buckets algorithm for downsampling time series–like data

Based on the original JavaScript code:


Sveinn Steinarsson. 2013. Downsampling Time Series for Visual Representation. MSc thesis. University of Iceland.

A test data set is provided in tests/timeseries.csv. It was downloaded from and converted from JSON to CSV.


import numpy as np
import lttb
data = np.array([range(100), np.random.random(100)]).T
small_data = lttb.downsample(data, n_out=20)
assert small_data.shape == (20, 2)

For example, here is the data set provided in tests downsampled to 100 points:


To install the lttb package into your (virtual) environment:

pip install lttb


  • Python 3
  • Numpy

Licence: MIT


  • Jack Viljoen (@javiljoen) – original Numpy implementation
  • Guillaume Bethouart (@guillaumeB) – performance improvements

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lttb, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size lttb-0.2.0-py3-none-any.whl (3.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size lttb-0.2.0.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page