convtools


Nameconvtools JSON
Version 1.8.0 PyPI version JSON
download
home_pageNone
Summarydynamic, declarative data transformations with automatic code generation
upload_time2024-03-06 19:47:28
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseThe MIT License (MIT) Copyright (c) 2021 Nikita Almakov Copyright (c) 2020 iTechArt Group Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords codegen converters convtools etl
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # convtools

**convtools** is a specialized Python library designed for defining data
transformations dynamically using a declarative approach. It automatically
generates custom Python code for the user in the background.

[![License](https://img.shields.io/github/license/westandskif/convtools.svg)](https://github.com/westandskif/convtools/blob/master/LICENSE.txt)
[![codecov](https://codecov.io/gh/westandskif/convtools/branch/master/graph/badge.svg)]( https://codecov.io/gh/westandskif/convtools)
[![Tests status](https://github.com/westandskif/convtools/workflows/tests/badge.svg)](https://github.com/westandskif/convtools/actions/workflows/pytest.yml)
[![Docs status](https://readthedocs.org/projects/convtools/badge/?version=latest)](https://convtools.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://badge.fury.io/py/convtools.svg)](https://pypi.org/project/convtools/)
[![Twitter](https://img.shields.io/twitter/url?label=convtools&style=social&url=https%3A%2F%2Ftwitter.com%2Fconvtools)](https://twitter.com/convtools)
[![Downloads](https://static.pepy.tech/badge/convtools)](https://pepy.tech/project/convtools)
[![Python versions](https://img.shields.io/pypi/pyversions/convtools.svg)](https://pypi.org/project/convtools/)

____

## Installation

`pip install convtools`

## Documentation

**[convtools.readthedocs.io](https://convtools.readthedocs.io/en/latest/)**


## Group by example

```python
from convtools import conversion as c

input_data = [
    {"a": 5, "b": "foo"},
    {"a": 10, "b": "foo"},
    {"a": 10, "b": "bar"},
    {"a": 10, "b": "bar"},
    {"a": 20, "b": "bar"},
]

conv = (
    c.group_by(c.item("b"))
    .aggregate(
        {
            "b": c.item("b"),
            "a_first": c.ReduceFuncs.First(c.item("a")),
            "a_max": c.ReduceFuncs.Max(c.item("a")),
        }
    )
    .pipe(
        c.aggregate({
            "b_values": c.ReduceFuncs.Array(c.item("b")),
            "mode_a_first": c.ReduceFuncs.Mode(c.item("a_first")),
            "median_a_max": c.ReduceFuncs.Median(c.item("a_max")),
        })
    )
    .gen_converter()
)

assert conv(input_data) == {
    'b_values': ['foo', 'bar'],
    'mode_a_first': 10,
    'median_a_max': 15.0
}

```

##### Built-in reducers like `c.ReduceFuncs.First`
    * Sum
    * SumOrNone
    * Max
    * MaxRow
    * Min
    * MinRow
    * Count
    * CountDistinct
    * First
    * Last
    * Average
    * Median
    * Percentile
    * Mode
    * TopK
    * Array
    * ArrayDistinct
    * ArraySorted

    DICT REDUCERS ARE IN FACT AGGREGATIONS THEMSELVES, BECAUSE VALUES GET REDUCED.
    * Dict
    * DictArray
    * DictSum
    * DictSumOrNone
    * DictMax
    * DictMin
    * DictCount
    * DictCountDistinct
    * DictFirst
    * DictLast

    AND LASTLY YOU CAN DEFINE YOUR OWN REDUCER BY PASSING ANY REDUCE FUNCTION
    OF TWO ARGUMENTS TO ``c.reduce``.


## What's the point if there are tools like Pandas / Polars?

* convtools doesn't need to wrap data in a container to provide functionality,
  it simply runs the python code it generates on **any input**
* convtools is lightweight (_though optional `black` is highly recommended for
  pretty-printing generated code out of curiosity_)
* convtools fosters building pipelines on top of iterators, allowing for stream
  processing
* convtools supports nested aggregations
* convtools is a set of primitives for code generation, so it's just different.

## Support

* westandskif (Nikita Almakov) - [Link to support](https://boosty.to/westandskif)

## Reporting a Security Vulnerability

See the [security policy](https://github.com/westandskif/convtools/security/policy).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "convtools",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "Nikita Almakov <nikita.almakov@gmail.com>",
    "keywords": "codegen,converters,convtools,etl",
    "author": null,
    "author_email": "Nikita Almakov <nikita.almakov@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/e7/a6/030fe5d56fe9f9ff373bfcdcdf7a1398c77570dc3180b101e623369eb940/convtools-1.8.0.tar.gz",
    "platform": null,
    "description": "# convtools\n\n**convtools** is a specialized Python library designed for defining data\ntransformations dynamically using a declarative approach. It automatically\ngenerates custom Python code for the user in the background.\n\n[![License](https://img.shields.io/github/license/westandskif/convtools.svg)](https://github.com/westandskif/convtools/blob/master/LICENSE.txt)\n[![codecov](https://codecov.io/gh/westandskif/convtools/branch/master/graph/badge.svg)]( https://codecov.io/gh/westandskif/convtools)\n[![Tests status](https://github.com/westandskif/convtools/workflows/tests/badge.svg)](https://github.com/westandskif/convtools/actions/workflows/pytest.yml)\n[![Docs status](https://readthedocs.org/projects/convtools/badge/?version=latest)](https://convtools.readthedocs.io/en/latest/?badge=latest)\n[![PyPI](https://badge.fury.io/py/convtools.svg)](https://pypi.org/project/convtools/)\n[![Twitter](https://img.shields.io/twitter/url?label=convtools&style=social&url=https%3A%2F%2Ftwitter.com%2Fconvtools)](https://twitter.com/convtools)\n[![Downloads](https://static.pepy.tech/badge/convtools)](https://pepy.tech/project/convtools)\n[![Python versions](https://img.shields.io/pypi/pyversions/convtools.svg)](https://pypi.org/project/convtools/)\n\n____\n\n## Installation\n\n`pip install convtools`\n\n## Documentation\n\n**[convtools.readthedocs.io](https://convtools.readthedocs.io/en/latest/)**\n\n\n## Group by example\n\n```python\nfrom convtools import conversion as c\n\ninput_data = [\n    {\"a\": 5, \"b\": \"foo\"},\n    {\"a\": 10, \"b\": \"foo\"},\n    {\"a\": 10, \"b\": \"bar\"},\n    {\"a\": 10, \"b\": \"bar\"},\n    {\"a\": 20, \"b\": \"bar\"},\n]\n\nconv = (\n    c.group_by(c.item(\"b\"))\n    .aggregate(\n        {\n            \"b\": c.item(\"b\"),\n            \"a_first\": c.ReduceFuncs.First(c.item(\"a\")),\n            \"a_max\": c.ReduceFuncs.Max(c.item(\"a\")),\n        }\n    )\n    .pipe(\n        c.aggregate({\n            \"b_values\": c.ReduceFuncs.Array(c.item(\"b\")),\n            \"mode_a_first\": c.ReduceFuncs.Mode(c.item(\"a_first\")),\n            \"median_a_max\": c.ReduceFuncs.Median(c.item(\"a_max\")),\n        })\n    )\n    .gen_converter()\n)\n\nassert conv(input_data) == {\n    'b_values': ['foo', 'bar'],\n    'mode_a_first': 10,\n    'median_a_max': 15.0\n}\n\n```\n\n##### Built-in reducers like `c.ReduceFuncs.First`\n    * Sum\n    * SumOrNone\n    * Max\n    * MaxRow\n    * Min\n    * MinRow\n    * Count\n    * CountDistinct\n    * First\n    * Last\n    * Average\n    * Median\n    * Percentile\n    * Mode\n    * TopK\n    * Array\n    * ArrayDistinct\n    * ArraySorted\n\n    DICT REDUCERS ARE IN FACT AGGREGATIONS THEMSELVES, BECAUSE VALUES GET REDUCED.\n    * Dict\n    * DictArray\n    * DictSum\n    * DictSumOrNone\n    * DictMax\n    * DictMin\n    * DictCount\n    * DictCountDistinct\n    * DictFirst\n    * DictLast\n\n    AND LASTLY YOU CAN DEFINE YOUR OWN REDUCER BY PASSING ANY REDUCE FUNCTION\n    OF TWO ARGUMENTS TO ``c.reduce``.\n\n\n## What's the point if there are tools like Pandas / Polars?\n\n* convtools doesn't need to wrap data in a container to provide functionality,\n  it simply runs the python code it generates on **any input**\n* convtools is lightweight (_though optional `black` is highly recommended for\n  pretty-printing generated code out of curiosity_)\n* convtools fosters building pipelines on top of iterators, allowing for stream\n  processing\n* convtools supports nested aggregations\n* convtools is a set of primitives for code generation, so it's just different.\n\n## Support\n\n* westandskif (Nikita Almakov) - [Link to support](https://boosty.to/westandskif)\n\n## Reporting a Security Vulnerability\n\nSee the [security policy](https://github.com/westandskif/convtools/security/policy).\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)\n        \n        Copyright (c) 2021 Nikita Almakov\n        \n        Copyright (c) 2020 iTechArt Group\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "dynamic, declarative data transformations with automatic code generation",
    "version": "1.8.0",
    "project_urls": {
        "changelog": "https://github.com/westandskif/convtools/blob/master/docs/CHANGELOG.md",
        "documentation": "https://convtools.readthedocs.io/en/latest/",
        "homepage": "https://github.com/westandskif/convtools",
        "repository": "https://github.com/westandskif/convtools"
    },
    "split_keywords": [
        "codegen",
        "converters",
        "convtools",
        "etl"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "89a4f553b9217b8a4bd127e7a193bcd97af3747a77681f6298fd10b35acaec1f",
                "md5": "cb71b30271cd31a8e923c78a7d34da05",
                "sha256": "e07bd0b95795e195ebfbdabf376293beadde6971f5c1ec1ba1903aefaed51b94"
            },
            "downloads": -1,
            "filename": "convtools-1.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cb71b30271cd31a8e923c78a7d34da05",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 73348,
            "upload_time": "2024-03-06T19:47:31",
            "upload_time_iso_8601": "2024-03-06T19:47:31.027083Z",
            "url": "https://files.pythonhosted.org/packages/89/a4/f553b9217b8a4bd127e7a193bcd97af3747a77681f6298fd10b35acaec1f/convtools-1.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e7a6030fe5d56fe9f9ff373bfcdcdf7a1398c77570dc3180b101e623369eb940",
                "md5": "86e6a80791090e6aa3dcfdfa212c1527",
                "sha256": "85aff4340fbcd09c1ca87f4f41c4c335da1051791167b5c4d248a58c54ae15cf"
            },
            "downloads": -1,
            "filename": "convtools-1.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "86e6a80791090e6aa3dcfdfa212c1527",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 64316,
            "upload_time": "2024-03-06T19:47:28",
            "upload_time_iso_8601": "2024-03-06T19:47:28.033517Z",
            "url": "https://files.pythonhosted.org/packages/e7/a6/030fe5d56fe9f9ff373bfcdcdf7a1398c77570dc3180b101e623369eb940/convtools-1.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-06 19:47:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "westandskif",
    "github_project": "convtools",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "convtools"
}
        
Elapsed time: 0.23385s