Skip to content

Add .nunique method to DataFrame and .groupby #15794

Closed
@topper-123

Description

@topper-123

Currently, pd.DataFrame does not have a .nunique method

DataFrames have various aggregation methods that they share with series, examples being .sum, .count etc. Likewise with DataFrame.groupby-objects.

In many cases, a .nunique would be useful as on DataFrame and DataFrame.groupby-objects, for example when you're trying to assess the diversity of data in a DataFrame.

Expected Output

When you're using DataFrame.nunique, with n columns, you should get back a series where the index values are the dataframe.columns values, and the series values are the count of unique values, for each column.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Duplicate ReportDuplicate issue or pull requestEnhancementReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions