Skip to content

Commit 3f4f564

Browse files
authored
Add test for #32108 (error with groupby on series with period index) (#33105)
1 parent 486be25 commit 3f4f564

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/groupby/test_timegrouper.py

+14
Original file line numberDiff line numberDiff line change
@@ -769,3 +769,17 @@ def test_scalar_call_versus_list_call(self):
769769
expected = grouped.count()
770770

771771
tm.assert_frame_equal(result, expected)
772+
773+
def test_grouper_period_index(self):
774+
# GH 32108
775+
periods = 2
776+
index = pd.period_range(
777+
start="2018-01", periods=periods, freq="M", name="Month"
778+
)
779+
period_series = pd.Series(range(periods), index=index)
780+
result = period_series.groupby(period_series.index.month).sum()
781+
782+
expected = pd.Series(
783+
range(0, periods), index=Index(range(1, periods + 1), name=index.name),
784+
)
785+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)