Closed machow closed 1 year ago
This could use a section of its own in the guide, but is now handled using the Fx
object. See the across docs for details
https://siuba.org/guide/programming-across.html#basic-use
from siuba import _, across, Fx, group_by, mutate, summarize, filter, arrange
from siuba.data import mtcars
mtcars >> summarize(across(_[_.startswith("m"), _.endswith("p")], Fx.mean()))
dplyr functions like
across
allow you to apply an operation to each of a set of selected columns, using syntax of this form:across(<column selection>, <column application>)
Importantly, the column application step allows you to refer to both...
This means that siuba needs to differentiate...
_.some_column
)Looking broadly at siuba's pipe and call behavior, there are many cases where this could surface. E.g. basically anywhere a lambda might surface in a
call()
:fct_reorder(_.cyl, _.mpg, lambda x: -x.mean())
cf: https://github.com/machow/siuba/pull/413