# Is there a way to fill a dataframe with values from a smaller dataframe?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-fill-a-dataframe-with-values-from-a-smaller-dataframe/49912>\
**Category:** New to Julia\
**Created:** [November 10, 2020, 1:38pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-fill-a-dataframe-with-values-from-a-smaller-dataframe/49912 "2020-11-10T13:38:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Post date:** [November 10, 2020, 1:38pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-fill-a-dataframe-with-values-from-a-smaller-dataframe/49912/1 "2020-11-10T13:38:40Z")

</div>

I was hoping to be able to fill a larger `DataFrame` with the values of a smaller one using `fill()` but it doesn’t work this way. I can create a new `DataFrame` using `vcat` but was hoping for a better method.

```julia
using DataFrames
df_test = DataFrame(a = repeat([1:2;], inner = [2]),
                 b = repeat([1;], inner = [4]),
                 c = randn(4))

df_test2 = DataFrame(zeros(16,3))

df_test3 = fill(df_test2,df_test) # does not work

df_test_4 = vcat(df_test,df_test,df_test,df_test) # does work, but more 'work' or not as elegant

```

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [November 10, 2020, 1:41pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-fill-a-dataframe-with-values-from-a-smaller-dataframe/49912/2 "2020-11-10T13:41:33Z")

</div>

It is intentional that this does not work. In Julia, as opposed to R we are strict about object dimensions. However, what works cleanly is:

```julia
repeat(df_test, 4)

```

as this is the thing you are looking for - right?

---

<div class="post-metadata">

**Author:** ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Post date:** [November 10, 2020, 1:43pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-fill-a-dataframe-with-values-from-a-smaller-dataframe/49912/3 "2020-11-10T13:43:27Z")

</div>

Yes, thank you!
