Skip to content

Commit

Permalink
0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
pwwang committed May 7, 2021
1 parent bc4273a commit 8a73146
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ repos:
rev: 5df1a4bf6f04a1ed3a643167b38d502575e29aef
hooks:
- id: trailing-whitespace
exclude: 'docs/'
exclude: 'docs/|README\.rst'
- id: end-of-file-fixer
exclude: 'docs/'
exclude: 'docs/|README\.rst'
- id: check-yaml
exclude: 'mkdocs.yml'
- repo: local
Expand Down
130 changes: 130 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
.. role:: raw-html-m2r(raw)
:format: html


datar
=====

Port of `dplyr <https://dplyr.tidyverse.org/index.html>`_ and other related R packages in python, using `pipda <https://github.com/pwwang/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.

:raw-html-m2r:`<!-- badges -->`
`
.. image:: https://img.shields.io/pypi/v/datar?style=flat-square
:target: https://img.shields.io/pypi/v/datar?style=flat-square
:alt: Pypi
<https://pypi.org/project/datar/>`_ `
.. image:: https://img.shields.io/github/v/tag/pwwang/datar?style=flat-square
:target: https://img.shields.io/github/v/tag/pwwang/datar?style=flat-square
:alt: Github
<https://github.com/pwwang/datar>`_
.. image:: https://img.shields.io/github/workflow/status/pwwang/datar/Build%20and%20Deploy?style=flat-square
:target: https://img.shields.io/github/workflow/status/pwwang/datar/Build%20and%20Deploy?style=flat-square
:alt: Building
`
.. image:: https://img.shields.io/github/workflow/status/pwwang/datar/Build%20Docs?label=Docs&style=flat-square
:target: https://img.shields.io/github/workflow/status/pwwang/datar/Build%20Docs?label=Docs&style=flat-square
:alt: Docs and API
<https://pwwang.github.io/datar/>`_ `
.. image:: https://img.shields.io/codacy/grade/3d9bdff4d7a34bdfb9cd9e254184cb35?style=flat-square
:target: https://img.shields.io/codacy/grade/3d9bdff4d7a34bdfb9cd9e254184cb35?style=flat-square
:alt: Codacy
<https://app.codacy.com/gh/pwwang/datar>`_ `
.. image:: https://img.shields.io/codacy/coverage/3d9bdff4d7a34bdfb9cd9e254184cb35?style=flat-square
:target: https://img.shields.io/codacy/coverage/3d9bdff4d7a34bdfb9cd9e254184cb35?style=flat-square
:alt: Codacy coverage
<https://app.codacy.com/gh/pwwang/datar>`_

`Documentation <https://pwwang.github.io/datar/>`_ | `Reference Maps <https://pwwang.github.io/datar/reference_maps/ALL/>`_ | `Notebook Examples <https://pwwang.github.io/datar/notebooks/across/>`_ | `API <https://pwwang.github.io/datar/api/datar/>`_

Installtion
-----------

.. code-block:: shell
pip install -U datar
``datar`` requires python 3.7.1+ and is backended by ``pandas (1.2+)``.

Example usage
-------------

.. code-block:: python
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
"""
.. code-block:: python
# 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)
.. image:: ./example.png
:target: ./example.png
:alt: example


.. code-block:: python
# 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()
.. image:: ./example2.png
:target: ./example2.png
:alt: example

2 changes: 1 addition & 1 deletion datar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from .core import operator as _datar_operator
from .core.defaults import f

__version__ = '0.0.3'
__version__ = '0.0.4'
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.0.4
- Finish port of tibble.

## 0.0.3
- Add stats.weighted_mean
- Allow function to prefer recycling input or output for summarise
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[tool.poetry]
name = "datar"
version = "0.0.3"
description = "Port of R data packages tidyr, dplyr, tibble and so on in python"
version = "0.0.4"
description = "Port of dplyr and other related R packages in python, using pipda."
authors = ["pwwang <[email protected]>"]
readme = "README.md"
license = "MIT"
homepage = "https://github.com/pwwang/datar"
repository = "https://github.com/pwwang/datar"

[tool.poetry.dependencies]
python = "^3.7.1" # align with pandas
Expand Down
15 changes: 13 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@
except ImportError:
from distutils.core import setup


import os.path

readme = ''
here = os.path.abspath(os.path.dirname(__file__))
readme_path = os.path.join(here, 'README.rst')
if os.path.exists(readme_path):
with open(readme_path, 'rb') as stream:
readme = stream.read().decode('utf8')


setup(
long_description=readme,
name='datar',
version='0.0.3',
description='Port of R data packages tidyr, dplyr, tibble and so on in python',
version='0.0.4',
description='Port of dplyr and other related R packages in python, using pipda.',
python_requires='==3.*,>=3.7.1',
project_urls={"homepage": "https://github.com/pwwang/datar",
"repository": "https://github.com/pwwang/datar"},
author='pwwang',
author_email='[email protected]',
license='MIT',
Expand Down

0 comments on commit 8a73146

Please sign in to comment.