Name of dataframe column created by function

I’m not sure I understand the question - you are showing in your example how you can specify the name of the created column, and you can do that for your weighted mean function as well?

julia> transform(gdf, [:Income, :Weight] => ((x, y) -> (mean(x, weights(y)))) => :Income_weighted) # Income weighted
6×4 DataFrame
 Row │ Region  Income  Weight  Income_weighted 
     │ String  Int64   Int64   Float64         
─────┼─────────────────────────────────────────
   1 │ state1      10      51         10.7134
   2 │ state1       7      20         10.7134
   3 │ state1      12      86         10.7134
   4 │ state2      10      75          8.41204
   5 │ state2       7     125          8.41204
   6 │ state2      12      16          8.41204

1 Like