Skip to content

Groupby Agg not working if different partials with same name on the same column #28570

Description

@charlesdong1991

related to #28426 from PR #28428

from functools import partial

import pandas as pd
import numpy as np

quant50 = partial(np.percentile, q=50)
quant70 = partial(np.percentile, q=70)

test = pd.DataFrame({'col1': ['a', 'a', 'b', 'b', 'b'], 'col2': [1,2,3,4,5]})
test.groupby('col1').agg({'col2': [quant50, quant70]})

However, quant50 result is rewritten by quant70, so will get the same output on both columns.

output:

col1 percentile percentile
a 1.7 1.7
b 4.4 4.4

expected output:

col1 percentile percentile
a 1.5 1.7
b 4.0 4.4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ApplyApply, Aggregate, Transform, MapBugGroupbyNeeds TestsUnit test(s) needed to prevent regressions

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions