Before https://github.com/pandas-dev/pandas/pull/49611, test_regression_allowlist_methods
was a comprehensive groupby test that asserted frame.groupby(...).op(...)
was equivalent to frame.op(level=..., ...)
. Now that level
has been removed, this test should ideally have a stronger assertion than current testing that a DataFrame is returned; ideally using tm.assert_frame_equal
Comment From: isaac-chung
Is this an issue that's welcoming contributions? If yes, I'd love to give it a go.
Comment From: mroeschke
Definitely @isaac-chung. Feel free to tackle it!
Comment From: isaac-chung
Looking for ways to generate the expected
frame to use tm.assert_frame_equal
. Trying to get some context for the removal of level
from this PR and this suggestion. It seems that the previous way of building the expected
frame is no longer supported.
Is this something close to the best we can do for now? Even then, this does not match result
currently when given sort=True
or axis=1
.
expected = frame.groupby(level="first").apply(lambda h: getattr(h, op)(axis=axis))
I hope to see if there is something obvious that I'm missing before I go into a rabbit hole. Also happy to discuss this or let another contributor take a go if needed.
Comment From: mroeschke
The apply idea is a good one - fair point though it might not conveniently support all the supported arguments.
Since this test is mainly smoketest for groupby methods and args, I think it's valid to replace raw_frame
with a "simple DataFrame" like DataFrame([0])
that should hopefully have similar results for a lot of the groupby methods and their args.
Comment From: isaac-chung
Sounds good, this would simplify things quite well. Let me share what I currently have in a pull request.