From fa9c7140e1c23e6c0cf966ebf67803a8190fb3b7 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sat, 28 Aug 2021 23:07:50 +0530 Subject: [PATCH 1/8] PERF: indexing.InsertColumns.time_assign_with_setitem --- pandas/core/frame.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index e02a88aafcf34..3fc83fd467bd1 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3620,9 +3620,11 @@ def __setitem__(self, key, value): self._setitem_array(key, value) elif isinstance(value, DataFrame): self._set_item_frame_value(key, value) - elif is_list_like(value) and 1 < len( - self.columns.get_indexer_for([key]) - ) == len(value): + elif ( + is_list_like(value) + and not self.columns.is_unique + and 1 < len(self.columns.get_indexer_for([key])) == len(value) + ): # Column to set is duplicated self._setitem_array([key], value) else: From 9568c73a43192ac0e88702bcd71efac69a5a91d3 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sun, 29 Aug 2021 02:30:27 +0530 Subject: [PATCH 2/8] added whatsnew --- doc/source/whatsnew/v1.3.3.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index 9aac0a9ad9681..fdebfff9a50f1 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -21,6 +21,15 @@ Fixed regressions .. --------------------------------------------------------------------------- +.. _whatsnew_133.performance: + +Performance improvements +~~~~~~~~~~~~~~~~~~~~~~~~ +- Performance improvement for :meth:`DataFrame.__setitem__` +- +- +.. --------------------------------------------------------------------------- + .. _whatsnew_133.bug_fixes: Bug fixes From 9cad0b1cbe034b6074cf97c48070ade1786c01af Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sun, 29 Aug 2021 12:23:36 +0530 Subject: [PATCH 3/8] more descriptive whatsnew --- doc/source/whatsnew/v1.3.3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index fdebfff9a50f1..103b3e2e32b9f 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,7 +25,7 @@ Fixed regressions Performance improvements ~~~~~~~~~~~~~~~~~~~~~~~~ -- Performance improvement for :meth:`DataFrame.__setitem__` +- Performance improvement for :meth:`DataFrame.__setitem__` with dataframes containing unique columns and list-like values - - .. --------------------------------------------------------------------------- From 1567d3c00fb34d92d1cbf4afe6c2c49759e4e83b Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sun, 29 Aug 2021 12:40:49 +0530 Subject: [PATCH 4/8] rectified whatsnew --- doc/source/whatsnew/v1.3.3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index 103b3e2e32b9f..085f62b005b40 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,7 +25,7 @@ Fixed regressions Performance improvements ~~~~~~~~~~~~~~~~~~~~~~~~ -- Performance improvement for :meth:`DataFrame.__setitem__` with dataframes containing unique columns and list-like values +- Performance improvement for :meth:`DataFrame.__setitem__` with dataframes containing unique columns - - .. --------------------------------------------------------------------------- From 256f80f9d30463a250ab95b93e5fb65427b09579 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Mon, 30 Aug 2021 14:34:44 +0530 Subject: [PATCH 5/8] added PR ref in whatsnew --- doc/source/whatsnew/v1.3.3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index 085f62b005b40..03364a92c5288 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,7 +25,7 @@ Fixed regressions Performance improvements ~~~~~~~~~~~~~~~~~~~~~~~~ -- Performance improvement for :meth:`DataFrame.__setitem__` with dataframes containing unique columns +- Performance improvement for :meth:`DataFrame.__setitem__` with dataframes containing unique columns (:issue:`43274`) - - .. --------------------------------------------------------------------------- From ed101667db74127adb978266cc062a3ffa46e1c2 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Mon, 30 Aug 2021 16:37:08 +0530 Subject: [PATCH 6/8] clear whatsnew --- doc/source/whatsnew/v1.3.3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index 03364a92c5288..89e973a10f23a 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,7 +25,7 @@ Fixed regressions Performance improvements ~~~~~~~~~~~~~~~~~~~~~~~~ -- Performance improvement for :meth:`DataFrame.__setitem__` with dataframes containing unique columns (:issue:`43274`) +- Performance improvement for :meth:`DataFrame.__setitem__` when the key or value is not a dataframe, or key is not list-like (:issue:`43274`) - - .. --------------------------------------------------------------------------- From aaa5fdfdc27bf14d744b362a4cc61f8b03a5565e Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Mon, 30 Aug 2021 18:16:13 +0530 Subject: [PATCH 7/8] suggested change --- doc/source/whatsnew/v1.3.3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index 89e973a10f23a..b3e0714cd1c83 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,7 +25,7 @@ Fixed regressions Performance improvements ~~~~~~~~~~~~~~~~~~~~~~~~ -- Performance improvement for :meth:`DataFrame.__setitem__` when the key or value is not a dataframe, or key is not list-like (:issue:`43274`) +- Performance improvement for :meth:`DataFrame.__setitem__` when the key or value is not a :class:`DataFrame`, or key is not list-like (:issue:`43274`) - - .. --------------------------------------------------------------------------- From 549b39e89a0ec951ac1f1e915f3f0fd09e041993 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Mon, 30 Aug 2021 20:15:06 +0530 Subject: [PATCH 8/8] added blank line --- doc/source/whatsnew/v1.3.3.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index b3e0714cd1c83..7c1a414c1f37d 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -28,6 +28,7 @@ Performance improvements - Performance improvement for :meth:`DataFrame.__setitem__` when the key or value is not a :class:`DataFrame`, or key is not list-like (:issue:`43274`) - - + .. --------------------------------------------------------------------------- .. _whatsnew_133.bug_fixes: