-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
REF: reverse dispatch in factorize #49966
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
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.
Looks good, just left a couple of comments for my own understanding
if isinstance(self, ABCIndex): | ||
# preserve e.g. NumericIndex, preserve MultiIndex | ||
uniques = self._constructor(uniques) | ||
else: |
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.
does this change from elif isinstance(self, ABCSeries)
because here self
would always be ABCSeries
, so it might as well just be else
?
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.
correct
if not isinstance(values, ABCMultiIndex): | ||
values = extract_array(values, extract_numpy=True) |
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.
is this no longer necessary because of the early return above
if isinstance(values, (ABCIndex, ABCSeries)):
return values.factorize(sort=sort, use_na_sentinel=use_na_sentinel)
?
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.
correct
|
||
if isinstance(self, ABCIndex): | ||
# preserve e.g. NumericIndex, preserve MultiIndex | ||
uniques = self._constructor(uniques) |
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's the reason to change this from
uniques = ensure_wrapped_if_datetimelike(uniques)
uniques = self._shallow_copy(uniques, name=None)
? Is it just simpler?
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.
correct
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.
Looks good to me, thanks @jbrockmendel !
Thanks @jbrockmendel |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Needed for upcoming removal of DTA/TDA.freq