-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG: pd.factorize should not upconvert unique values unnecessarily #41132
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
d8b1052 to
5c788a3
Compare
5c788a3 to
23adaf2
Compare
pandas/core/algorithms.py
Outdated
| elif is_float_dtype(values): | ||
| return ensure_float64(values), np.dtype("float64") | ||
| dtype = getattr(values, "dtype", np.dtype("float64")) | ||
| return ensure_float64(values), dtype |
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.
i think this code was written before we had non-64 hashtables. i expect a lot of this casting can now be avoided
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.
Probably yeah, and if we can avoid them, it'll speed some things up nicely.
But that's for a different PR? I got a feeling there's a lot of detail hidden in that change.
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.
fair enough
|
thanks @topper-123 |
The uniques returned from
pd.factorizeshould keep their original dtype, where possible.