MCPcopy
hub / github.com/pandas-dev/pandas / _flex_arith_method

Method _flex_arith_method

pandas/core/frame.py:9504–9534  ·  view source on GitHub ↗
(
        self, other, op, *, axis: Axis = "columns", level=None, fill_value=None
    )

Source from the content-addressed store, hash-verified

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 """

Callers 14

addMethod · 0.95
raddMethod · 0.95
subMethod · 0.95
rsubMethod · 0.95
mulMethod · 0.95
rmulMethod · 0.95
truedivMethod · 0.95
rtruedivMethod · 0.95
floordivMethod · 0.95
rfloordivMethod · 0.95
modMethod · 0.95
rmodMethod · 0.95

Calls 8

_align_for_opMethod · 0.95
_combine_frameMethod · 0.95
_dispatch_frame_opMethod · 0.95
_construct_resultMethod · 0.95
_get_axis_numberMethod · 0.80
fillnaMethod · 0.45

Tested by

no test coverage detected