# I have a list of dataframes with the same columns, how would I stack them on top of each other and make one dataframe?

**URL:** <https://discourse.julialang.org/t/i-have-a-list-of-dataframes-with-the-same-columns-how-would-i-stack-them-on-top-of-each-other-and-make-one-dataframe/36495>\
**Category:** General Usage\
**Created:** [March 25, 2020, 2:12pm UTC](https://discourse.julialang.org/t/i-have-a-list-of-dataframes-with-the-same-columns-how-would-i-stack-them-on-top-of-each-other-and-make-one-dataframe/36495 "2020-03-25T14:12:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Post date:** [March 25, 2020, 2:12pm UTC](https://discourse.julialang.org/t/i-have-a-list-of-dataframes-with-the-same-columns-how-would-i-stack-them-on-top-of-each-other-and-make-one-dataframe/36495/1 "2020-03-25T14:12:08Z")

</div>

Hi how’s it going,

I tried using hcat to stack each of these dataframes on top of each other, but it’s not really working as intended. I want to combine a list of dataframes, all with the same column names, into one big dataframe

Thanks

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [March 25, 2020, 2:26pm UTC](https://discourse.julialang.org/t/i-have-a-list-of-dataframes-with-the-same-columns-how-would-i-stack-them-on-top-of-each-other-and-make-one-dataframe/36495/2 "2020-03-25T14:26:03Z")

</div>

you want `vcat`, for _v_ertical concatenation as opposed to hcat for _h_orizontal concatenation.

```julia
julia> dfs= [DataFrame(rand(5,2)) for i in 1:5]
julia> reduce(vcat, dfs)

```

If you dataframes don’t have the same columns and you want to stack them on top of one another, filling in missing columns with `missing`s, you can do

```julia
julia> dfs= [isodd(i) ? DataFrame(rand(5, 2)) : DataFrame(rand(5, 3)) for i in 1:5]
julia> reduce(vcat, dfs, cols = :union)

```

---

<div class="post-metadata">

**Author:** ![rvasil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rvasil/32/3821_2.png) [@rvasil](https://discourse.julialang.org/u/rvasil)\
**Post date:** [March 25, 2020, 3:27pm UTC](https://discourse.julialang.org/t/i-have-a-list-of-dataframes-with-the-same-columns-how-would-i-stack-them-on-top-of-each-other-and-make-one-dataframe/36495/3 "2020-03-25T15:27:49Z")

</div>

or “reduce” typing 🙂 with:

```julia
df_union = vcat(dfs..., cols = :union)

```

---

<div class="post-metadata">

**Author:** ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Post date:** [March 25, 2020, 4:05pm UTC](https://discourse.julialang.org/t/i-have-a-list-of-dataframes-with-the-same-columns-how-would-i-stack-them-on-top-of-each-other-and-make-one-dataframe/36495/4 "2020-03-25T16:05:51Z")

</div>

Thanks guys!
