-
Hey there, Quickly checking for the presence of NaN in the data frame using datar works fine (as expected): Question: Thanks a lot for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi Gernot, It's all about You can simply check whether a function is registered as a >>> from datar import base
>>> from pipda import Function, Verb
>>> base.any_na
<datar.core.factory.DatarAggFunction object at 0x7f730eff25b0>
>>> from pipda import Function
>>> isinstance(base.any_na, Function)
True
>>> base.dim
<pipda.verb.Verb object at 0x7f730ef78b50>
>>> isinstance(base.dim, Verb)
True A verb is a function that is able to accept the arguments except the first, which is the data, and wait for it to be piped in. For example, Why just register all functions as Theoretically, yes. But would cause confusion in this scenario: >>> from datar import f
>>> from datar.base import as_character
>>> from datar.dplyr import everything, mutate, across
>>> from datar.datasets import table3
>>> table3
country year rate
<object> <int64> <object>
0 Afghanistan 1999 745/19987071
1 Afghanistan 2000 2666/20595360
2 Brazil 1999 37737/172006362
3 Brazil 2000 80488/174504898
4 China 1999 212258/1272915272
5 China 2000 213766/1280428583
>>> table3 >> mutate(across(everything(), as_character))
country year rate
<object> <object> <object>
0 Afghanistan 1999 745/19987071
1 Afghanistan 2000 2666/20595360
2 Brazil 1999 37737/172006362
3 Brazil 2000 80488/174504898
4 China 1999 212258/1272915272
5 China 2000 213766/1280428583 It worked just fine, as @register_verb(DataFrame)
def as_character(_data, x):
return ... Even though There is a way to work around it. For example, check if Ideas are welcome for solving this issue and making all functions |
Beta Was this translation helpful? Give feedback.
-
I've gone through the cases and found that r$> df = tibble(x=1:3, y=4:6)
r$> df = tibble(y=df)
r$> df
# A tibble: 3 × 1
y$x $y
<int> <int>
1 1 4
2 2 5
3 3 6
r$> df |> mutate(across(everything(), ~ select(.x, "x"))) # need to pass .x proun to refer the data, it is explicitly passed.
# A tibble: 3 × 1
y$x
<int>
1 1
2 2
3 3 That means, we just need to pass the arguments literally to the function used in So we should be able to register all functions as |
Beta Was this translation helpful? Give feedback.
Hi Gernot,
It's all about
Verb
vsFunction
, which are registered byregister_verb()
andregister_func()
frompipda
.You can simply check whether a function is registered as a
Verb
orFunction
by:A verb is a function that is able to accept the arguments except the first, which is the data, and wait for it to be piped in. For example,
df >> base.dim()
. However,Function
just literally a…