How to split up a Float column in array or dataframe (not String)

Hello, there are a few topics about splitting up columns in a Dataframe or Table that are strings e.g.
https://discourse.julialang.org/t/juliadb-split-one-column-into-n-columns/20718
https://stackoverflow.com/questions/57184663/how-to-convert-comma-separated-values-in-a-dataframe-cell-into-an-array-in-julia

But I cannot find how to do this with Floats.

I have an array/DataFrame (first I create the array and later I turn it into a dataframe) and I want to split up the second column into five parts.

 Row   │ Time    │ x2                                                  │
│       │ Any     │ Any                                                 │
├───────┼─────────┼─────────────────────────────────────────────────────┤
│ 1     │ 0.0     │ (0.00912906, 0.70303, 0.182395, -3.25295, 1.90496)  │
│ 2     │ 1.0     │ (0.00915032, 0.70303, 0.182026, -3.25192, 1.9049)   │
│ 3     │ 2.0     │ (0.00917156, 0.70303, 0.181659, -3.2509, 1.90485)   │
│ 4     │ 3.0     │ (0.00919279, 0.70303, 0.181295, -3.24988, 1.90479)  │

MWE

Time= 0.0
x2 = (0.00912906, 0.70303, 0.182395, -3.25295, 1.90496)
data_frame_test = [Time x2]

With String this is done by DataFrame(split.(data_frame_test, ",")) but this doesn’t apply here. Any suggestions?

Time= 0.0
x2 = (0.00912906, 0.70303, 0.182395, -3.25295, 1.90496)
data_frame_test = [Time x2...]
dt = DataFrame(data_frame_test)

Note the … in data_frame_test. This i called splatting.

Thank you for your reply. Your suggestion is correct for my MWE.

I receive an error and see my MWE was not correct. Unfortunately I do not know how to make a different MWE. In this case, x2 is a Vector{NTuple{5,Float64}}.

I receive the error

DimensionMismatch("mismatch in dimension 1 (expected 50001 got 1)")
in top-level scope at Schneider et al 2016 running.jl:220
in hcat at base\abstractarray.jl:1544
in  at base\abstractarray.jl:1564
in #cat#110 at base\abstractarray.jl:1564
in _cat at base\abstractarray.jl:1435
in  at base\abstractarray.jl:1437
in #cat_t#109 at base\abstractarray.jl:1437
in _cat_t at base\abstractarray.jl:1440
in cat_shape at base\abstractarray.jl:1395
in cat_shape at base\abstractarray.jl:1395
in _cshp at base\abstractarray.jl:1416 
in _cs at base\abstractarray.jl:1420

Is it something like the following?

julia> x2 = [(1,2,3)]
1-element Array{Tuple{Int64,Int64,Int64},1}:
 (1, 2, 3)

julia> x2[1]
 (1, 2, 3)

If so, try to change line

data_frame_test = [Time x2...]

to

data_frame_test = [Time x2[1]...]

You want a broadcasted getindex

julia> 
julia> df = DataFrame(a = [(rand(), rand()) for i in 1:10]);

julia> for i in 1:2
       df[:, "a$i"] = getindex.(df.a, i)
       end;

julia> df
10×3 DataFrame
│ Row │ a                      │ a1        │ a2        │
│     │ Tuple{Float64,Float64} │ Float64   │ Float64   │
├─────┼────────────────────────┼───────────┼───────────┤
│ 1   │ (0.856342, 0.307311)   │ 0.856342  │ 0.307311  │
│ 2   │ (0.0181747, 0.899767)  │ 0.0181747 │ 0.899767  │
│ 3   │ (0.637947, 0.155305)   │ 0.637947  │ 0.155305  │
│ 4   │ (0.641775, 0.33356)    │ 0.641775  │ 0.33356   │
│ 5   │ (0.292641, 0.33817)    │ 0.292641  │ 0.33817   │
│ 6   │ (0.0669127, 0.0544888) │ 0.0669127 │ 0.0544888 │
│ 7   │ (0.880316, 0.655488)   │ 0.880316  │ 0.655488  │
│ 8   │ (0.812024, 0.0369003)  │ 0.812024  │ 0.0369003 │
│ 9   │ (0.742961, 0.78381)    │ 0.742961  │ 0.78381   │
│ 10  │ (0.377581, 0.257949)   │ 0.377581  │ 0.257949  │

When I use your example code, I get

ERROR: MethodError: no method matching setindex!(::DataFrame, ::Array{Float64,1}, ::String)

@BLI It still wasn’t working so I resaved it as a Vector{Float64} and it works now.

What version of DataFrames are you using?

  [a93c6f00] DataFrames v0.20.2

If you update DataFrames, you will be able to do df[:, "a string"] rather than using symbols everywhere. But my code snipped above works if you replace df[:, "a$i"] with df[:, Symbol(:a, i)].