julia> transform!(groupby(df, :id), :x1 => first)
9×4 DataFrame
Row │ id x1 x2 x1_first
│ Int64 Int64 Int64 Int64
─────┼───────────────────────────────
1 │ 1 1 10 1
2 │ 1 4 13 1
3 │ 1 7 16 1
4 │ 2 2 11 2
5 │ 2 5 14 2
6 │ 2 8 17 2
7 │ 3 3 12 3
8 │ 3 6 15 3
9 │ 3 9 18 3
1 Like