-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
ENH: Optimize replace to avoid copying when not necessary #50918
Conversation
Does this fix any of the existing cases in |
No, not yet |
# Conflicts: # pandas/tests/copy_view/test_replace.py
# Conflicts: # pandas/tests/copy_view/test_methods.py # pandas/tests/copy_view/test_replace.py
if using_cow: | ||
return [self.copy(deep=False)] | ||
else: | ||
return [self] if inplace else [self.copy()] | ||
|
||
if mask is None: | ||
mask = missing.mask_missing(values, to_replace) | ||
if not mask.any(): |
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.
If we pass an axis(I thinkaxis=0
should work, need to be careful of 1-D values/mask though), than we should have enough info to split the block.
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.
Yep agree, but right now this is not that high on my list of priorities. With the ref tracking how it is right now, this only defers the copy a little bit
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. Can you update the list on #49473?
thanks @phofl |
…when not necessary
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.