Skip to content

Add CountDistinct method to GroupBy #7574

@sevenzees

Description

@sevenzees

Is your feature request related to a problem? Please describe.
I have a need to count the distinct values within a group, similar to the nunique method in Pandas GroupBy.

Describe the solution you'd like
I would like to have a method within the GroupBy class that counts the distinct non-null values per group. Even better, a CountIf method that allows the user to supply their own predicate to conditionally count rows per group.

Describe alternatives you've considered
I wrote my own CountDistinct method within my application, but it would be better if I could use a built in method.

Additional context
For reference, the Pandas method that I would like to loosely base this off of is here https://pandas.pydata.org/pandas-docs/version/2.2.2/reference/api/pandas.core.groupby.DataFrameGroupBy.nunique.html,

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestuntriagedNew issue has not been triaged

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions