Two things
- You can use the functions with Chain.jl. Chain.jl and DataFramesMeta.jl macros are not tied together in any way.
julia> df_new = @chain df begin
groupby(_, :g)
transform(groupindices => :gnum)
end
6×3 DataFrame
Row │ x g gnum
│ Float64 String Int64
─────┼──────────────────────────
1 │ 0.465506 c 1
2 │ 0.0945491 c 1
3 │ 0.512721 a 2
4 │ 0.444936 b 3
5 │ 0.631455 b 3
6 │ 0.667982 b 3
But also, you can use it with @transform as follows
julia> df_new = @chain df begin
groupby(_, :g)
@transform :gnum = $groupindices
end
6×3 DataFrame
Row │ x g gnum
│ Float64 String Int64
─────┼──────────────────────────
1 │ 0.465506 c 1
2 │ 0.0945491 c 1
3 │ 0.512721 a 2
4 │ 0.444936 b 3
5 │ 0.631455 b 3
6 │ 0.667982 b 3