DataFrames / Using variables into a push command to fill dataframes



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

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.


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

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

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


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.