Skip to content

REF: pass str_rep through arithmetic ops more consistently #31297

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 8 commits into from
Feb 23, 2020
8 changes: 5 additions & 3 deletions pandas/core/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def f(self, other, axis=default_axis, level=None):
return _combine_series_frame(self, other, op, axis=axis)
else:
# in this case we always have `np.ndim(other) == 0`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment on your other PR. I would rather not do this as another arg, better is to create a NamedTuple that holds both and pass that around

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another alternative would be to make the getting of str_rep a dict lookup in expressions

new_data = dispatch_to_series(self, other, op)
new_data = dispatch_to_series(self, other, op, str_rep)
return self._construct_result(new_data)

f.__name__ = op_name
Expand All @@ -860,13 +860,15 @@ def f(self, other):
new_data = dispatch_to_series(self, other, op, str_rep)

elif isinstance(other, ABCSeries):
new_data = dispatch_to_series(self, other, op, axis="columns")
new_data = dispatch_to_series(
self, other, op, str_rep=str_rep, axis="columns"
)

else:

# straight boolean comparisons we want to allow all columns
# (regardless of dtype to pass thru) See #4537 for discussion.
new_data = dispatch_to_series(self, other, op)
new_data = dispatch_to_series(self, other, op, str_rep)

return self._construct_result(new_data)

Expand Down