DataFrame vector to columns

I think you might be interested in this recent blog post from Bogumil - your case is explained in the section “Multiple target columns”.

Here the elements of list_data are iterable (as they are vectors), so in combination with multiple return columns they are split up. Your transformation col -> [el for el in col] does indeed not do anything:

julia> df.list_data == [el for el in df.list_data]
true

and so you could have shortened your example to

julia> transform(df, :list_data => identity => [:A,:B])
3×4 DataFrame
 Row │ data      list_data  A      B     
     │ Float64   Array…     Int64  Int64 
─────┼───────────────────────────────────
   1 │ 0.895446  [1, 2]         1      2
   2 │ 0.386052  [3, 4]         3      4
   3 │ 0.978884  [5, 6]         5      6

4 Likes