Skip to content

requested edit to comparison method #27873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions pandas/core/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down