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

AttributeError: 'NoneType' object has no attribute 'x'[BUG]

rleyvasal 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

I am running the plotnine example on the repo page and I get an error message AttributeError: 'NoneType' object has no attribute 'x' when running the code below.

# works with plotnine
# example grabbed from https://github.com/has2k1/plydata

from datar import f  # this line not in the documentation

import numpy
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)
)

Also, can you add from datar import f line of code to the the documentation example? - without it, the code does not run

Expected Behavior

Running the code show plotnine plot

Installed Versions

python : 3.8.12 (default, Oct 12 2021, 03:01:40) [MSC v.1916 64 bit (AMD64)] datar : 0.8.5 numpy : 1.22.3 pipda : 0.6.0 executing: 0.8.0 varname : 0.8.2 pandas : 1.4.1
commented

datar 0.8.5 is out of date. Can you try the latest version?

It works in the latest version of datar, after running:

pip install -U datar
pip install -U datar[pandas]

Note: from datar import f line still needs to be added for the code to run.

commented

Mind submitting a PR?

Submitted PR