Skip to content

Commit 9cb5dc8

Browse files
committed
PR comments
1 parent 004e6e6 commit 9cb5dc8

File tree

1 file changed

+4
-27
lines changed
  • modin/core/storage_formats/pandas

1 file changed

+4
-27
lines changed

modin/core/storage_formats/pandas/utils.py

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,11 @@ def split_result_of_axis_func_pandas(
8484
list of pandas.DataFrames
8585
Splitted dataframe represented by list of frames.
8686
"""
87-
if num_splits == 1:
88-
return [result]
89-
90-
if length_list is None:
91-
length_list = get_length_list(result.shape[axis], num_splits, min_block_size)
92-
# Inserting the first "zero" to properly compute cumsum indexing slices
93-
length_list = np.insert(length_list, obj=0, values=[0])
94-
95-
sums = np.cumsum(length_list)
96-
axis = 0 if isinstance(result, pandas.Series) else axis
97-
# We do this to restore block partitioning
98-
if axis == 0:
99-
chunked = [result.iloc[sums[i] : sums[i + 1]] for i in range(len(sums) - 1)]
100-
else:
101-
chunked = [result.iloc[:, sums[i] : sums[i + 1]] for i in range(len(sums) - 1)]
102-
103-
return [
104-
# Sliced MultiIndex still stores all encoded values of the original index, explicitly
105-
# asking it to drop unused values in order to save memory.
106-
(
107-
chunk.set_axis(
108-
chunk.axes[axis].remove_unused_levels(), axis=axis, copy=False
109-
)
110-
if isinstance(chunk.axes[axis], pandas.MultiIndex)
111-
else chunk
87+
list(
88+
generate_result_of_axis_func_pandas(
89+
axis, num_splits, result, length_list, min_block_size
11290
)
113-
for chunk in chunked
114-
]
91+
)
11592

11693

11794
def generate_result_of_axis_func_pandas(

0 commit comments

Comments
 (0)