MIT License

项目介绍

pwwang/datar 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 MIT License 许可证,目前获得 289 个 Star、21 次 Fork。

仓库全名
pwwang/datar
开源许可证
MIT License
Star 数
289
Fork 数
21
未关闭 Issue
8

README 摘要

datar A Grammar of Data Manipulation in python [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 Backends Example usage Testimonials @coforfe: Thanks for your excellent package to port R (dplyr) flow of…

完整内容见 GitHub 原始 README 或本页 。

常见问题

datar 用什么语言开发?

主要使用 Python 编写,采用 MIT License 许可证,目前有 289 个 Star。

datar 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 datar 的源码?

可以直接克隆仓库:git clone https://github.com/pwwang/datar.git,默认分支为 master;安装与运行步骤见仓库 README。

datar 最近还在维护吗?

仓库最近一次更新为 3 周前,当前有 8 个未关闭 Issue;Star 数为 289,可作为社区活跃度的参考。

关于

A Grammar of Data Manipulation in python

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
340
价值分
180
活跃状态
活跃

语言占比

Dockerfile
Python
Shell

Release

README

datar

A Grammar of Data Manipulation in python

Pypi Github Building Docs and API Codacy Codacy coverage Downloads

Documentation | Reference Maps | Notebook Examples | API

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

pip install -U datar

# install with a backend
pip install -U datar[pandas]

# or
pip install -U datar[polars]

Backends

Repo Badges
datar-numpy 3 18
datar-pandas 4 19
datar-arrow 23 24
datar-polars 25

Example usage

# 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
"""
# 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

# 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

Testimonials

@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.

评论

暂无评论