From 81d8039ee5d0c909f2ab24de0c4d85950b188d45 Mon Sep 17 00:00:00 2001 From: Kirill Suvorov Date: Thu, 22 Aug 2024 12:28:17 +0000 Subject: [PATCH] Add test for empty partitions after groupby --- modin/tests/pandas/test_groupby.py | 34 +++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/modin/tests/pandas/test_groupby.py b/modin/tests/pandas/test_groupby.py index b82473c674b..12c0b888ff2 100644 --- a/modin/tests/pandas/test_groupby.py +++ b/modin/tests/pandas/test_groupby.py @@ -21,7 +21,13 @@ import pytest import modin.pandas as pd -from modin.config import IsRayCluster, NPartitions, RangePartitioning, StorageFormat +from modin.config import ( + DynamicPartitioning, + IsRayCluster, + NPartitions, + RangePartitioning, + StorageFormat, +) from modin.core.dataframe.algebra.default2pandas.groupby import GroupBy from modin.core.dataframe.pandas.partitioning.axis_partition import ( PandasDataframeAxisPartition, @@ -2431,6 +2437,32 @@ def test_multi_column_groupby_different_partitions( ) +def test_empty_partitions_after_groupby(): + DynamicPartitioning.put(True) + + def func_to_apply(grp): + return grp.agg( + { + list(test_data_values[0].keys())[1]: "sum", + list(test_data_values[0].keys())[-1]: "sum", + } + ) + + data = test_data_values[0] + md_df, pd_df = create_test_dfs(data) + by = pd_df.columns[0] + + md_grp, pd_grp = ( + md_df.groupby(by), + pd_df.groupby(by), + ) + eval_general( + md_grp, + pd_grp, + func_to_apply, + ) + + @pytest.mark.parametrize( "by", [