Backport PR #32040 on branch 1.0.x (BUG: GroupBy aggregation of DataFrame with MultiIndex columns breaks with custom function)
Backport PR #32040: BUG: GroupBy aggregation of DataFrame with MultiIndex columns breaks with custom function