Skip to main content

Port of dplyr and other related R packages in python, using pipda.

Project description

datar

Port of dplyr and other related R packages in python, using pipda.

Unlike other similar packages in python that just mimic the piping sign, datar follows the API designs from the original packages as possible. So that nearly no extra effort is needed for those who are familar with those R packages to transition to python.

Pypi Github Building Docs and API Codacy Codacy coverage

Documentation | Reference Maps | Notebook Examples | API

Installtion

pip install -U datar

datar requires python 3.7.1+ and is backended by pandas (1.2+).

Example usage

from datar import f
from datar.dplyr import mutate, filter, if_else
from datar.tibble import tibble

df = tibble(
    x=range(4),
    y=['zero', 'one', 'two', 'three']
)
df >> mutate(z=f.x)
"""# output
   x      y  z
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
0  0   zero  0
1  1    one  0
2  2    two  1
3  3  three  1
"""

df >> filter(f.x>1)
"""# output:
   x      y
0  2    two
1  3  three
"""

df >> mutate(z=if_else(f.x>1, 1, 0)) >> filter(f.z==1)
"""# output:
   x      y  z
0  2    two  1
1  3  three  1
"""
# works with plotnine
import numpy
from datar.base import sin, pi
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.datasets import iris
from datar.dplyr import pull

dist_plot = register_verb(func=klib.dist_plot)
iris >> pull(f.Sepal_Length) >> dist_plot()

example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datar-0.0.5.tar.gz (945.7 kB view details)

Uploaded Source

Built Distribution

datar-0.0.5-py3-none-any.whl (971.0 kB view details)

Uploaded Python 3

File details

Details for the file datar-0.0.5.tar.gz.

File metadata

  • Download URL: datar-0.0.5.tar.gz
  • Upload date:
  • Size: 945.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.4.0-1047-azure

File hashes

Hashes for datar-0.0.5.tar.gz
Algorithm Hash digest
SHA256 9ea5a4302b5d494bfbc2f9f59566850c3f9be602e170968e5dbadebf3cf49303
MD5 6b213a9e58cd16fe169cfde4b83fcb94
BLAKE2b-256 265007ac2c3406866ebd03ada55d8affb896f3e070dfd8edae3661d9134d7485

See more details on using hashes here.

Provenance

File details

Details for the file datar-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: datar-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 971.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.4.0-1047-azure

File hashes

Hashes for datar-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3c7a87c81109bbf6bae10f9b070423487b412fd759164667dabd11fae789da4d
MD5 013c87b821799aa0bdaa60891a6a9b27
BLAKE2b-256 52cdc78c87abb0d85c792727ab89232b34e475cd6d9f730fc1333075f76aed21

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page