-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
pandas/tests/groupby/test_apply.py
Outdated
{"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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use reduction_func
fixture instead of picking these one-off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
pandas/tests/groupby/test_apply.py
Outdated
|
||
@pytest.mark.parametrize( | ||
"values", | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to pandas/tests/groupby/test_function.py
also merge master |
groups = pd.DataFrame(values, dtype="Int64").groupby("a") | ||
result = getattr(groups, function)() | ||
|
||
output = 0.5 if function == "var" else 1.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move the expected to the top.
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)() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move result down to the bottom & add testing for
.agg([function])
and .agg(function)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small change in tests, ping on green.
|
||
groups = pd.DataFrame(values, dtype="Int64").groupby("a") | ||
|
||
if use_agg: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to parameterize on use_agg; just test all 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback Updated and green
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
thanks @dsaxton |
@dsaxton if you can try a manual backport would be great :-> |
Thanks @dsaxton. FYI, in the future you can remove the "still needs manual backport" label after the backport is merged. |
mean
on aDataFrameGroupBy
withInt64
dtype results inTypeError
#32219black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
It looks like this was due to the
TypeError
not being caught