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
13 changes: 13 additions & 0 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2057,3 +2057,16 @@ def test_groups_repr_truncates(max_seq_items, expected):

result = df.groupby(np.array(df.a)).groups.__repr__()
assert result == expected


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this under test_grouper_index_types (same file). ping on green.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function test_grouper_index_types is in the file pandas/tests/groupby/test_grouping.py our test is in pandas/tests/groupby/test_groupby.py, do you want us to move our test to test_grouping.py ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes pls move this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

def test_groupby_period_index():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the issue number here:

def test_groupby_period_index():
    # GH 32108

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

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