-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ | |
|
||
from pandas import ( | ||
Categorical, | ||
Index, | ||
Series, | ||
) | ||
|
||
|
@@ -1134,8 +1135,20 @@ def factorize( | |
self, | ||
sort: bool = False, | ||
use_na_sentinel: bool = True, | ||
): | ||
return algorithms.factorize(self, sort=sort, use_na_sentinel=use_na_sentinel) | ||
) -> tuple[npt.NDArray[np.intp], Index]: | ||
|
||
codes, uniques = algorithms.factorize( | ||
self._values, sort=sort, use_na_sentinel=use_na_sentinel | ||
) | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. what's the reason to change this from
? Is it just simpler? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct |
||
else: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this change from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct |
||
from pandas import Index | ||
|
||
uniques = Index(uniques) | ||
return codes, uniques | ||
|
||
_shared_docs[ | ||
"searchsorted" | ||
|
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
?
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