Skip to content

Commit 394feb6

Browse files
committed
restore + change test_evaluate_with_empty_groups
1 parent 8a13d06 commit 394feb6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pandas/tests/groupby/test_grouping.py

+27
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,33 @@ def test_list_grouper_with_nat(self):
610610
expected = {pd.Timestamp("2011-01-01"): 365}
611611
tm.assert_dict_equal(result.groups, expected)
612612

613+
@pytest.mark.parametrize(
614+
"func,expected",
615+
[
616+
(
617+
"transform",
618+
pd.Series(name=2, dtype=np.float64, index=pd.Index([], dtype="object")),
619+
),
620+
(
621+
"agg",
622+
pd.Series(name=2, dtype=np.float64, index=pd.Float64Index([], name=1)),
623+
),
624+
(
625+
"apply",
626+
pd.Series(name=2, dtype=np.float64, index=pd.Float64Index([], name=1)),
627+
),
628+
],
629+
)
630+
def test_evaluate_with_empty_groups(self, func, expected):
631+
# 26208
632+
# test transform'ing empty groups
633+
# (not testing other agg fns, because they return
634+
# different index objects.
635+
df = pd.DataFrame({1: [], 2: []})
636+
g = df.groupby(1)
637+
result = getattr(g[2], func)(lambda x: x)
638+
tm.assert_series_equal(result, expected)
639+
613640
def test_groupby_empty(self):
614641
# https://github.com/pandas-dev/pandas/issues/27190
615642
s = pd.Series([], name="name", dtype="float64")

0 commit comments

Comments
 (0)