How to combine and make an array into a cell of DataFrames.jl?

14 Views Asked by At

Let say

df = DataFrame(a=[1])
 Row │ a
     │ Int64
─────┼───────
   1 │     1

We have

  1. Tried to combine data and make a new column holding arrays
combine(df, :a => x->[1,2])
 Row │ a_function
     │ Int64
─────┼────────────
   1 │          1
   2 │          2
  1. Tried to combine data and make a new column holding tuples

combine(df, :a => x->(1,2))
 Row │ a_function
     │ Tuple…
─────┼────────────
   1 │ (1, 2)

Why 1 doesn't work as intended, i.e. holding the whole [1,2] array in one cell instead of creating 2 rows?

I converted the array into a tuple and it worked, but I wonder why they works in so different ways.

0

There are 0 best solutions below