Skip to content

Commit

Permalink
PERF-#0000: Don't materialize index in 'groupby' where 'by' hashable
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
  • Loading branch information
anmyachev committed Nov 28, 2023
1 parent ca654de commit fca805e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fca805e

Please sign in to comment.