From ece5d466391cdd893d37c1c43d1c4da8ffb0def6 Mon Sep 17 00:00:00 2001 From: Andrew Fiore-Gartland Date: Thu, 17 Mar 2016 21:44:00 -0700 Subject: [PATCH 1/2] Updated docstring for copy() method Added note that a copy with `deep=True` does not copy the data of objects contained in underlying arrays with `dtype=object`. --- pandas/core/generic.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 24b883b90cf5d..cb155f24fe9ac 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -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. + + Note that when ``deep=True`` data is copied unless ``dtype=object``, + in which case only the reference to the object is copied. This is + in contrast to ``copy.deepcopy`` in the Standard Library, which + recursively copies object data. Returns ------- From 3660bc122d80fb37475967ef5d8c80337d0df66c Mon Sep 17 00:00:00 2001 From: Andrew Fiore-Gartland Date: Wed, 23 Mar 2016 09:37:38 -0700 Subject: [PATCH 2/2] Explicit description of deep for True and False --- pandas/core/generic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index cb155f24fe9ac..d2379942de121 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2952,7 +2952,8 @@ 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, including a copy of the data and the indices. + With ``deep=False`` neither the indices or the data are copied. Note that when ``deep=True`` data is copied unless ``dtype=object``, in which case only the reference to the object is copied. This is