Skip to content

Commit ab31dd6

Browse files
author
Jon M. Mease
committed
Implemented GH 5677
1 parent fb97134 commit ab31dd6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pandas/core/groupby.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -2446,9 +2446,13 @@ def is_in_obj(gpr):
24462446
exclusions.append(name)
24472447

24482448
elif is_in_axis(gpr): # df.groupby('name')
2449-
in_axis, name, gpr = True, gpr, obj[gpr]
2450-
exclusions.append(name)
2451-
2449+
if gpr in obj:
2450+
in_axis, name, gpr = True, gpr, obj[gpr]
2451+
exclusions.append(name)
2452+
elif gpr in obj.index.names:
2453+
in_axis, name, level, gpr = False, None, gpr, None
2454+
else:
2455+
raise KeyError(gpr)
24522456
else:
24532457
in_axis, name = False, None
24542458

0 commit comments

Comments
 (0)