From 69d912da679d57465622d67af648c7cba2fd53c1 Mon Sep 17 00:00:00 2001 From: Tan Nian Wei Date: Wed, 17 Aug 2022 21:05:10 +0800 Subject: [PATCH 1/2] BUG: #39448 fixed dropna to return copy correctly --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 7a4f41da5840c..c7aa3f7da6f3c 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6546,7 +6546,7 @@ def dropna( if np.all(mask): result = self.copy() else: - result = self.loc(axis=axis)[mask] + result = self.loc(axis=axis)[mask].copy() if not inplace: return result From 282025bb6efcd43c876c64e628ce6125e4276b9f Mon Sep 17 00:00:00 2001 From: Tan Nian Wei Date: Wed, 17 Aug 2022 23:45:03 +0800 Subject: [PATCH 2/2] docs: added relevant mention in whatsnew --- doc/source/whatsnew/v1.5.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 0ceac8aeb9db8..0d5b96439843c 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -993,7 +993,7 @@ Indexing - Bug in :meth:`DataFrame.sum` min_count changes dtype if input contains NaNs (:issue:`46947`) - Bug in :class:`IntervalTree` that lead to an infinite recursion. (:issue:`46658`) - Bug in :class:`PeriodIndex` raising ``AttributeError`` when indexing on ``NA``, rather than putting ``NaT`` in its place. (:issue:`46673`) -- +- Bug in :meth:`DataFrame.dropna` where a copy of the dataframe was not returned if rows are dropped (:issue:`39448`) Missing ^^^^^^^