Name | datar JSON |
Version |
0.15.6
JSON |
| download |
home_page | https://github.com/pwwang/datar |
Summary | A Grammar of Data Manipulation in python |
upload_time | 2024-03-14 04:12:20 |
maintainer | |
docs_url | None |
author | pwwang |
requires_python | >=3.8,<4.0 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
# datar
A Grammar of Data Manipulation in python
<!-- badges -->
[![Pypi][6]][7] [![Github][8]][9] ![Building][10] [![Docs and API][11]][5] [![Codacy][12]][13] [![Codacy coverage][14]][13] [![Downloads][20]][7]
[Documentation][5] | [Reference Maps][15] | [Notebook Examples][16] | [API][17]
`datar` is a re-imagining of APIs for data manipulation in python with multiple backends supported. Those APIs are aligned with tidyverse packages in R as much as possible.
## Installation
```shell
pip install -U datar
# install with a backend
pip install -U datar[pandas]
# More backends support coming soon
```
<!-- ## Maximum compatibility with R packages
|Package|Version|
|-|-|
|[dplyr][21]|1.0.8| -->
## Backends
|Repo|Badges|
|-|-|
|[datar-numpy][1]|![3] ![18]|
|[datar-pandas][2]|![4] ![19]|
|[datar-arrow][22]|![23] ![24]|
## Example usage
```python
# with pandas backend
from datar import f
from datar.dplyr import mutate, filter_, if_else
from datar.tibble import tibble
# or
# from datar.all import f, mutate, filter_, if_else, tibble
df = tibble(
x=range(4), # or c[:4] (from datar.base import c)
y=['zero', 'one', 'two', 'three']
)
df >> mutate(z=f.x)
"""# output
x y z
<int64> <object> <int64>
0 0 zero 0
1 1 one 1
2 2 two 2
3 3 three 3
"""
df >> mutate(z=if_else(f.x>1, 1, 0))
"""# output:
x y z
<int64> <object> <int64>
0 0 zero 0
1 1 one 0
2 2 two 1
3 3 three 1
"""
df >> filter_(f.x>1)
"""# output:
x y
<int64> <object>
0 2 two
1 3 three
"""
df >> mutate(z=if_else(f.x>1, 1, 0)) >> filter_(f.z==1)
"""# output:
x y z
<int64> <object> <int64>
0 2 two 1
1 3 three 1
"""
```
```python
# works with plotnine
# example grabbed from https://github.com/has2k1/plydata
import numpy
from datar import f
from datar.base import sin, pi
from datar.tibble import tibble
from datar.dplyr import mutate, if_else
from plotnine import ggplot, aes, geom_line, theme_classic
df = tibble(x=numpy.linspace(0, 2 * pi, 500))
(
df
>> mutate(y=sin(f.x), sign=if_else(f.y >= 0, "positive", "negative"))
>> ggplot(aes(x="x", y="y"))
+ theme_classic()
+ geom_line(aes(color="sign"), size=1.2)
)
```
![example](./example.png)
```python
# very easy to integrate with other libraries
# for example: klib
import klib
from pipda import register_verb
from datar import f
from datar.data import iris
from datar.dplyr import pull
dist_plot = register_verb(func=klib.dist_plot)
iris >> pull(f.Sepal_Length) >> dist_plot()
```
![example](./example2.png)
## Testimonials
[@coforfe](https://github.com/coforfe):
> Thanks for your excellent package to port R (`dplyr`) flow of processing to Python. I have been using other alternatives, and yours is the one that offers the most extensive and equivalent to what is possible now with `dplyr`.
[1]: https://github.com/pwwang/datar-numpy
[2]: https://github.com/pwwang/datar-pandas
[3]: https://img.shields.io/codacy/coverage/0a7519dad44246b6bab30576895f6766?style=flat-square
[4]: https://img.shields.io/codacy/coverage/45f4ea84ae024f1a8cf84be54dd144f7?style=flat-square
[5]: https://pwwang.github.io/datar/
[6]: https://img.shields.io/pypi/v/datar?style=flat-square
[7]: https://pypi.org/project/datar/
[8]: https://img.shields.io/github/v/tag/pwwang/datar?style=flat-square
[9]: https://github.com/pwwang/datar
[10]: https://img.shields.io/github/actions/workflow/status/pwwang/datar/ci.yml?branch=master&style=flat-square
[11]: https://img.shields.io/github/actions/workflow/status/pwwang/datar/docs.yml?branch=master&style=flat-square
[12]: https://img.shields.io/codacy/grade/3d9bdff4d7a34bdfb9cd9e254184cb35?style=flat-square
[13]: https://app.codacy.com/gh/pwwang/datar
[14]: https://img.shields.io/codacy/coverage/3d9bdff4d7a34bdfb9cd9e254184cb35?style=flat-square
[15]: https://pwwang.github.io/datar/reference-maps/ALL/
[16]: https://pwwang.github.io/datar/notebooks/across/
[17]: https://pwwang.github.io/datar/api/datar/
[18]: https://img.shields.io/pypi/v/datar-numpy?style=flat-square
[19]: https://img.shields.io/pypi/v/datar-pandas?style=flat-square
[20]: https://img.shields.io/pypi/dm/datar?style=flat-square
[21]: https://github.com/tidyverse/dplyr
[22]: https://github.com/pwwang/datar-arrow
[23]: https://img.shields.io/codacy/coverage/5f4ef9dd2503437db18786ff9e841d8b?style=flat-square
[24]: https://img.shields.io/pypi/v/datar-arrow?style=flat-square
Raw data
{
"_id": null,
"home_page": "https://github.com/pwwang/datar",
"name": "datar",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "pwwang",
"author_email": "pwwang@pwwang.com",
"download_url": "https://files.pythonhosted.org/packages/55/57/c9a6468c5b6f2e719483ac0174844f130abf7b577a516e775e04ce220460/datar-0.15.6.tar.gz",
"platform": null,
"description": "# datar\n\nA Grammar of Data Manipulation in python\n\n<!-- badges -->\n[![Pypi][6]][7] [![Github][8]][9] ![Building][10] [![Docs and API][11]][5] [![Codacy][12]][13] [![Codacy coverage][14]][13] [![Downloads][20]][7]\n\n[Documentation][5] | [Reference Maps][15] | [Notebook Examples][16] | [API][17]\n\n`datar` is a re-imagining of APIs for data manipulation in python with multiple backends supported. Those APIs are aligned with tidyverse packages in R as much as possible.\n\n## Installation\n\n```shell\npip install -U datar\n\n# install with a backend\npip install -U datar[pandas]\n\n# More backends support coming soon\n```\n\n<!-- ## Maximum compatibility with R packages\n\n|Package|Version|\n|-|-|\n|[dplyr][21]|1.0.8| -->\n\n## Backends\n\n|Repo|Badges|\n|-|-|\n|[datar-numpy][1]|![3] ![18]|\n|[datar-pandas][2]|![4] ![19]|\n|[datar-arrow][22]|![23] ![24]|\n\n## Example usage\n\n```python\n# with pandas backend\nfrom datar import f\nfrom datar.dplyr import mutate, filter_, if_else\nfrom datar.tibble import tibble\n# or\n# from datar.all import f, mutate, filter_, if_else, tibble\n\ndf = tibble(\n x=range(4), # or c[:4] (from datar.base import c)\n y=['zero', 'one', 'two', 'three']\n)\ndf >> mutate(z=f.x)\n\"\"\"# output\n x y z\n <int64> <object> <int64>\n0 0 zero 0\n1 1 one 1\n2 2 two 2\n3 3 three 3\n\"\"\"\n\ndf >> mutate(z=if_else(f.x>1, 1, 0))\n\"\"\"# output:\n x y z\n <int64> <object> <int64>\n0 0 zero 0\n1 1 one 0\n2 2 two 1\n3 3 three 1\n\"\"\"\n\ndf >> filter_(f.x>1)\n\"\"\"# output:\n x y\n <int64> <object>\n0 2 two\n1 3 three\n\"\"\"\n\ndf >> mutate(z=if_else(f.x>1, 1, 0)) >> filter_(f.z==1)\n\"\"\"# output:\n x y z\n <int64> <object> <int64>\n0 2 two 1\n1 3 three 1\n\"\"\"\n```\n\n```python\n# works with plotnine\n# example grabbed from https://github.com/has2k1/plydata\nimport numpy\nfrom datar import f\nfrom datar.base import sin, pi\nfrom datar.tibble import tibble\nfrom datar.dplyr import mutate, if_else\nfrom plotnine import ggplot, aes, geom_line, theme_classic\n\ndf = tibble(x=numpy.linspace(0, 2 * pi, 500))\n(\n df\n >> mutate(y=sin(f.x), sign=if_else(f.y >= 0, \"positive\", \"negative\"))\n >> ggplot(aes(x=\"x\", y=\"y\"))\n + theme_classic()\n + geom_line(aes(color=\"sign\"), size=1.2)\n)\n```\n\n![example](./example.png)\n\n```python\n# very easy to integrate with other libraries\n# for example: klib\nimport klib\nfrom pipda import register_verb\nfrom datar import f\nfrom datar.data import iris\nfrom datar.dplyr import pull\n\ndist_plot = register_verb(func=klib.dist_plot)\niris >> pull(f.Sepal_Length) >> dist_plot()\n```\n\n![example](./example2.png)\n\n## Testimonials\n\n[@coforfe](https://github.com/coforfe):\n> Thanks for your excellent package to port R (`dplyr`) flow of processing to Python. I have been using other alternatives, and yours is the one that offers the most extensive and equivalent to what is possible now with `dplyr`.\n\n[1]: https://github.com/pwwang/datar-numpy\n[2]: https://github.com/pwwang/datar-pandas\n[3]: https://img.shields.io/codacy/coverage/0a7519dad44246b6bab30576895f6766?style=flat-square\n[4]: https://img.shields.io/codacy/coverage/45f4ea84ae024f1a8cf84be54dd144f7?style=flat-square\n[5]: https://pwwang.github.io/datar/\n[6]: https://img.shields.io/pypi/v/datar?style=flat-square\n[7]: https://pypi.org/project/datar/\n[8]: https://img.shields.io/github/v/tag/pwwang/datar?style=flat-square\n[9]: https://github.com/pwwang/datar\n[10]: https://img.shields.io/github/actions/workflow/status/pwwang/datar/ci.yml?branch=master&style=flat-square\n[11]: https://img.shields.io/github/actions/workflow/status/pwwang/datar/docs.yml?branch=master&style=flat-square\n[12]: https://img.shields.io/codacy/grade/3d9bdff4d7a34bdfb9cd9e254184cb35?style=flat-square\n[13]: https://app.codacy.com/gh/pwwang/datar\n[14]: https://img.shields.io/codacy/coverage/3d9bdff4d7a34bdfb9cd9e254184cb35?style=flat-square\n[15]: https://pwwang.github.io/datar/reference-maps/ALL/\n[16]: https://pwwang.github.io/datar/notebooks/across/\n[17]: https://pwwang.github.io/datar/api/datar/\n[18]: https://img.shields.io/pypi/v/datar-numpy?style=flat-square\n[19]: https://img.shields.io/pypi/v/datar-pandas?style=flat-square\n[20]: https://img.shields.io/pypi/dm/datar?style=flat-square\n[21]: https://github.com/tidyverse/dplyr\n[22]: https://github.com/pwwang/datar-arrow\n[23]: https://img.shields.io/codacy/coverage/5f4ef9dd2503437db18786ff9e841d8b?style=flat-square\n[24]: https://img.shields.io/pypi/v/datar-arrow?style=flat-square\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Grammar of Data Manipulation in python",
"version": "0.15.6",
"project_urls": {
"Homepage": "https://github.com/pwwang/datar",
"Repository": "https://github.com/pwwang/datar"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e1bacf0d0753b0f78f41648611acc6b6185277496de47c022a14398cb900f4c1",
"md5": "26828ed1c81d302c479bf41943ac1177",
"sha256": "1736ea0d0c7cffa8ae3dcb78813daedd595a602edceb6069558e83fb3452cc16"
},
"downloads": -1,
"filename": "datar-0.15.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "26828ed1c81d302c479bf41943ac1177",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 10331298,
"upload_time": "2024-03-14T04:12:17",
"upload_time_iso_8601": "2024-03-14T04:12:17.859616Z",
"url": "https://files.pythonhosted.org/packages/e1/ba/cf0d0753b0f78f41648611acc6b6185277496de47c022a14398cb900f4c1/datar-0.15.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5557c9a6468c5b6f2e719483ac0174844f130abf7b577a516e775e04ce220460",
"md5": "98aba35792ada8137e4d0452a20c3c26",
"sha256": "5136c3b0dc4851f0db32e3d44ea137ebaac94f4fdf39f5e4d4de30d875d90b7e"
},
"downloads": -1,
"filename": "datar-0.15.6.tar.gz",
"has_sig": false,
"md5_digest": "98aba35792ada8137e4d0452a20c3c26",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 10324293,
"upload_time": "2024-03-14T04:12:20",
"upload_time_iso_8601": "2024-03-14T04:12:20.527470Z",
"url": "https://files.pythonhosted.org/packages/55/57/c9a6468c5b6f2e719483ac0174844f130abf7b577a516e775e04ce220460/datar-0.15.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-14 04:12:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pwwang",
"github_project": "datar",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "datar"
}