Is there an equivalent to dplyr::across

So I am trying to switch my employer’s credit modeling code base over to Julia but am running into issues with wide datasets. In R you can apply a function to multiple columns columnwise, for example using dplyr to square each column except species you could do something like this:

iris %>%
                function(x) {x^2}

Is there an equivalent style of operation to this in DataFrames?

You can use names(df, Not(r"species")) to get all the columns that dont contain species.

Then you can broadcast the function t -> t^2 across this vector to get a vector of pairs. Then use this as an input to transform.

 transform(df, names(df,Not(r"species")) .=> ByRow(t -> t^2))

PS this comparison in the latest version of the DataFrames documentation will be really useful.

1 Like

That comparison is a game changer. Thanks