Transform multiple columns of a DataFrame using the same function

Just broadcast the pair operator:

julia> transform!(df, [:a, :c] .=> (x -> 2x) .=> [:a, :c])
3×3 DataFrame
 Row │ a      b      c     
     │ Int64  Int64  Int64 
─────┼─────────────────────
   1 │     2      4     14
   2 │     4      5     16
   3 │     6      6     18

(no need for ByRow as you can just double the whole vector).

7 Likes