Skip to content

Commit 95f5510

Browse files
Fix error checking for groupby
Signed-off-by: Devin Petersohn <[email protected]>
1 parent 6e8466e commit 95f5510

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

modin/pandas/dataframe.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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
(

0 commit comments

Comments
 (0)