I don’t have much more to add, I even rerun the code but initializing the columns with the type as a string, and still:
The two columns before them are fine, but no matter what i do these have type
Any
, and that’s making my code throw errors later on
How are you initializing?
julia> A = Array{Float64}(undef, 4, 4)
4×4 Matrix{Float64}:
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
julia> df = DataFrame(A, :auto)
4×4 DataFrame
Row │ x1 x2 x3 x4
│ Float64 Float64 Float64 Float64
─────┼────────────────────────────────────
1 │ 0.0 0.0 0.0 0.0
2 │ 0.0 0.0 0.0 0.0
3 │ 0.0 0.0 0.0 0.0
4 │ 0.0 0.0 0.0 0.0
I used some arrays of floats i constructed before.
Oh, i found the problem. I was initializing the vectors as []
, with no values inside them and no type, so they stayed as Vector{Any}
s.
Changing the declarations to Vector{Float64}()
solved the problem.
2 Likes
You can use also Float64[]
(and more generally T[]
) to initialize an empty vector or Float64…
1 Like