(
self, other, op, *, axis: Axis = "columns", level=None, fill_value=None
)
| 9502 | ).__finalize__(series) |
| 9503 | |
| 9504 | def _flex_arith_method( |
| 9505 | self, other, op, *, axis: Axis = "columns", level=None, fill_value=None |
| 9506 | ): |
| 9507 | axis = self._get_axis_number(axis) if axis is not None else 1 |
| 9508 | |
| 9509 | if self._should_reindex_frame_op(other, op, axis, fill_value, level): |
| 9510 | return self._arith_method_with_reindex(other, op) |
| 9511 | |
| 9512 | if isinstance(other, Series) and fill_value is not None: |
| 9513 | # TODO: We could allow this in cases where we end up going |
| 9514 | # through the DataFrame path |
| 9515 | raise NotImplementedError(f"fill_value {fill_value} not supported.") |
| 9516 | |
| 9517 | other = ops.maybe_prepare_scalar_for_op(other, self.shape) |
| 9518 | self, other = self._align_for_op(other, axis, flex=True, level=level) |
| 9519 | |
| 9520 | with np.errstate(all="ignore"): |
| 9521 | if isinstance(other, DataFrame): |
| 9522 | # Another DataFrame |
| 9523 | new_data = self._combine_frame(other, op, fill_value) |
| 9524 | |
| 9525 | elif isinstance(other, Series): |
| 9526 | new_data = self._dispatch_frame_op(other, op, axis=axis) |
| 9527 | else: |
| 9528 | # in this case we always have `np.ndim(other) == 0` |
| 9529 | if fill_value is not None: |
| 9530 | self = self.fillna(fill_value) |
| 9531 | |
| 9532 | new_data = self._dispatch_frame_op(other, op) |
| 9533 | |
| 9534 | return self._construct_result(new_data, other=other) |
| 9535 | |
| 9536 | def _construct_result(self, result, other) -> DataFrame: |
| 9537 | """ |
no test coverage detected