Skip to content

Zero counts in Series.value_counts for categoricals #8559

Closed
@fkaufer

Description

@fkaufer

Series.value_counts() also shows categories with count 0.

Thought this would be a bug but according to doc it is intentional.

This makes the output of value_counts inconsistent when switching between category and non-category dtype. Apart from that it blows up the value_counts output for series with many categories.

I would prefer to hide counts (i.e. zero) for non-occuring categories by default and rather consider a parameter dropzero=True similar to dropna (see also #5569).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions