# daproli [![PyPI version](https://badge.fury.io/py/daproli.svg)](https://pypi.org/project/daproli/) [![Build Status](https://travis-ci.com/ermshaua/daproli.svg?branch=master)](https://travis-ci.com/ermshaua/daproli) [![Downloads](https://pepy.tech/badge/daproli)](https://pepy.tech/project/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.
```python3
>>> 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```.
```python3
>>> names = ['John', 'Susan', 'Mike']
>>> numbers = range(10)
```
```python3
>>> even_numbers = range(0, 10, 2)
>>> odd_numbers = range(1, 10, 2)
```
```python3
>>> dp.map(str.lower, names)
['john', 'susan', 'mike']
```
```python3
>>> dp.filter(lambda n : len(n) % 2 == 0, names)
['John', 'Mike']
```
```python3
>>> dp.split(lambda x : x % 2 == 0, numbers)
[[1, 3, 5, 7, 9], [0, 2, 4, 6, 8]]
```
```python3
>>> 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]]
```
```python3
>>> dp.combine(lambda x, y : (x,y), even_numbers, odd_numbers)
[(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]
```
```python3
>>> 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.
```python3
>>> dp.windowed(numbers, 2, step=2)
[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]
```
```python3
>>> 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.
```python3
>>> 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)]
```
```python3
>>> 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 <a href="https://github.com/ermshaua/daproli/tree/master/daproli/examples">here</a>.
Raw data
{
"_id": null,
"home_page": "https://github.com/ermshaua/daproli",
"name": "daproli",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Arik Ermshaus",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/63/38/fb4fc81b0873a6d7ad0a1b8326914b41377cf862af0f6c1f98bb58399a32/daproli-0.22.tar.gz",
"platform": "",
"description": "# daproli [![PyPI version](https://badge.fury.io/py/daproli.svg)](https://pypi.org/project/daproli/) [![Build Status](https://travis-ci.com/ermshaua/daproli.svg?branch=master)](https://travis-ci.com/ermshaua/daproli) [![Downloads](https://pepy.tech/badge/daproli)](https://pepy.tech/project/daproli)\nA small data processing library that attempts to make data transformation more declarative.\n\n## Installation\n\nYou can install daproli with PyPi:\n`python -m pip install daproli`\n\n## Examples\n\nLet's first import daproli.\n\n```python3\n>>> import daproli as dp\n```\n\nThe 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```. \n\n```python3\n>>> names = ['John', 'Susan', 'Mike']\n>>> numbers = range(10)\n```\n\n```python3\n>>> even_numbers = range(0, 10, 2)\n>>> odd_numbers = range(1, 10, 2)\n```\n\n```python3\n>>> dp.map(str.lower, names)\n['john', 'susan', 'mike']\n```\n\n```python3\n>>> dp.filter(lambda n : len(n) % 2 == 0, names)\n['John', 'Mike']\n```\n\n```python3\n>>> dp.split(lambda x : x % 2 == 0, numbers)\n[[1, 3, 5, 7, 9], [0, 2, 4, 6, 8]]\n```\n\n```python3\n>>> dp.expand(lambda x : (x, x**2), numbers)\n[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]]\n```\n\n```python3\n>>> dp.combine(lambda x, y : (x,y), even_numbers, odd_numbers)\n[(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]\n```\n\n```python3\n>>> dp.join(lambda x, y : y-x == 3, even_numbers, odd_numbers)\n[(0, 3), (2, 5), (4, 7), (6, 9)]\n```\n\ndaproli implements basic data manipulation functions.\n\n```python3\n>>> dp.windowed(numbers, 2, step=2)\n[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]\n```\n```python3\n>>> dp.flatten([[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]])\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n```\n\nAdditionally, 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.\n\n```python3\n>>> dp.Pipeline(\n dp.Splitter(lambda x: x % 2 == 1),\n dp.Union(\n dp.Mapper(lambda x: x ** 2),\n dp.Mapper(lambda x: x ** 3),\n ),\n dp.Combiner(lambda x1, x2: (x1, x2))\n ).transform(numbers)\n[(0, 1), (4, 27), (16, 125), (36, 343), (64, 729)]\n```\n\n```python3\n>>> dp.Pipeline(\n dp.Filter(lambda x : x > 1),\n dp.Filter(lambda x : all(x % idx != 0 for idx in range(2, x))),\n ).transform(numbers)\n[2, 3, 5, 7]\n```\n\nYou can find more examples <a href=\"https://github.com/ermshaua/daproli/tree/master/daproli/examples\">here</a>. \n\n\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License",
"summary": "daproli is a small data processing library that attempts to make data transformation more declarative.",
"version": "0.22",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "43553128ec6c71aa89a25da5e69a7f50d4bbf22919d39df46b7d7c7909076f3f",
"md5": "3a6b3a5db88501724288c4f645af73a0",
"sha256": "8fc6315715916cc673ae1038bcb68e5b5b4b428f5e680c4c18f950222123228c"
},
"downloads": -1,
"filename": "daproli-0.22-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3a6b3a5db88501724288c4f645af73a0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9822,
"upload_time": "2020-10-26T17:18:23",
"upload_time_iso_8601": "2020-10-26T17:18:23.523496Z",
"url": "https://files.pythonhosted.org/packages/43/55/3128ec6c71aa89a25da5e69a7f50d4bbf22919d39df46b7d7c7909076f3f/daproli-0.22-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6338fb4fc81b0873a6d7ad0a1b8326914b41377cf862af0f6c1f98bb58399a32",
"md5": "c59a65d8f8803c58a34b7450abdc4239",
"sha256": "7080864708769b86a3d5724f15d5a10aa81d3a801ba0ce6c1bf20a44075a6971"
},
"downloads": -1,
"filename": "daproli-0.22.tar.gz",
"has_sig": false,
"md5_digest": "c59a65d8f8803c58a34b7450abdc4239",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7406,
"upload_time": "2020-10-26T17:18:24",
"upload_time_iso_8601": "2020-10-26T17:18:24.550821Z",
"url": "https://files.pythonhosted.org/packages/63/38/fb4fc81b0873a6d7ad0a1b8326914b41377cf862af0f6c1f98bb58399a32/daproli-0.22.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-10-26 17:18:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "ermshaua",
"github_project": "daproli",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numpy",
"specs": []
},
{
"name": "joblib",
"specs": []
},
{
"name": "tqdm",
"specs": []
},
{
"name": "setuptools",
"specs": []
}
],
"lcname": "daproli"
}