Deconstruct NamedTupleColumn with Prefix

Another option would be @unnest_wider from TidierData. It will automatically prefix the column names, but it will drop the original column which might add some performance benefit

julia> using TidierData; df = DataFrame(x = rand(2), y =[(a=1,b=2),(a=3,b=5)]);

julia> @time transform(df, :y => ByRow(t -> add_prefix(t, "y")) => AsTable)
  0.031335 seconds (67.12 k allocations: 3.632 MiB, 98.90% compilation time)
2×4 DataFrame
 Row │ x         y               y_a    y_b   
     │ Float64   NamedTup…       Int64  Int64 
─────┼────────────────────────────────────────
   1 │ 0.478783  (a = 1, b = 2)      1      2
   2 │ 0.741308  (a = 3, b = 5)      3      5

julia> @time @unnest_wider(df, y)
  0.000086 seconds (96 allocations: 4.539 KiB)
2×3 DataFrame
 Row │ x         y_a    y_b   
     │ Float64   Int64  Int64 
─────┼────────────────────────
   1 │ 0.478783      1      2
   2 │ 0.741308      3      5
1 Like