Skip to content

Suggestion #28

@rparente16

Description

@rparente16

LOVE this function. Would love even more if there was an option to do nway=True so that it would add all combinations. For example:

CURRENT:
df.groupby(['sex', 'class','city']).agg({'fare': ['sum']}).stb.subtotal(nway=True)

sex class city Count
Female First Melbourne 5
Female First Burbank 10
Female First Female/First Subtotal 15
Female Second Melbourne 3
Female Second Burbank 6
Female Second Female/Second Subtotal 9
Female Female Subtotal 24
Male First Melbourne 10
Male First Burbank 15
Male First Male/First Subtotal 25
Male Second Melbourne 9
Male Second Burbank 3
Male Second Male/Second Subtotal 12
Male Male Subtotal 37

NEW ROWS:

sex class city Count
Female Female/City Subtotal Melbourne 8
Female Female/City Subtotal Burbank 16
Male Male/City Subtotal Melbourne 19
Male Male/City Subtotal Burbank 18
First/Burbank Subtotal First Burbank 25
First/Burbank Subtotal Second Burbank 9

and so on ...

Proc Means in SAS does this and it's such a headache to code in Python. WOULD love if you added it!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions