Counts of unique values per group in a DataFrame

In Query, how do would you put this in a function? With dataframes it’s

function combinecount(df, groupvars, newvar)
    @pipe df |> 
        groupby(df, groupvars) |> 
        combine(nrow => newvar)
end
3 Likes