Skip to content

special case percentage in combine #2272

@pdeffebach

Description

@pdeffebach

Currently combine special cases nrow to get the number of rows.

It's actually pretty hard to get the percentage of observations in a group when doing a combine operation. You have to do nrow before, then save that variable, then make a new nrow.

It might be worth considering adding something like

julia> df = DataFrame(
           sex = rand(["Man", "Woman", "Other"], 100), 
           race = rand(["White", "Black", "Other"], 100), 
           income = rand(100));

julia> combine(groupby(df, "race"), percentage)

be a shorthand for

N = nrow(parent(df))
n = nrow(sdf)
return n / N

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions