Skip to content

Commit 7939d93

Browse files
committed
Add _validate_shape
1 parent f4315ac commit 7939d93

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/core/arrays/base.py

+4
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,10 @@ def _add_comparison_ops(cls):
862862
cls.__le__ = cls._create_comparison_method(operator.le)
863863
cls.__ge__ = cls._create_comparison_method(operator.ge)
864864

865+
def _validate_shape(self, other):
866+
if len(self) != len(other):
867+
raise ValueError('Lengths must match to compare')
868+
865869

866870
class ExtensionScalarOpsMixin(ExtensionOpsMixin):
867871
"""

pandas/core/arrays/period.py

+1-2
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)