# DataFrames / Using variables into a push command to fill dataframes

**URL:** <https://discourse.julialang.org/t/dataframes-using-variables-into-a-push-command-to-fill-dataframes/18220>\
**Category:** General Usage\
**Tags:** dataframes\
**Created:** [December 2, 2018, 2:33pm UTC](https://discourse.julialang.org/t/dataframes-using-variables-into-a-push-command-to-fill-dataframes/18220 "2018-12-02T14:33:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Dubus](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@Patrick\_Dubus](https://discourse.julialang.org/u/Patrick_Dubus)\
**Post date:** [December 2, 2018, 2:33pm UTC](https://discourse.julialang.org/t/dataframes-using-variables-into-a-push-command-to-fill-dataframes/18220/1 "2018-12-02T14:33:14Z")

</div>

Hello  
After creation of a DataFrame:  
xd = DataFrame(name=String,typ=Float64,min=Float64,max=Float64,law=String,avg=Float64,std=Float64)

To simplify filling data, I used in the past the following command  
push!(xd,(name=“Voff”,typ=0,min=-850e-6,max=850e-6,law=“uniform”,avg=(max+min)/2,std=(max-min)/8))

avg and std (the two last column values) were calculated from other column values using the variable name of the other columns.

With Julia 1.0 and after, this seems not be possible anymore. What could be the solution to compute automatically avg and std (in one command line to simplify the data entry if possible).

Thanks for your help.  
Patrick.

---

<div class="post-metadata">

**Author:** ![y4lu](https://avatars.discourse-cdn.com/v4/letter/y/47e85d/32.png) [@y4lu](https://discourse.julialang.org/u/y4lu)\
**Post date:** [December 3, 2018, 2:08am UTC](https://discourse.julialang.org/t/dataframes-using-variables-into-a-push-command-to-fill-dataframes/18220/2 "2018-12-03T02:08:14Z")

</div>

`push!(df, [xinput; xvector])` is still ok, so maybe a helper function?

```julia
function pushFrame!(df, inpvec)
  xavg = (inpvec[3] + inpvec[4]) / 2;
  xstd = (inpvec[4] - inpvec[3]) / 8;
  push!(df, [inpvec; xavg; xstd]);
  end;

pushFrame!(xd, ["Voff"; 0; -850e-6; 850e-6; "uniform"]);

```

There may be other built-ins and ways of doing it

eg. `@assert inpvec[4] >= inpvec[3]` might make a nice addition to the above function

---

<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:** [December 3, 2018, 4:31am UTC](https://discourse.julialang.org/t/dataframes-using-variables-into-a-push-command-to-fill-dataframes/18220/3 "2018-12-03T04:31:07Z")

</div>

Yeah I don’t think this is possible right now.

This is a `NamedTuple` issue, since you can still push a `NamedTuple` to a `DataFrame`, you just can’t do the calculation on the fly. but I can’t comment on whether or not the constructor changed.
