group_trim
In [1]:
Copied!
# https://dplyr.tidyverse.org/reference/group_trim.html
%run nb_helpers.py
from datar.all import *
nb_header(group_trim)
# https://dplyr.tidyverse.org/reference/group_trim.html
%run nb_helpers.py
from datar.all import *
nb_header(group_trim)
In [3]:
Copied!
df = tibble(x=factor(["a", "b"], levels=list("abc")))
df >> group_by(f.x, _drop=False) >> group_data()
df = tibble(x=factor(["a", "b"], levels=list("abc")))
df >> group_by(f.x, _drop=False) >> group_data()
Out[3]:
x | _rows | |
---|---|---|
<category> | <object> | |
0 | a | [0] |
1 | b | [1] |
2 | c | [] |
In [4]:
Copied!
df >> group_by(f.x, _drop=False) >> group_trim() >> group_data()
df >> group_by(f.x, _drop=False) >> group_trim() >> group_data()
Out[4]:
x | _rows | |
---|---|---|
<category> | <object> | |
0 | a | [0] |
1 | b | [1] |