{"id":13738052,"url":"https://github.com/pwwang/datar","last_synced_at":"2025-04-04T10:05:28.539Z","repository":{"id":39879381,"uuid":"316677724","full_name":"pwwang/datar","owner":"pwwang","description":"A Grammar of Data Manipulation in python","archived":false,"fork":false,"pushed_at":"2024-03-14T04:14:34.000Z","size":22447,"stargazers_count":271,"open_issues_count":8,"forks_count":17,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-30T01:38:35.394Z","etag":null,"topics":["data-manipulation","dplyr","forcats","groupby","pandas","tibble","tidyr","tidyverse","tribble"],"latest_commit_sha":null,"homepage":"https://pwwang.github.io/datar/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-11-28T07:10:06.000Z","updated_at":"2024-10-26T19:56:25.000Z","dependencies_parsed_at":"2024-04-20T04:33:49.701Z","dependency_job_id":"c7d459c2-3a59-441e-b54f-298a54150908","html_url":"https://github.com/pwwang/datar","commit_stats":{"total_commits":245,"total_committers":5,"mean_commits":49.0,"dds":"0.24489795918367352","last_synced_commit":"2a601fbd2af4a5a12d42bcfce9c5db3da5171425"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fdatar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fdatar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fdatar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fdatar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwwang","download_url":"https://codeload.github.com/pwwang/datar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157046,"owners_count":20893202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-manipulation","dplyr","forcats","groupby","pandas","tibble","tidyr","tidyverse","tribble"],"created_at":"2024-08-03T03:02:09.903Z","updated_at":"2025-04-04T10:05:28.505Z","avatar_url":"https://github.com/pwwang.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# datar\n\nA Grammar of Data Manipulation in python\n\n\u003c!-- badges --\u003e\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\u003c!-- ## Maximum compatibility with R packages\n\n|Package|Version|\n|-|-|\n|[dplyr][21]|1.0.8| --\u003e\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 \u003e\u003e mutate(z=f.x)\n\"\"\"# output\n        x        y       z\n  \u003cint64\u003e \u003cobject\u003e \u003cint64\u003e\n0       0     zero       0\n1       1      one       1\n2       2      two       2\n3       3    three       3\n\"\"\"\n\ndf \u003e\u003e mutate(z=if_else(f.x\u003e1, 1, 0))\n\"\"\"# output:\n        x        y       z\n  \u003cint64\u003e \u003cobject\u003e \u003cint64\u003e\n0       0     zero       0\n1       1      one       0\n2       2      two       1\n3       3    three       1\n\"\"\"\n\ndf \u003e\u003e filter_(f.x\u003e1)\n\"\"\"# output:\n        x        y\n  \u003cint64\u003e \u003cobject\u003e\n0       2      two\n1       3    three\n\"\"\"\n\ndf \u003e\u003e mutate(z=if_else(f.x\u003e1, 1, 0)) \u003e\u003e filter_(f.z==1)\n\"\"\"# output:\n        x        y       z\n  \u003cint64\u003e \u003cobject\u003e \u003cint64\u003e\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    \u003e\u003e mutate(y=sin(f.x), sign=if_else(f.y \u003e= 0, \"positive\", \"negative\"))\n    \u003e\u003e 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 \u003e\u003e pull(f.Sepal_Length) \u003e\u003e dist_plot()\n```\n\n![example](./example2.png)\n\n## Testimonials\n\n[@coforfe](https://github.com/coforfe):\n\u003e 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\u0026style=flat-square\n[11]: https://img.shields.io/github/actions/workflow/status/pwwang/datar/docs.yml?branch=master\u0026style=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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwwang%2Fdatar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwwang%2Fdatar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwwang%2Fdatar/lists"}