-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
REF/BUG/API: factorizing categorical data #19938
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 1 commit
18de376
9ef5be2
5e52b6f
e19ae86
121b682
a6bc405
0bfbc47
b25f383
2688c4f
2395a99
ab4f01c
65150f4
ad8173b
1e006d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -520,7 +520,8 @@ def factorize(values, sort=False, order=None, na_sentinel=-1, size_hint=None): | |
from pandas.core.sorting import safe_sort | ||
try: | ||
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. Removed all t 643D he sorting from Categorical.factorize. All that logic is here. I don't think we want to just call
On some small bencharks (10,000 elements) this is about 25-40% faster. The only slow case, for which we still need safe_sort, is when the array is mixed. In that case things are about 10% slower. |
||
order = uniques.argsort() | ||
labels = take_1d(order, labels, fill_value=na_sentinel) | ||
order2 = order.argsort() | ||
labels = take_1d(order2, labels, fill_value=na_sentinel) | ||
uniques = uniques.take(order) | ||
except TypeError: | ||
# Mixed types, where uniques.argsort fails. | ||
|
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.
could move to the except (but no big deal)