-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: preserve object dtype for Index set ops #31401
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: preserve object dtype for Index set ops #31401
Conversation
…f-index-wrap_setop_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.
minor comment
…f-index-wrap_setop_result
@@ -2566,6 +2567,7 @@ def _union(self, other, sort): | |||
# worth making this faster? a very unusual case | |||
value_set = set(lvals) | |||
result.extend([x for x in rvals if x not in value_set]) | |||
result = Index(result)._values # do type inference here |
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.
why does _wrap_setop_result not do this?
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.
ATM it does in a roundabout manner. Index._wrap_setop_result calls self._constructor, which is type(self)
whereas the subclasses use _shallow_copy.
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.
ok
@@ -2566,6 +2567,7 @@ def _union(self, other, sort): | |||
# worth making this faster? a very unusual case | |||
value_set = set(lvals) | |||
result.extend([x for x in rvals if x not in value_set]) | |||
result = Index(result)._values # do type inference here |
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.
ok
I'd be fine with coercing if we did it consistently, but ATM we behave differently for monotonic-increasing vs otherwise.