We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f4315ac commit 7939d93Copy full SHA for 7939d93
pandas/core/arrays/base.py
@@ -862,6 +862,10 @@ def _add_comparison_ops(cls):
862
cls.__le__ = cls._create_comparison_method(operator.le)
863
cls.__ge__ = cls._create_comparison_method(operator.ge)
864
865
+ def _validate_shape(self, other):
866
+ if len(self) != len(other):
867
+ raise ValueError('Lengths must match to compare')
868
+
869
870
class ExtensionScalarOpsMixin(ExtensionOpsMixin):
871
"""
pandas/core/arrays/period.py
@@ -68,8 +68,7 @@ def wrapper(self, other):
68
elif isinstance(other, cls):
69
self._check_compatible_with(other)
70
71
- if other.ndim > 0 and len(self) != len(other):
72
- raise ValueError('Lengths must match to compare')
+ self._validate_shape(other)
73
74
if not_implemented:
75
return NotImplemented
0 commit comments