-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame reductions with object dtype and axis=1 #49619
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
Closed
rhshadrach
wants to merge
12
commits into
pandas-dev:main
from
rhshadrach:object_reduction_axis_1_attempt_2
Closed
BUG: DataFrame reductions with object dtype and axis=1 #49619
rhshadrach
wants to merge
12
commits into
pandas-dev:main
from
rhshadrach:object_reduction_axis_1_attempt_2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ct_reduction_axis_1_attempt_2 � Conflicts: � pandas/core/frame.py
…ct_reduction_axis_1_attempt_2 � Conflicts: � pandas/core/frame.py
…ct_reduction_axis_1_attempt_2
…ct_reduction_axis_1_attempt_2 � Conflicts: � doc/source/whatsnew/v2.0.0.rst
…ct_reduction_axis_1_attempt_2
…ct_reduction_axis_1_attempt_2
rhshadrach
commented
Dec 10, 2022
Comment on lines
+989
to
+991
dtype = arr.dtype if res is NaT else None | ||
result_arrays.append( | ||
sanitize_array([res], None) # type: ignore[arg-type] | ||
sanitize_array([res], None, dtype=dtype) # type: ignore[arg-type] |
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 expect this approach to work for L984-985 above; is this a preferred method?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
DataFrame
DataFrame data structure
Dtype Conversions
Unexpected or buggy dtype conversions
Reduction Operations
sum, mean, min, max, etc.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.In #49616 I attempted to only remove the errant cast to float, but this lead to the issue that, e.g. for axis=1 the sum of boolean columns becomes object. Unconditionally taking the block manager reduce path solves this problem, but then we run into the issue of taking a transpose of a frame with no columns (see the comments in the diff here). This PR resolves that issue, but is a bit of a hack (I can't seem to find any other resolution).
In the test here, there are some reductions (e.g. mean) that one may have expected float back instead - I've opened #49618 for this.