diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index a56521b9c9fec..c243b28aedd3c 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -835,13 +835,12 @@ def wrapper(self, other, axis=None): elif 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, frozenset) - ): - # TODO: why are we treating len-1 frozenset differently? - raise ValueError("Lengths must match to compare") + 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) + # The ambiguous case is object-dtype. See GH#27803 + if len(self) != len(other): + raise ValueError("Lengths must match to compare") if is_categorical_dtype(self): # Dispatch to Categorical implementation; CategoricalIndex