Skip to content

Commit 616232e

Browse files
committed
Add _validate_shape
1 parent 5fc95e1 commit 616232e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/core/arrays/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,10 @@ def _add_comparison_ops(cls):
891891
cls.__le__ = cls._create_comparison_method(operator.le)
892892
cls.__ge__ = cls._create_comparison_method(operator.ge)
893893

894+
def _validate_shape(self, other):
895+
if len(self) != len(other):
896+
raise ValueError('Lengths must match to compare')
897+
894898

895899
class ExtensionScalarOpsMixin(ExtensionOpsMixin):
896900
"""

pandas/core/arrays/period.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def wrapper(self, other):
6868
elif isinstance(other, cls):
6969
self._check_compatible_with(other)
7070

71-
if other.ndim > 0 and len(self) != len(other):
72-
raise ValueError('Lengths must match to compare')
71+
self._validate_shape(other)
7372

7473
if not_implemented:
7574
return NotImplemented

0 commit comments

Comments
 (0)