# Best julian way to populate empty dataframes?

**URL:** https://discourse.julialang.org/t/best-julian-way-to-populate-empty-dataframes/30768
**Category:** General Usage
**Created:** [November 5, 2019, 9:20pm UTC](https://discourse.julialang.org/t/best-julian-way-to-populate-empty-dataframes/30768 "2019-11-05T21:20:13Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bashonubuntu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)
#### Post date: [November 5, 2019, 9:20pm UTC](https://discourse.julialang.org/t/best-julian-way-to-populate-empty-dataframes/30768/1 "2019-11-05T21:20:14Z")

</div>

Hello,

Often times in what I code, I need to populate an empty dataframe based on some pre-existing dataframe which is called inside a function. For example,

```julia
function populate_meta_data(data::R) where {R<:DataFrame}
    data_1 = manipulate(data) #do something with data to return some new dataframe
    meta_data = DataFrame() #start populating empty dataframe meta_data column-wise 
    meta_data[!, :a_new] = data_1[!, :a]
    meta_data[!, :b_new] = data_1[!, :b]
 return meta_data
end

```

What is the most performant way to do such operations?

---

<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: [November 5, 2019, 11:34pm UTC](https://discourse.julialang.org/t/best-julian-way-to-populate-empty-dataframes/30768/2 "2019-11-05T23:34:05Z")

</div>

That seems fine. Though be careful with the `!` syntax. You probably want to use a colon `:` so that operations that manipulate vectors in `meta_data` don’t affect the vectors in `data_1`.

---

<div class="post-metadata">

### Author: ![bashonubuntu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)
#### Post date: [November 6, 2019, 12:50am UTC](https://discourse.julialang.org/t/best-julian-way-to-populate-empty-dataframes/30768/3 "2019-11-06T00:50:24Z")

</div>

Yes, I am careful regarding that aspect and thanks for flagging it! Probably safer to use colon on the RHS of the assignment.
