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

Method _flex_method

pandas/core/series.py:6856–6883  ·  view source on GitHub ↗
(self, other, op, *, level=None, fill_value=None, axis: Axis = 0)

Source from the content-addressed store, hash-verified

6854 return out
6855
6856 def _flex_method(self, other, op, *, level=None, fill_value=None, axis: Axis = 0):
6857 if axis is not None:
6858 self._get_axis_number(axis)
6859
6860 res_name = ops.get_op_result_name(self, other)
6861
6862 if isinstance(other, Series):
6863 return self._binop(other, op, level=level, fill_value=fill_value)
6864 elif isinstance(other, (np.ndarray, list, tuple, ExtensionArray)):
6865 if len(other) != len(self):
6866 raise ValueError("Lengths must be equal")
6867 other = self._constructor(other, self.index, copy=False)
6868 result = self._binop(other, op, level=level, fill_value=fill_value)
6869 result._name = res_name
6870 return result
6871 elif isinstance(other, ABCDataFrame):
6872 # GH#46179
6873 raise TypeError(
6874 f"Series.{op.__name__.strip('_')} does not support a DataFrame "
6875 f"`other`. Use df.{op.__name__.strip('_')}(ser) instead."
6876 )
6877 else:
6878 if fill_value is not None:
6879 if isna(other):
6880 return op(self, fill_value)
6881 self = self.fillna(fill_value)
6882
6883 return op(self, other)
6884
6885 def eq(
6886 self,

Callers 15

eqMethod · 0.95
neMethod · 0.95
leMethod · 0.95
ltMethod · 0.95
geMethod · 0.95
gtMethod · 0.95
addMethod · 0.95
raddMethod · 0.95
subMethod · 0.95
rsubMethod · 0.95
mulMethod · 0.95
rmulMethod · 0.95

Calls 7

_binopMethod · 0.95
_constructorMethod · 0.95
isnaFunction · 0.90
opFunction · 0.85
_get_axis_numberMethod · 0.80
stripMethod · 0.80
fillnaMethod · 0.45

Tested by

no test coverage detected