-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix DateFrameGroupBy.mean error for Int64 dtype #32223
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 12 commits
225ad43
fc683e1
dec6560
60c3ccb
c5bd077
780c4cd
6d4a94b
651de5e
a237581
3d0477d
0c7a802
967df57
c60dbcb
e94c9db
bcf9867
9a04125
66fa0de
45d7888
3dadd53
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 |
---|---|---|
|
@@ -866,3 +866,27 @@ def fct(group): | |
[[1.0, 2.0], [3.0], [np.nan]], index=pd.Index(["a", "b", "none"], name="A") | ||
) | ||
tm.assert_series_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"values", | ||
[ | ||
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. move this to pandas/tests/groupby/test_function.py |
||
{ | ||
"a": [1, 1, 1, 2, 2, 2, 3, 3, 3], | ||
"b": [1, pd.NA, 2, 1, pd.NA, 2, 1, pd.NA, 2], | ||
}, | ||
{"a": [1, 1, 2, 2, 3, 3], "b": [1, 2, 1, 2, 1, 2]}, | ||
], | ||
) | ||
@pytest.mark.parametrize("function", ["mean", "median", "var"]) | ||
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 use 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. I'm having some trouble using this fixture without making the test very complex since the methods each have different output (e.g., sometimes it's empty), some require arguments, etc. Would it be okay if these tests only included the ones affected by the bug? |
||
def test_apply_to_nullable_integer_returns_float(values, function): | ||
# https://github.com/pandas-dev/pandas/issues/32219 | ||
groups = pd.DataFrame(values, dtype="Int64").groupby("a") | ||
result = getattr(groups, function)() | ||
|
||
output = 0.5 if function == "var" else 1.5 | ||
arr = np.array([output] * 3, dtype=float) | ||
idx = pd.Index([1, 2, 3], dtype=object, name="a") | ||
expected = pd.DataFrame({"b": arr}, index=idx) | ||
|
||
tm.assert_frame_equal(result, expected) |
Uh oh!
There was an error while loading. Please reload this page.