File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -415,7 +415,6 @@ def groupby(
415415 )
416416 else :
417417 squeeze = False
418-
419418 axis = self ._get_axis_number (axis )
420419 idx_name = None
421420 # Drop here indicates whether or not to drop the data column before doing the
@@ -448,6 +447,14 @@ def groupby(
448447 idx_name = by .name
449448 by = by ._query_compiler
450449 elif is_list_like (by ):
450+ for k in by :
451+ if k in self .index .names and k in self .axes [axis ]:
452+ level_name , index_name = "an index" , "a column"
453+ if axis == 1 :
454+ level_name , index_name = index_name , level_name
455+ raise ValueError (
456+ f"{ k } is both { level_name } level and { index_name } label, which is ambiguous."
457+ )
451458 # fastpath for multi column groupby
452459 if axis == 0 and all (
453460 (
You can’t perform that action at this time.
0 commit comments