Skip to main content

python-rle

Run-length encoding (wikipedia link) for data analysis in Python. Install with pip install python-rle. No dependencies required other than tqdm for visualizing a progress bar.

Usage

Encode any iterable (tuples, lists, pd.Series etc.) with rle.encode.

# rle.encode(iterable) returns (values, counts)
>>> import rle 
>>> rle.encode((10, 10, 10, 20, 20, 20, 30, 30, 30))
([10, 20, 30], [3, 3, 3])

Decode (values, counts) back into a sequence with rle.decode.

>>> rle.decode([10, 20, 30], [3, 3, 3])
[10, 10, 10, 20, 20, 20, 30, 30, 30]

Set progress_bar == True for long sequences :

progress_bar_anim

Motivation

Base R contains a simple rle function that "computes the lengths and values of runs of equal values in a vector", as described by its docstring. I found it useful for calculating streaks in collected data, and is especially wonderful for compiling and summarizing categorical data that describes status over time. Hence this little utility.

Release files for python-rle 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-rle 0.0.3
File Size Uploaded
python-rle-0.0.3.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-rle 0.0.3
File Interpreter ABI Platform
python_rle-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / python-rle-0.0.3.tar.gz

Download URL python-rle-0.0.3.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4e07dc3c775a4bbc6e2cc7a3102e4cf33f4431e35c7b5fedc863edc44bc7b6aa
BLAKE2b-256 checksum
How to use checksums
0f66d2abcfce6c1d0bb3251d4277649eb0f3b21866134d3a5e8b9efe9e839ada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

Release files / python_rle-0.0.3-py3-none-any.whl

Download URL python_rle-0.0.3-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52a086dad15bf98e1242a45f70ff0d7e0a0e9cd0a8bcc91ed36404c4b713c654
BLAKE2b-256 checksum
How to use checksums
a4cafc4dc810c892f8284d41046b60105fea56a7689a5b31e55e0b47c6aff971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page