Skip to content

Add test for #32108 (error with groupby on series with period index) #33105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 24, 2020
14 changes: 14 additions & 0 deletions pandas/tests/groupby/test_timegrouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,3 +769,17 @@ def test_scalar_call_versus_list_call(self):
expected = grouped.count()

tm.assert_frame_equal(result, expected)

def test_grouper_period_index(self):
# GH 32108
periods = 2
index = pd.period_range(
start="2018-01", periods=periods, freq="M", name="Month"
)
period_serie = pd.Series(range(periods), index=index)
result = period_serie.groupby(period_serie.index.month).sum()

expected = pd.Series(
range(0, periods), index=Index(range(1, periods + 1), name=index.name),
)
tm.assert_series_equal(result, expected)