# Push! to vector of DataFrames

**URL:** <https://discourse.julialang.org/t/push-to-vector-of-dataframes/15854>\
**Category:** General Usage\
**Tags:** dataframes\
**Created:** [October 4, 2018, 1:40am UTC](https://discourse.julialang.org/t/push-to-vector-of-dataframes/15854 "2018-10-04T01:40:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![natemcintosh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natemcintosh/32/9021_2.png) [@natemcintosh](https://discourse.julialang.org/u/natemcintosh)\
**Post date:** [October 4, 2018, 1:40am UTC](https://discourse.julialang.org/t/push-to-vector-of-dataframes/15854/1 "2018-10-04T01:40:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [October 4, 2018, 1:52am UTC](https://discourse.julialang.org/t/push-to-vector-of-dataframes/15854/2 "2018-10-04T01:52:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![natemcintosh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natemcintosh/32/9021_2.png) [@natemcintosh](https://discourse.julialang.org/u/natemcintosh)\
**Post date:** [October 4, 2018, 1:37pm UTC](https://discourse.julialang.org/t/push-to-vector-of-dataframes/15854/3 "2018-10-04T13:37:43Z")

</div>

Ah, thank you. The devil is in the details
