Skip to content

unexpected result with groupby apply on categorical data #9603

Closed
@tmoroz

Description

@tmoroz
df = pandas.DataFrame({'a': [1, 0, 0, 0]})
df.groupby(pandas.cut(df.a, [0, 1, 2, 3, 4])).apply(lambda x: len(x))

Out[3]:
a
(0, 1]    1
(1, 2]    0
(2, 3]    0
(3, 4]    3
dtype: int64

final group length should be 0 not 3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions