daproli

A small data processing library that attempts to make data transformation more declarative.
Installation
You can install daproli with PyPi:
python -m pip install daproli
Examples
Let's first import daproli.
>>> import daproli as dp
The library provides basic data transformation methods. In default mode, all transformations are single-threaded and silent. You can specify the amount of jobs with n_jobs, provide further parameters like backend for the joblib module and increase the verbosity level with verbose.
>>> names = ['John', 'Susan', 'Mike']
>>> numbers = range(10)
>>> even_numbers = range(0, 10, 2)
>>> odd_numbers = range(1, 10, 2)
>>> dp.map(str.lower, names)
['john', 'susan', 'mike']
>>> dp.filter(lambda n : len(n) % 2 == 0, names)
['John', 'Mike']
>>> dp.split(lambda x : x % 2 == 0, numbers)
[[1, 3, 5, 7, 9], [0, 2, 4, 6, 8]]
>>> dp.expand(lambda x : (x, x**2), numbers)
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]]
>>> dp.combine(lambda x, y : (x,y), even_numbers, odd_numbers)
[(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]
>>> dp.join(lambda x, y : y-x == 3, even_numbers, odd_numbers)
[(0, 3), (2, 5), (4, 7), (6, 9)]
daproli implements basic data manipulation functions.
>>> dp.windowed(numbers, 2, step=2)
[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]
>>> dp.flatten([[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Additionally, it provides a data transformation pipeline framework. All transformation and manipulation procedures have respective transformers with the same arguments. There are also utility transformers like Union or Manipulator that help to connect transformers or make global changes to the data container.
>>> dp.Pipeline(
dp.Splitter(lambda x: x % 2 == 1),
dp.Union(
dp.Mapper(lambda x: x ** 2),
dp.Mapper(lambda x: x ** 3),
),
dp.Combiner(lambda x1, x2: (x1, x2))
).transform(numbers)
[(0, 1), (4, 27), (16, 125), (36, 343), (64, 729)]
>>> dp.Pipeline(
dp.Filter(lambda x : x > 1),
dp.Filter(lambda x : all(x % idx != 0 for idx in range(2, x))),
).transform(numbers)
[2, 3, 5, 7]
You can find more examples here.
Metadata
Release files for daproli 0.22
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| daproli-0.22.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| daproli-0.22-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.2 kB
Release files / daproli-0.22.tar.gz
| Download URL | daproli-0.22.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7080864708769b86a3d5724f15d5a10aa81d3a801ba0ce6c1bf20a44075a6971
|
|
BLAKE2b-256 checksum How to use checksums |
6338fb4fc81b0873a6d7ad0a1b8326914b41377cf862af0f6c1f98bb58399a32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Release files / daproli-0.22-py3-none-any.whl
| Download URL | daproli-0.22-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8fc6315715916cc673ae1038bcb68e5b5b4b428f5e680c4c18f950222123228c
|
|
BLAKE2b-256 checksum How to use checksums |
43553128ec6c71aa89a25da5e69a7f50d4bbf22919d39df46b7d7c7909076f3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|