Skip to content

Commit

Permalink
PERF-#4804: Preserve lengths/widths caches in 'broadcast_apply_full_a…
Browse files Browse the repository at this point in the history
…xis'

Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed Nov 20, 2023
1 parent 8ba32a8 commit 7b2be32
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modin/core/dataframe/pandas/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3348,6 +3348,25 @@ def broadcast_apply_full_axis(
kw["column_widths"] = self._column_widths_cache
elif len(new_columns) == 1 and new_partitions.shape[1] == 1:
kw["column_widths"] = [1]
else:
if (
kw["row_lengths"] is None
and new_index is not None
and self._row_lengths_cache is not None
and len(new_index) == sum(self._row_lengths_cache)
# to avoid problems that may arise when filtering empty dataframes
and all(r != 0 for r in self._row_lengths_cache)
):
kw["row_lengths"] = self._row_lengths_cache
if (
kw["column_widths"] is None
and new_columns is not None
and self._column_widths_cache is not None
and len(new_columns) == sum(self._column_widths_cache)
# to avoid problems that may arise when filtering empty dataframes
and all(w != 0 for w in self._column_widths_cache)
):
kw["column_widths"] = self._column_widths_cache

result = self.__constructor__(
new_partitions, index=new_index, columns=new_columns, **kw
Expand Down

0 comments on commit 7b2be32

Please sign in to comment.