Skip to content

Commit 521eb60

Browse files
authored
PERF-#6668: Use copy=False for internal usage of set_axis (#6667)
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
1 parent dcd750c commit 521eb60

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

modin/core/dataframe/pandas/dataframe/dataframe.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,12 @@ def _propagate_index_objs(self, axis=None):
808808
if axis is None:
809809

810810
def apply_idx_objs(df, idx, cols):
811-
return df.set_axis(idx, axis="index").set_axis(cols, axis="columns")
811+
# We should make at least one copy to avoid the data modification problem
812+
# that may arise when sharing buffers from distributed storage
813+
# (zero-copy pickling).
814+
return df.set_axis(idx, axis="index").set_axis(
815+
cols, axis="columns", copy=False
816+
)
812817

813818
self._partitions = np.array(
814819
[

modin/pandas/groupby.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,9 @@ def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs)
19901990
# because there is no need to identify which original column's aggregation
19911991
# the new column represents. alternatively we could give the query compiler
19921992
# a hint that it's for a series, not a dataframe.
1993-
return result.set_axis(labels=self._try_get_str_func(func), axis=1)
1993+
return result.set_axis(
1994+
labels=self._try_get_str_func(func), axis=1, copy=False
1995+
)
19941996
else:
19951997
return super().aggregate(
19961998
func, *args, engine=engine, engine_kwargs=engine_kwargs, **kwargs

0 commit comments

Comments
 (0)