Skip to content

Commit

Permalink
FIX-#5364: fix get_indices internal function (#5355)
Browse files Browse the repository at this point in the history
Signed-off-by: Myachev <[email protected]>
  • Loading branch information
anmyachev authored Dec 6, 2022
1 parent 1748e00 commit c868065
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
13 changes: 1 addition & 12 deletions modin/core/dataframe/pandas/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2058,18 +2058,7 @@ def sort_function(df):
new_axes[axis.value],
new_lengths[axis.value],
) = self._compute_axis_labels_and_lengths(axis.value, new_partitions)
# If we have a MultiIndex, but the first partition is empty, which may happen when
# the dataframe is small, `_compute_axis_labels_and_lengths` will return us a flattened
# MultiIndex - i.e. an Index consisting of tuples. This is because the MultiIndex from
# the remaining partitions is appended to an empty flat Index, which results in a
# flattened index. To work around this, we need to convert this flattened Index back
# into a MultiIndex.
if isinstance(self.axes[axis.value], pandas.MultiIndex) and isinstance(
new_axes[axis.value][0], tuple
):
new_axes[axis.value] = pandas.MultiIndex.from_tuples(
new_axes[axis.value].values
)

new_axes[axis.value] = new_axes[axis.value].set_names(
self.axes[axis.value].names
)
Expand Down
7 changes: 5 additions & 2 deletions modin/core/dataframe/pandas/partitioning/partition_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,11 @@ def get_indices(cls, axis, partitions, index_func=None):
target = partitions.T if axis == 0 else partitions
new_idx = [idx.apply(func) for idx in target[0]] if len(target) else []
new_idx = cls.get_objects_from_partitions(new_idx)
# TODO FIX INFORMATION LEAK!!!!1!!1!!
total_idx = new_idx[0].append(new_idx[1:]) if new_idx else new_idx
# filter empty indexes
total_idx = list(filter(len, new_idx))
if len(total_idx) > 0:
# TODO FIX INFORMATION LEAK!!!!1!!1!!
total_idx = total_idx[0].append(total_idx[1:])
return total_idx, new_idx

@classmethod
Expand Down

0 comments on commit c868065

Please sign in to comment.