Skip to content

Commit eddeee5

Browse files
jbrockmendeljreback
authored andcommitted
requested edit to comparison method (#27873)
1 parent 6a927b0 commit eddeee5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pandas/core/ops/__init__.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,12 @@ def wrapper(self, other, axis=None):
841841
):
842842
raise ValueError("Lengths must match")
843843

844-
elif (
845-
is_list_like(other)
846-
and len(other) != len(self)
847-
and not isinstance(other, frozenset)
848-
):
849-
# TODO: why are we treating len-1 frozenset differently?
850-
raise ValueError("Lengths must match to compare")
844+
elif isinstance(other, (np.ndarray, ABCIndexClass, ABCSeries)):
845+
# TODO: make this treatment consistent across ops and classes.
846+
# We are not catching all listlikes here (e.g. frozenset, tuple)
847+
# The ambiguous case is object-dtype. See GH#27803
848+
if len(self) != len(other):
849+
raise ValueError("Lengths must match to compare")
851850

852851
if is_categorical_dtype(self):
853852
# Dispatch to Categorical implementation; CategoricalIndex

0 commit comments

Comments
 (0)