Skip to content

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

Merged
merged 7 commits into from
Sep 2, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Aug 21, 2022

  • closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest 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

@phofl phofl added Indexing Related to indexing on series/frames, not to indexes themselves ExtensionArray Extending pandas with custom dtypes or arrays. labels Aug 21, 2022
@phofl
Copy link
Member Author

phofl commented Sep 1, 2022

cc @mroeschke gentle ping

Ci is green, forgot to remove 1.5 whatsnew

@@ -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])
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a ndim check

Copy link
Member

@mroeschke mroeschke left a 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

@mroeschke mroeschke added this to the 1.6 milestone Sep 2, 2022
@phofl phofl merged commit 854987f into pandas-dev:main Sep 2, 2022
@phofl phofl deleted the reindex_mask_object branch September 2, 2022 19:45
@mroeschke mroeschke modified the milestones: 1.6, 2.0 Oct 13, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants