-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Reindex casting to object in certain situation #48190
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
# Conflicts: # doc/source/whatsnew/v1.6.0.rst # pandas/tests/frame/methods/test_reindex.py
cc @mroeschke gentle ping Ci is green, forgot to remove 1.5 whatsnew |
pandas/core/generic.py
Outdated
@@ -5345,6 +5345,9 @@ def _needs_reindex_multi(self, axes, method, level) -> bool_t: | |||
and method is None | |||
and level is None | |||
and not self._is_mixed_type | |||
and not ( | |||
len(self.dtypes) == 1 and is_extension_array_dtype(self.dtypes.iloc[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.
Might be cleaner to define for DataFrame
only? Although Series
overrides _needs_reindex_multi
to be False
, self.dtypes
for Series
is a scalar
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.
added a ndim check
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.
One minor suggestion, otherwise LGTM. Feel free to merge on greenish
Co-authored-by: Matthew Roeschke <[email protected]>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Stumbled across this when doing #48185
Longterm we could support a mask in take_2d_multi