Skip to content

Updated docstring for copy() method #12664

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
wants to merge 2 commits into from
Closed

Updated docstring for copy() method #12664

wants to merge 2 commits into from

Conversation

agartland
Copy link
Contributor

Added note that a copy with deep=True does not copy the data of objects contained in underlying arrays with dtype=object.

Added note that a copy with `deep=True` does not copy the data of objects contained in underlying arrays with `dtype=object`.
@jreback jreback added the Docs label Mar 18, 2016
@jreback jreback added this to the 0.18.1 milestone Mar 18, 2016
@@ -2952,7 +2952,12 @@ def copy(self, deep=True):
Parameters
----------
deep : boolean or string, default True
Make a deep copy, i.e. also copy data
Make a deep copy, i.e. also copy data.
Copy link
Contributor

Choose a reason for hiding this comment

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

change this to something like:

deep also copy the indexes (its not the data that addtionally gets copied; a shallow copy does this).

@agartland
Copy link
Contributor Author

Actually I think deep=False doesn't copy the data at all:

d = pd.DataFrame(rand(3,3))
c = d.copy(deep=False)
c.loc[0,0] = -9
print d

Seems like deep=False is a view of the data and uses the exact same objects for index and columns,
whereas deep=True is a copy of the data and a copy of the index and columns (except for dtype=object)

@agartland
Copy link
Contributor Author

I tried to be more explicit in this version. I hope this is helpful.

@jreback jreback closed this in 286e7a3 Mar 23, 2016
@jreback
Copy link
Contributor

jreback commented Mar 23, 2016

thanks @agartland

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.

Copy method does not make truly deep copies of dtype object arrays
2 participants