Skip to content

Commit d64c7df

Browse files
committed
Add _validate_shape
1 parent 9bca2c9 commit d64c7df

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
@@ -917,6 +917,10 @@ def _add_comparison_ops(cls):
917917
cls.__le__ = cls._create_comparison_method(operator.le)
918918
cls.__ge__ = cls._create_comparison_method(operator.ge)
919919

920+
def _validate_shape(self, other):
921+
if len(self) != len(other):
922+
raise ValueError('Lengths must match to compare')
923+
920924

921925
class ExtensionScalarOpsMixin(ExtensionOpsMixin):
922926
"""

pandas/core/arrays/period.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def wrapper(self, other):
6767
elif isinstance(other, cls):
6868
self._check_compatible_with(other)
6969

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

7372
if not_implemented:
7473
return NotImplemented

0 commit comments

Comments
 (0)