Skip to content

.groupby by should indicate it aligns the passed in Series #15338

Closed
@kernc

Description

@kernc

Code Sample, a copy-pastable example if possible

>>> series = pd.Series([1, 2, 3], index=range(3))

>>> key = pd.Series([0, 0, 1], index=range(3, 6))  # Note: disjunct index

>>> series.groupby(key).sum()
Series([], dtype: int64)

>>> series.groupby(key.values).sum()
0    3
1    3
dtype: int64

Problem description

The current behavior is a bug because the .groupby() documentation says about by parameter:

If a dict or Series is passed, the Series or dict VALUES will be used to determine the groups

Above example shows this not being the case.

Expected Output

With above setup:

>>> series.groupby(key).sum()
0    3
1    3
dtype: int64

Output of pd.show_versions()

pandas: 0.19.0+416.ge1390cd

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions