-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG/API: _values_for_factorize/_from_factorized round-trip #32798
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
jorisvandenbossche
left a comment
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.
Let's first discuss in the issue what we want
jreback
left a comment
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.
lgtm.
|
@jorisvandenbossche objections? |
|
Yes, see my comment, we should first discuss further in the issue before simply changing |
pandas/core/arrays/boolean.py
Outdated
| def _from_factorized(cls, values, original: "BooleanArray") -> "BooleanArray": | ||
| return cls._from_sequence(values, dtype=original.dtype) | ||
| mask = values == -1 | ||
| return cls(values.astype(bool), mask) |
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.
The astype causes a copy, which I think wasn't present before. This could perhaps be a .view('bool') to preserve the previous no-copy behavior.
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.
changed to .astype(bool, copy=False)
|
mothballing |
black pandasgit diff upstream/master -u -- "*.py" | flake8 --diffhaving this round-trip-ability is necessary for implementing an efficient general-case broadcast_to/tile compat method.