-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
BUG: Groupby selection context not being properly reset #28541
BUG: Groupby selection context not being properly reset #28541
Conversation
@@ -240,6 +240,7 @@ Groupby/resample/rolling | |||
- Bug in :meth:`DataFrame.rolling` not allowing for rolling over datetimes when ``axis=1`` (:issue: `28192`) | |||
- Bug in :meth:`DataFrame.groupby` not offering selection by column name when ``axis=1`` (:issue:`27614`) | |||
- Bug in :meth:`DataFrameGroupby.agg` not able to use lambda function with named aggregation (:issue:`27519`) | |||
- Bug in :meth:`DataFrameGroupby` causing unexpected mutations of the groupby object (:issue:`28523`) |
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 think the ref needs to be :class:`pandas.core.groupby.DataFrameGroupBy`. And maybe briefly explain the user-visible behavior: "Multiple operations on a DataFrameGroupBy object not giving the same results in certain cases".
pandas/tests/groupby/test_groupby.py
Outdated
@pytest.mark.parametrize( | ||
"func, args", | ||
[ | ||
("sum", []), |
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.
DO we need all these parametrezations? Or does just a few work? sum
and nth
?
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.
Probably not. It looks like one of [sum, prod, min, max, first, last] and then nth would suffice.
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.
We have a reduction_func
fixture I think you should use here; would actually be more functions but also more comprehensive and consistent with some other tests
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.
Looks good just some minor comments. Did you see any other usages that weren't part of the context manager by chance?
pandas/tests/groupby/test_groupby.py
Outdated
@pytest.mark.parametrize( | ||
"func, args", | ||
[ | ||
("sum", []), |
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.
We have a reduction_func
fixture I think you should use here; would actually be more functions but also more comprehensive and consistent with some other tests
Will this fix #26864? |
So there are two tests that will need to be changed regarding this fix:
The second change is straightforward, the first might have identified another bug. Is this behavior expected?
The mutating state caused those two to be equal in the test, but now it fails, and I'm not sure if the second is intended behavior. |
I think the second is a bug might have open issue already
…Sent from my iPhone
On Sep 19, 2019, at 6:45 PM, Chris Zimmerman ***@***.***> wrote:
So there are two tests that will need to be changed regarding this fix:
test_grouper_creation_bug and test_agg_timezone_round_trip
The second change is straightforward, the first might have identified another bug.
Is this behavior expected?
>>> df = DataFrame({"A": [0, 0, 1, 1, 2, 2], "B": [1, 2, 3, 4, 5, 6]})
>>> df.groupby('A').sum()
B
A
0 3
1 7
2 11
>>> df.groupby('A').apply(lambda x: x.sum())
A B
A
0 0 3
1 2 7
2 4 11
The mutating state caused those two to be equal in the test, but now it fails, and I'm not sure if the second is intended behavior.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@WillAyd OK, I'll track down that bug and take care of that before I do anything else with this PR. Also per your previous comment, making the test work with |
Sounds good - nice work so far! |
#17091 might be closed by this as well |
@christopherzimmerman can you merge master, been some changed in groupby recently. |
@christopherzimmerman can you rebase, this would be really nice to see fixed |
… into avoid_mutate_groupby
Hello @christopherzimmerman! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-10-21 13:45:44 UTC |
@jbrockmendel rebased and cleaned up what I was working on. #28549 still needs to be addressed before this is green. I had a PR going for that issue and I'll revisit it. |
a lot of work has been going on in these files; can you rebase again? ill try to review in a timely manner so we dont have to go through another round |
@christopherzimmerman would be a nice change, can you merge master |
I will merge, but #29131 will need to be merged first or else the CI will fail, since this requires some test updates from the other PR. |
Let's come back to this after the other PR is merged then; (looks like more changes are needed there). Closing to reduce PR queue for the time being - thanks as always! |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff