python package for run length encoding on pandas Series
Project description
pdrle
Installation
pip install pdrle
Usage
import pdrle
import pandas
x = pandas.Series(["a", "a", "b", "b", "a", "a", "a", "c"])
rle = pdrle.encode(x)
rle
# vals runs
# 0 a 2
# 1 b 2
# 2 a 3
# 3 c 1
y = pdrle.decode(rle.vals, rle.runs)
y
# 0 a
# 1 a
# 2 b
# 3 b
# 4 a
# 5 a
# 6 a
# 7 c
# dtype: object
pandas.concat({"x": x, "id": pdrle.get_id(x)}, axis=1)
# x id
# 0 a 0
# 1 a 0
# 2 b 1
# 3 b 1
# 4 a 2
# 5 a 2
# 6 a 2
# 7 c 3
pandas.concat({"x": x, "sn": pdrle.get_sn(x)}, axis=1)
# x sn
# 0 a 0
# 1 a 1
# 2 b 0
# 3 b 1
# 4 a 0
# 5 a 1
# 6 a 2
# 7 c 0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pdrle-0.5.0.tar.gz
(3.0 kB
view details)
File details
Details for the file pdrle-0.5.0.tar.gz
.
File metadata
- Download URL: pdrle-0.5.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9ccf0d018c548f83b885988837044b07503d9847380fd8e40b73dd9d50c3493 |
|
MD5 | 0a2529a412b3efa9db4ba0424019ece0 |
|
BLAKE2b-256 | bcf3744912fd65db3dd54a638f3ce334a65a68f522dd7c61dd6337181e0dd731 |