Here is the code in DataFrames
:
@chain DataFrame(tbl) begin
dropmissing([:NT_GER, :NT_FG, :NT_CE])
groupby([:TP_SEXO, :CO_TURNO_GRADUACAO], skipmissing=true)
combine(nrow,
[:NT_GER, :NT_FG, :NT_CE] .=> mean)
end
how do I do it in Query.jl
but using a single instruction to @map
to mean. I have to keep repeating myself like this:
Tables.datavaluerows(tbl) |>
@dropna(:NT_GER, :NT_FG, :NT_CE, :TP_SEXO, :CO_TURNO_GRADUACAO) |>
@groupby({_.TP_SEXO, _.CO_TURNO_GRADUACAO}) |>
@map({
sexo = key(_)[1],
turno = key(_)[2],
nrows = length(_),
NT_GER_mean = mean(_.NT_GER),
NT_FG_mean = mean(_.NT_FG),
NT_CE_mean = mean(_.NT_CE)
}) |>
DataFrame
Is there something like?:
@map({
sexo = key(_)[1],
turno = key(_)[2],
nrows = length(_),
{_.NT_GER, _.NT_FG, _.NT_CE} = mean(_)
})