From b0cd06a562d2127150cbb89bca0d30d515025393 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 14 Aug 2019 14:43:59 -0700 Subject: [PATCH 1/6] remove incorrect check --- pandas/core/ops/__init__.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index 843f12c20b07b..29ecd46a0242a 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -831,13 +831,6 @@ def wrapper(self, other, axis=None): if isinstance(other, ABCSeries) and not self._indexed_same(other): raise ValueError("Can only compare identically-labeled Series objects") - elif ( - is_list_like(other) - and len(other) != len(self) - and not isinstance(other, (set, frozenset)) - ): - raise ValueError("Lengths must match") - elif isinstance(other, (np.ndarray, ABCIndexClass, ABCSeries)): # TODO: make this treatment consistent across ops and classes. # We are not catching all listlikes here (e.g. frozenset, tuple) From 6dca9a512f98303fdc693e1764636832ef0db810 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 14 Aug 2019 14:45:55 -0700 Subject: [PATCH 2/6] avoid rename --- pandas/core/ops/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index 29ecd46a0242a..ef03316f69df4 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -881,9 +881,11 @@ def wrapper(self, other, axis=None): ) result = self._constructor(res_values, index=self.index) - # rename is needed in case res_name is None and result.name - # is not. - return finalizer(result).rename(res_name) + result = finalizer(result) + + # pin name for case res_name is None and result.name is not. + result.name = res_name + return result wrapper.__name__ = op_name return wrapper From b709f89ad156af89e3243a29ee0fd8394c9c5f9f Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Thu, 15 Aug 2019 10:21:58 -0700 Subject: [PATCH 3/6] remove comment, fix check --- pandas/core/ops/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index eff264a48cd71..0b08adb420fb3 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -37,6 +37,7 @@ ABCDataFrame, ABCDatetimeArray, ABCDatetimeIndex, + ABCExtensionArray, ABCIndex, ABCIndexClass, ABCSeries, @@ -804,7 +805,9 @@ def wrapper(self, other, axis=None): if isinstance(other, ABCSeries) and not self._indexed_same(other): raise ValueError("Can only compare identically-labeled Series objects") - elif isinstance(other, (np.ndarray, ABCIndexClass, ABCSeries)): + elif isinstance( + other, (np.ndarray, ABCExtensionArray, ABCIndexClass, ABCSeries) + ): # TODO: make this treatment consistent across ops and classes. # We are not catching all listlikes here (e.g. frozenset, tuple) # The ambiguous case is object-dtype. See GH#27803 @@ -855,8 +858,6 @@ def wrapper(self, other, axis=None): result = self._constructor(res_values, index=self.index) result = finalizer(result) - - # pin name for case res_name is None and result.name is not. result.name = res_name return result From a68f8e6c383a34498005eeb927abaeca6d605640 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 16 Aug 2019 09:06:48 -0700 Subject: [PATCH 4/6] re-comment --- pandas/core/ops/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index 33487d9421ac2..dae437a3a775a 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -753,6 +753,9 @@ def wrapper(self, other, axis=None): result = self._constructor(res_values, index=self.index) result = finalizer(result) + + # pin name for case where res_name is not and result.name is not + # (because finalizer transferred self.name) result.name = res_name return result From 67df3069c246e3d7ab4752585ae8ed0747551f87 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 16 Aug 2019 11:17:16 -0700 Subject: [PATCH 5/6] Update pandas/core/ops/__init__.py Co-Authored-By: Joris Van den Bossche --- pandas/core/ops/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index dae437a3a775a..7caa540643889 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -754,7 +754,7 @@ def wrapper(self, other, axis=None): result = self._constructor(res_values, index=self.index) result = finalizer(result) - # pin name for case where res_name is not and result.name is not + # Set the result's name after finalizer is called because finalizer would set it back to self.name # (because finalizer transferred self.name) result.name = res_name return result From 0e46044b43be7a7d8c0482e5a38a40ecfb54f156 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 16 Aug 2019 11:18:51 -0700 Subject: [PATCH 6/6] fix post-suggestion --- pandas/core/ops/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index 7caa540643889..de1462d9ae335 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -754,8 +754,8 @@ def wrapper(self, other, axis=None): result = self._constructor(res_values, index=self.index) result = finalizer(result) - # Set the result's name after finalizer is called because finalizer would set it back to self.name - # (because finalizer transferred self.name) + # Set the result's name after finalizer is called because finalizer + # would set it back to self.name result.name = res_name return result