Skip to content
Prev Previous commit
Next Next commit
pass correct ndim
  • Loading branch information
erfannariman committed Nov 22, 2020
commit ba634f8220630cf60d04aaec6397ce1c7e7d521c
5 changes: 3 additions & 2 deletions pandas/core/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,14 @@ def agg_dict_like(

from pandas.core.reshape.concat import concat

if selected_obj.ndim == 1:
ndim = selected_obj.ndim
if ndim == 1:
# key only used for output
colg = obj._gotitem(obj._selection, ndim=1)
results = {key: colg.agg(how) for key, how in arg.items()}
else:
# key used for column selection and output
results = {key: obj._gotitem(key, ndim=1).agg(how) for key, how in arg.items()}
results = {key: obj._gotitem(key, ndim=ndim).agg(how) for key, how in arg.items()}

# set the final keys
keys = list(arg.keys())
Expand Down