[1]:
import pandas as pd
pd.set_option("display.max_rows", 5)
Transmute¶
This function is equivalent doing a mutate
, followed by a select
to keep the recently defined columns. Currently the way it works is…
Positional arguments are used to select columns
Named arguments are used as in mutate
[2]:
from siuba import _, transmute
from siuba.data import mtcars
[3]:
mtcars >> transmute(_.cyl, _.mpg, hp_per_cyl = _.hp / _.cyl)
[3]:
cyl | mpg | hp_per_cyl | |
---|---|---|---|
0 | 6 | 21.0 | 18.333333 |
1 | 6 | 21.0 | 18.333333 |
... | ... | ... | ... |
30 | 8 | 15.0 | 41.875000 |
31 | 4 | 21.4 | 27.250000 |
32 rows × 3 columns
Edit page on github here. Interactive version: