diff --git a/modin/pandas/dataframe.py b/modin/pandas/dataframe.py index 2484b3932e2..7c80aca680e 100644 --- a/modin/pandas/dataframe.py +++ b/modin/pandas/dataframe.py @@ -498,7 +498,12 @@ def groupby( elif hashable(by) and not isinstance(by, (pandas.Grouper, FrozenList)): drop = by in self.columns idx_name = by - if by is not None and by in self._query_compiler.get_index_names(axis): + if ( + by is not None + # `by` is already in `self.columns` + and not drop + and by in self._query_compiler.get_index_names(axis) + ): # In this case we pass the string value of the name through to the # partitions. This is more efficient than broadcasting the values. level, by = by, None