Push! to vector of DataFrames

If I create an empty vector to hold DataFrames:
vecOfDFs = Vector{DataFrame}[]
(is that an ok way to do it? Are there better ways? )

And then I use push!(vecOfDFs, myNewDF) to add my myNewDF to vecOfDFs I get the error

MethodError: Cannot convert an object of type DataFrame to an object of type Array{DataFrame,1}

Closest candidates are:
convert(::Type{T<:Array}, !Matched::AbstractArray) where T<:Array at array.jl:489 convert(::Type{T<:AbstractArray}, !Matched::T<:AbstractArray) where T<:AbstractArray at abstractarray.jl:14 convert(::Type{T<:AbstractArray}, !Matched::LinearAlgebra.Factorization) where T<:AbstractArray at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/LinearAlgebra/src/factorization.jl:46 … Stacktrace: [1] push!(::Array{Array{DataFrame,1},1}, ::DataFrame) at ./array.jl:855 [2] transportAllCows(::DataFrame, ::Int64) at ./In[10]:8 [3] top-level scope at In[11]:1

That’s not a vector of dataframes, it’s a vector of vector of dataframes. Use vecOfDFs = DataFrame[]

1 Like

Ah, thank you. The devil is in the details

1 Like