Skip to content

Commit 13395f0

Browse files
FIX-#4522: Correct multiindex metadata with groupby
Signed-off-by: Devin Petersohn <[email protected]>
1 parent cca9468 commit 13395f0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modin/core/dataframe/algebra/groupby.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ def map(
133133
axis=1,
134134
)
135135
other = list(other.columns)
136+
# GH#4522: Vile as this may be, it is necessary to avoid the case where we are
137+
# grouping by columns that were recently added to the data via
138+
# `from_labels`. The internal dataframe doesn't know what to do when
139+
# the label matches a column name.
140+
if len(df.columns.intersection(df.index.names)) > 0:
141+
df = df.reset_index(drop=True)
136142
by_part = other
137143
else:
138144
by_part = by

0 commit comments

Comments
 (0)