Skip to content

DOC: elaborate on copies vs in place operations in comparison docs #38994

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 2 commits into from
Jan 8, 2021

Conversation

afeld
Copy link
Member

@afeld afeld commented Jan 6, 2021

Screen Shot 2021-01-06 at 12 15 05 AM

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry


sorted_df = df.sort_values("col1")

* Use the ``inplace=True`` keyword argument, where available
Copy link
Contributor

Choose a reason for hiding this comment

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

frown on this

in place is never recommended

Copy link
Member Author

Choose a reason for hiding this comment

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

A few options:

  • Say "in order of preference"
  • Mention inplace as "you will come across this, but don't use it"
  • Remove mention entirely

Strong feelings?

Copy link
Contributor

Choose a reason for hiding this comment

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

i ok with mentioning it, but put it in a note and point to this link: https://pandas.pydata.org/pandas-docs/dev/user_guide/indexing.html#indexing-view-versus-copy

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, though the "Returning a view versus a copy" section doesn't actually mention inplace. I'd submit a pull request to add an explanation, but frankly, that's one area of pandas that's still pretty fuzzy to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure that would be great

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 I mean is "I'm not sure I understand it fully myself, so would love an explanation from someone else" 😊

Copy link
Contributor

Choose a reason for hiding this comment

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

oh i c. check this blog by @TomAugspurger https://tomaugspurger.github.io/method-chaining.html

generaly inplace doesn't do a whole lot, is not idiomatic, and cause copy/view issues.

@jreback jreback added the Docs label Jan 6, 2021
@jreback jreback added this to the 1.3 milestone Jan 6, 2021
@jreback
Copy link
Contributor

jreback commented Jan 7, 2021

also pls merge master

@afeld afeld force-pushed the comparison-copy-vs-in-place branch from 698a3d1 to 0ff288c Compare January 8, 2021 06:31
@afeld afeld requested a review from jreback January 8, 2021 06:35
@jreback jreback merged commit 510bc20 into pandas-dev:master Jan 8, 2021
@jreback
Copy link
Contributor

jreback commented Jan 8, 2021

thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants