Skip to content

Commit 6558f86

Browse files
committed
FEAT-#2375: addressing comments
Signed-off-by: Dmitry Chigarev <[email protected]>
1 parent 7474170 commit 6558f86

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

modin/backends/pandas/query_compiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,9 @@ def compute_groupby(df, drop=False, partition_idx=0):
26102610
except (DataError, TypeError):
26112611
result = pandas.DataFrame(index=grouped_df.size().index)
26122612
if isinstance(result, pandas.Series):
2613-
result = result.to_frame("__reduced__")
2613+
result = result.to_frame(
2614+
result.name if result.name is not None else "__reduced__"
2615+
)
26142616

26152617
result_cols = result.columns
26162618
result.drop(columns=missmatched_cols, inplace=True, errors="ignore")

modin/engines/base/frame/data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,9 @@ def broadcast_apply_full_axis(
16991699
advance, and if not provided it must be computed.
17001700
apply_indices : list-like (optional),
17011701
Indices of `axis ^ 1` to apply function over.
1702+
enumerate_partitions : bool (optional, default False),
1703+
Whether or not to pass partition index into applied `func`.
1704+
Note that `func` must be able to obtain `partition_idx` kwarg.
17021705
dtypes : list-like (optional)
17031706
The data types of the result. This is an optimization
17041707
because there are functions that always result in a particular data

modin/engines/base/frame/partition_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ def broadcast_axis_partitions(
248248
The flag to keep partitions for Modin Frame.
249249
apply_indices : list of ints (optional),
250250
Indices of `axis ^ 1` to apply function over.
251+
enumerate_partitions : bool (optional, default False),
252+
Whether or not to pass partition index into `apply_func`.
253+
Note that `apply_func` must be able to obtain `partition_idx` kwarg.
251254
lengths : list(int), default None
252255
The list of lengths to shuffle the object.
253256

modin/pandas/test/test_groupby.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ def maybe_get_columns(df, by):
349349

350350
# Workaround for Pandas bug #34656. Recreate groupby object for Pandas
351351
pandas_groupby = pandas_df.groupby(by=pandas_by, as_index=as_index)
352-
apply_functions = [lambda df: df.sum(), min]
352+
apply_functions = [
353+
lambda df: df.sum(),
354+
lambda df: pandas.Series([1, 2, 3, 4], name="result"),
355+
min,
356+
]
353357
for func in apply_functions:
354358
eval_apply(modin_groupby, pandas_groupby, func)
355359

0 commit comments

Comments
 (0)