I cannot insert the new row to the dataframe. Any suggestions? Thanks!
julia> my_data = DataFrame(A = repeat(["test"], 5), B = repeat([100], 5), C = repeat(["100%"], 5))
5×3 DataFrame
Row │ A B C
│ String Int64 String
─────┼───────────────────────
1 │ test 100 100%
2 │ test 100 100%
3 │ test 100 100%
4 │ test 100 100%
5 │ test 100 100%
julia> new = pushfirst!(Array{Any, 1}(missing, ncol(my_data)-1), "new_test")
3-element Vector{Any}:
"new_test"
missing
missing
julia> insert!.(eachcol(my_data), 3, new)
ERROR: MethodError: Cannot `convert` an object of type Missing to an object of type Int64
Closest candidates are:
convert(::Type{T}, ::Ptr) where T<:Integer at pointer.jl:23
convert(::Type{IT}, ::GeometryBasics.OffsetInteger) where IT<:Integer at /Users/xzhong/.julia/packages/GeometryBasics/wFus0/src/offsetintegers.jl:40
convert(::Type{T}, ::SentinelArrays.ChainedVectorIndex) where T<:Union{Signed, Unsigned} at /Users/xzhong/.julia/packages/SentinelArrays/VbnBp/src/chainedvector.jl:209
...
I suggest that you do not name a vector new as this is a reserved keyword (in some contexts) in Julia.
Also, the types of your new row are not compatible with the DataFrame.
Try this