-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: as_index=False can return a MultiIndex in groupby.apply #58369
BUG: as_index=False can return a MultiIndex in groupby.apply #58369
Conversation
800a2c3
to
52fb291
Compare
f386f6a
to
5a30216
Compare
Removed the addition of multi index, instead of using |
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.
Thanks for the PR! Code change looks good, some requests / questions on the tests. In general, don't leave print
statements in the tests - these are captured by pytest and would hurt test suite performance if we left them throughout the tests.
if "level_0" in result: | ||
expected.insert(loc=0, column="level_0", value=result["level_0"]) |
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.
In tests, the expected should not depend on the result. This would allow behavior to change but the test to remain the same, and therefore possibly go unnoticed. Can you find a different condition here that doesn't depend on result.
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.
resolved to update expected results based on test parameters
pandas/tests/groupby/test_apply.py
Outdated
# GH58291 | ||
def test_apply_frame_not_as_index_returns_single_index(): | ||
df = DataFrame( |
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 move inside the function to agree with the style of the other tests.
def test_...():
# GH#58291
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.
resolved
pandas/tests/groupby/test_apply.py
Outdated
|
||
|
||
# GH58291 | ||
def test_apply_column_groupby_frame_not_as_index_returns_single_index(df): |
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.
What is this testing that we don't have test coverage for?
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.
resolved by removing all tests as they are already tested in other tests
pandas/tests/groupby/test_apply.py
Outdated
|
||
|
||
# GH58291 | ||
def test_apply_non_column_groupby_frame_not_as_index_returns_single_index(tsframe): |
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.
Same question - what case is this looking to expand our test coverage?
cd9ae2c
to
062031e
Compare
794ef85
to
8457147
Compare
Thank you for the review, I have updated the pr according to the comments |
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.
lgtm
Thanks @undermyumbrella1! |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.