Series comparison ops __finalize__ inconsistent #19271
Labels
Compat
pandas objects compatability with Numpy or Python functions
Duplicate Report
Duplicate issue or pull request
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Looking at core.ops. _comp_method_SERIES and whether we can have the datetime and timedelta cases defer to Index subclass implementations, a couple questions come up:
https://github.com/pandas-dev/pandas/blob/master/pandas/core/ops.py#L744
This
return op(y, x)
looks weird. Should it be a reverse-op? e.g if op is operator.ge, should this becomereturn operator.le(y, x)
? Maybe this is irrelevant if categorical comparisons are only defined for__eq__
and__ne__
? If that is the explanation, there should be a comment.Special casing for PeriodIndex:
I couldn't tell from #13637 what the connection was. Commenting this out did not appear to break anything in the tests. Anyone know if this is still relevant?
Update I forgot to mention the question mentioned in the Issue title. Most cases return
self._constructor(res, index=self.index, name=whatever)
, but one case returnsself._constructor(na_op(self.values, np.asarray(other)), index=self.index).__finalize__(self)
. Why is__finalize__
called in this case but not others?The text was updated successfully, but these errors were encountered: