pwwang / datar

A Grammar of Data Manipulation in python

Home Page:https://pwwang.github.io/datar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot import name 'filter' from 'datar.dplyr'

luifrancgom opened this issue · comments

datar version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of datar and its backends.

Issue Description

When I try to reproduce the following example:

# with pandas backend
from datar import f, get_versions
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)

df >> mutate(z=if_else(f.x>1, 1, 0)) >> filter(f.z==1)

I get the following error ImportError: cannot import name 'filter' from 'datar.dplyr'

My session info is the following:

-----
datar               0.15.3
datar_pandas        0.5.3
pipda               0.13.1
session_info        1.0.0
-----
Python 3.10.9 (main, Mar  1 2023, 18:23:06) [GCC 11.2.0]
Linux-6.2.0-37-generic-x86_64-with-glibc2.35
-----
Session information updated at 2023-12-06 12:59

Expected Behavior

I want to obtain the following result with the code df >> mutate(z=if_else(f.x>1, 1, 0)) >> filter(f.z==1):

        x        y       z
  <int64> <object> <int64>
0       2      two       1
1       3    three       1

Installed Versions

python : 3.10.9 (main, Mar 1 2023, 18:23:06) [GCC 11.2.0]
datar : 0.15.3
simplug : 0.3.2
executing : 2.0.1
pipda : 0.13.1
datar-numpy : 0.3.2
numpy : 1.26.2
datar-pandas: 0.5.3
pandas : 2.1.1