Skip to content

Commit

Permalink
FEAT-modin-project#2375: code cleaning
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
  • Loading branch information
dchigarev committed Dec 8, 2020
1 parent 7a6ac46 commit bc921c8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
6 changes: 5 additions & 1 deletion modin/backends/pandas/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,11 @@ def groupby_agg_builder(df, by=None, drop=False):
if isinstance(internal_by_df, pandas.DataFrame):
df = pandas.concat(
[df]
+ [internal_by_df[[o for o in internal_by_df if o not in df]]],
+ [
internal_by_df.iloc[
:, ~internal_by_df.columns.isin(df.columns)
]
],
axis=1,
)
internal_by_cols = list(internal_by_df.columns)
Expand Down
12 changes: 6 additions & 6 deletions modin/engines/base/frame/axis_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def apply(
if not isinstance(other_axis_partition, list):
other_axis_partition = [other_axis_partition]

other_shape = np.zeros(len(other_axis_partition) + 1, dtype=np.int)
for i in range(1, len(other_axis_partition) + 1):
other_shape[i] = other_shape[i - 1] + len(
other_axis_partition[i - 1].list_of_blocks
)
# (other_shape[i-1], other_shape[i]) will indicate slice
# to restore i axis partition
other_shape = np.cumsum(
[0] + [len(o.list_of_blocks) for o in other_axis_partition]
)

return self._wrap_partitions(
self.deploy_func_between_two_axis_partitions(
Expand Down Expand Up @@ -273,7 +273,7 @@ def deploy_func_between_two_axis_partitions(
# reshaping flattened `rt_parts` array into a frame with shape `other_shape`
combined_axis = [
pandas.concat(
[rt_parts[j] for j in range(other_shape[i - 1], other_shape[i])],
rt_parts[other_shape[i - 1] : other_shape[i]],
axis=axis,
copy=False,
)
Expand Down
4 changes: 3 additions & 1 deletion modin/engines/base/frame/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,9 @@ def broadcast_apply_full_axis(
None,
None,
dtypes,
validate_axes="all" if new_partitions.size != 0 else False,
validate_axes="all"
if any(o is None for o in [new_index, new_columns])
else False,
)

def _copartition(self, axis, other, how, sort, force_repartition=False):
Expand Down
3 changes: 0 additions & 3 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,6 @@ def groupby(
if len(external_by) == 0:
by = self[internal_by]._query_compiler

# if len(by) == 1 and isinstance(by[0], type(self._query_compiler)):
# by = by[0]

drop = True
else:
mismatch = len(by) != len(self.axes[axis])
Expand Down

0 comments on commit bc921c8

Please sign in to comment.