Skip to content
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

DOC: Add note for copy keywords for Copy-on-Write #56033

Merged
merged 6 commits into from
Nov 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6428,6 +6428,15 @@ def astype(
Return a copy when ``copy=True`` (be very careful setting
``copy=False`` as changes to values then may propagate to other
pandas objects).

.. note::
Copy link
Member

@lithomas1 lithomas1 Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this warning a shared docstring?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I find shared docstrings quite annoying (and untransparant, difficult to understand), so while it's nice to deduplicate and only have 1 place to update this note, I am also fine with simply copy-pasting this note multiple times once we have finalized its wording.

(certainly for methods that right now don't yet make use of shared docstrings)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't like them either

The copy-keyword will change behavior in pandas 3.0.
phofl marked this conversation as resolved.
Show resolved Hide resolved
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
copy-keyword will use a lazy copy mechanism and ignore the copy
phofl marked this conversation as resolved.
Show resolved Hide resolved
keyword. The copy-keyword will be removed in a future version of
phofl marked this conversation as resolved.
Show resolved Hide resolved
pandas.
errors : {'raise', 'ignore'}, default 'raise'
Control raising of exceptions on invalid data for provided dtype.

Expand Down
Loading