# Initializing a dataframe

**URL:** <https://discourse.julialang.org/t/initializing-a-dataframe/35933>\
**Category:** New to Julia\
**Created:** [March 13, 2020, 4:22pm UTC](https://discourse.julialang.org/t/initializing-a-dataframe/35933 "2020-03-13T16:22:30Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 15, 2020, 7:08am UTC](https://discourse.julialang.org/t/initializing-a-dataframe/35933/22 "2020-03-15T07:08:24Z")

</div>

> [@erlebach](#):
>
> Creating easy to use functionality that is not simple with the current structure of julia and packaging it for the user.
> 
> I am open to any suggestions you might have. This little excursion has taught me about NamedTuples, Structures, zip, loops of various kinds and the most basic form of metaprogramming.

I suspect that there is a simple and idiomatic solution, but I have to admit that with this meandering topic I no longer have a clear idea what the problem is.

If you want collect the arguments a function was called with, you could define a container and make it callable. Eg

```julia
struct CollectingVector{T}
    vector::Vector{T}
end

CollectingVector{T}() where T = CollectingVector(Vector{T}())

function (cv::CollectingVector)(x)
    push!(cv.vector, x)
    nothing
end

julia> cv = CollectingVector{typeof((J_δ = 1.0, c = 1.0))}(); # template for type

julia> cv((J_δ = 1, c = 2))

julia> cv.vector
1-element Array{NamedTuple{(:J_δ, :c),Tuple{Float64,Float64}},1}:
 (J_δ = 1.0, c = 2.0)

```

You [almost certainly don’t need metaprogramming](https://discourse.julialang.org/t/how-to-warn-new-users-away-from-metaprogramming/35022), but instead of learning about very basic things like loops and composite types (`stuct`) in the course of solving the problem, you may benefit from just working through the manual first.

Julia is a powerful language, but you won’t be able to harness that power without making an initial investment in some structured form.

---

_[View the full topic](https://discourse.julialang.org/t/initializing-a-dataframe/35933)._
