Skip to content

CLN: Remove incorrect check, comment, rename #27922

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 10 commits into from
Aug 20, 2019
19 changes: 9 additions & 10 deletions pandas/core/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
ABCDataFrame,
ABCDatetimeArray,
ABCDatetimeIndex,
ABCExtensionArray,
ABCIndexClass,
ABCSeries,
ABCSparseSeries,
Expand Down Expand Up @@ -699,14 +700,9 @@ def wrapper(self, other, axis=None):

if 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, (set, frozenset))
elif isinstance(
other, (np.ndarray, ABCExtensionArray, ABCIndexClass, ABCSeries)
):
raise ValueError("Lengths must match")

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
Expand Down Expand Up @@ -756,9 +752,12 @@ def wrapper(self, other, axis=None):
)

result = self._constructor(res_values, index=self.index)
# rename is needed in case res_name is None and result.name
# is not.
return finalizer(result).rename(res_name)
result = finalizer(result)

# pin name for case where res_name is not and result.name is not
# (because finalizer transferred self.name)
result.name = res_name
return result

wrapper.__name__ = op_name
return wrapper
Expand Down