Skip to content

DOC: Be explicit whether a view or copy is returned #33451

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

Closed
FSpanhel opened this issue Apr 10, 2020 · 1 comment · Fixed by #34955
Closed

DOC: Be explicit whether a view or copy is returned #33451

FSpanhel opened this issue Apr 10, 2020 · 1 comment · Fixed by #34955
Assignees
Labels
Milestone

Comments

@FSpanhel
Copy link

Location of the documentation

For instance,
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html

Documentation problem

Sometimes the documentation is explicit that a copy is returned, e.g., https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.assign.html -> "Returns a new object ...", sometimes it is not or not explicitly stated, e.g., https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html -> "Drop specified labels from rows or columns."

Suggested fix for documentation

I wrongly assumed that pandas.DataFrame.drop returns a view because the first line of the docstring "Drop specified labels from rows or columns." suggests that, in my view. Later it is mentioned what happens if you set inplace = True. But you can only assume what happens if the default argument is used. Thus, the documentation is not clear w.r.t. this point and may be confusing to users, see #33438 or #30484.

I would suggest that the documentation reads `"Drop specified labels from rows or columns and return a new object"' and/or "inplace : bool, default False. If False, return a copy. If True, do operation inplace and return None." This also applies to other methods that have the inplace parameter.

Since the use of inplace = True seems to be discouraged (#30484) it would also make sense to mention that in the documentation?

@FSpanhel FSpanhel added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 10, 2020
@charlesdong1991 charlesdong1991 removed the Needs Triage Issue that has not been reviewed by a pandas team member label Apr 10, 2020
@marinomaria
Copy link
Contributor

take

marinomaria added a commit to marinomaria/pandas that referenced this issue Jun 23, 2020
marinomaria added a commit to marinomaria/pandas that referenced this issue Jun 23, 2020
marinomaria added a commit to marinomaria/pandas that referenced this issue Jun 23, 2020
simonjayhawkins pushed a commit that referenced this issue Jun 23, 2020
@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants