-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
BUG/CoW: Series.rename not making a lazy copy when passed a scalar #53189
Conversation
pandas/core/series.py
Outdated
@@ -4667,7 +4671,9 @@ def rename( | |||
errors=errors, | |||
) | |||
else: | |||
return self._set_name(index, inplace=inplace) | |||
return self._set_name( | |||
index, inplace=inplace, deep=copy and not using_copy_on_write() |
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.
Any reason we are doing this here and not in _set_name
?
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.
Simply passing copy through should be sufficient though
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.
It's to ignore copy=True, when Copy on Write is activated. I just copy pasted from your code in #51464
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.
Forgot about this, thx.
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.
Nothing else calls _set_name
other than rename
, so I just left the Copy on Write logic in rename
itself. I can move it if you want me to.
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 more consistent to push it down, but not a really strong opinion
thx @lithomas1 |
…y copy when passed a scalar
… a lazy copy when passed a scalar) (#53221) * Backport PR #53189: BUG/CoW: Series.rename not making a lazy copy when passed a scalar * Update test_setitem.py --------- Co-authored-by: Thomas Li <[email protected]>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.I put this in for 2.0.2 since we claim that the lazy-copy was implemented for
rename
in 2.0