-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
REGR: Fix TypeError in groupby min / max of period column #31477
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
Changes from all commits
18508e5
a8bc3a8
23b7ba6
46bb8dc
fd0e79b
9f063b3
f973037
fc301d6
2b26a5c
a7b60ef
6bba2f5
e28bb0b
61b1016
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -684,6 +684,34 @@ def aggfunc(x): | |
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize("func", ["min", "max"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you move these to test_timegrouper.py (same dir) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're grouping by an int column and only aggregating the period column (not using a time grouper), does the current location make more sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This location seems OK since we're grouping by integers, not time. |
||
def test_groupby_aggregate_period_column(func): | ||
# GH 31471 | ||
groups = [1, 2] | ||
periods = pd.period_range("2020", periods=2, freq="Y") | ||
df = pd.DataFrame({"a": groups, "b": periods}) | ||
|
||
result = getattr(df.groupby("a")["b"], func)() | ||
idx = pd.Int64Index([1, 2], name="a") | ||
expected = pd.Series(periods, index=idx, name="b") | ||
|
||
tm.assert_series_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize("func", ["min", "max"]) | ||
def test_groupby_aggregate_period_frame(func): | ||
# GH 31471 | ||
groups = [1, 2] | ||
periods = pd.period_range("2020", periods=2, freq="Y") | ||
df = pd.DataFrame({"a": groups, "b": periods}) | ||
|
||
result = getattr(df.groupby("a"), func)() | ||
idx = pd.Int64Index([1, 2], name="a") | ||
expected = pd.DataFrame({"b": periods}, index=idx) | ||
|
||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
class TestLambdaMangling: | ||
def test_basic(self): | ||
df = pd.DataFrame({"A": [0, 0, 1, 1], "B": [1, 2, 3, 4]}) | ||
|
Uh oh!
There was an error while loading. Please reload this page.