Skip to content

DOC: Add comment about inplace/copy proposal #51487

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

Merged
merged 4 commits into from
Feb 20, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Feb 19, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@@ -1423,6 +1423,15 @@ Metadata

Other
^^^^^

.. note::
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be a bit strange location to put it? (inside a "Bugs" subsection)

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 good point, but did not want to put it right at the top, so not really sure where to place it

Copy link
Member Author

Choose a reason for hiding this comment

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

We could put it under other api changes?


.. code-block:: python

df.replace(5, inplace=True)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think replace is a good example. We are keeping inplace there.

Copy link
Member Author

Choose a reason for hiding this comment

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

That’s why I am using it. I could add an explicit comment that replace is one of the few methods where we are keeping it

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a small note that replace might keep inplace

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, it might be good to also give an example of something that would lose inplace, for comparison's sake.

Copy link
Member Author

Choose a reason for hiding this comment

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

What would you want to show with it? I am struggling to come up with an explanation for such an example

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we would need to go to in detail, just say e.g.

"Some methods cannot operate inplace (e.g. reindex), or would already avoid copying the data with Copy on Write. (e.g. rename)

It is recommended that the inplace/copy parameters be avoided for those methods".

No big deal if we don't add this, though, since people can always read the PDEP.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah got you, I thought you wanted to add a code example.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave the suggestion to not use them out. When used in the appropriate context it can speed up your code. I think it's clear enough that users can figure the consequences out for themself.

@lithomas1 lithomas1 added this to the 2.0 milestone Feb 20, 2023
@lithomas1 lithomas1 added Docs inplace Relating to inplace parameter or equivalent labels Feb 20, 2023
Copy link
Member

@lithomas1 lithomas1 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for writing this up.

@phofl
Copy link
Member Author

phofl commented Feb 20, 2023

Thx, let’s merge then we‘ll get it into the rc

@phofl phofl merged commit 3b295c9 into pandas-dev:main Feb 20, 2023
@phofl phofl deleted the doc_inplace_copy branch February 22, 2023 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs inplace Relating to inplace parameter or equivalent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants