@@ -84,34 +84,11 @@ def split_result_of_axis_func_pandas(
84
84
list of pandas.DataFrames
85
85
Splitted dataframe represented by list of frames.
86
86
"""
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
112
90
)
113
- for chunk in chunked
114
- ]
91
+ )
115
92
116
93
117
94
def generate_result_of_axis_func_pandas (
0 commit comments