diff --git a/pandas/core/frame.py b/pandas/core/frame.py index e9d8ba6aab4a8..07756b6af04f5 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8067,43 +8067,49 @@ def _flex_cmp_method(self, other, op, *, axis: Axis = "columns", level=None): return self._construct_result(new_data) @Appender(ops.make_flex_doc("eq", "dataframe")) - def eq(self, other, axis: Axis = "columns", level=None): + def eq(self, other, axis: Axis = "columns", level=None) -> DataFrame: return self._flex_cmp_method(other, operator.eq, axis=axis, level=level) @Appender(ops.make_flex_doc("ne", "dataframe")) - def ne(self, other, axis: Axis = "columns", level=None): + def ne(self, other, axis: Axis = "columns", level=None) -> DataFrame: return self._flex_cmp_method(other, operator.ne, axis=axis, level=level) @Appender(ops.make_flex_doc("le", "dataframe")) - def le(self, other, axis: Axis = "columns", level=None): + def le(self, other, axis: Axis = "columns", level=None) -> DataFrame: return self._flex_cmp_method(other, operator.le, axis=axis, level=level) @Appender(ops.make_flex_doc("lt", "dataframe")) - def lt(self, other, axis: Axis = "columns", level=None): + def lt(self, other, axis: Axis = "columns", level=None) -> DataFrame: return self._flex_cmp_method(other, operator.lt, axis=axis, level=level) @Appender(ops.make_flex_doc("ge", "dataframe")) - def ge(self, other, axis: Axis = "columns", level=None): + def ge(self, other, axis: Axis = "columns", level=None) -> DataFrame: return self._flex_cmp_method(other, operator.ge, axis=axis, level=level) @Appender(ops.make_flex_doc("gt", "dataframe")) - def gt(self, other, axis: Axis = "columns", level=None): + def gt(self, other, axis: Axis = "columns", level=None) -> DataFrame: return self._flex_cmp_method(other, operator.gt, axis=axis, level=level) @Appender(ops.make_flex_doc("add", "dataframe")) - def add(self, other, axis: Axis = "columns", level=None, fill_value=None): + def add( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, operator.add, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("radd", "dataframe")) - def radd(self, other, axis: Axis = "columns", level=None, fill_value=None): + def radd( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, roperator.radd, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("sub", "dataframe")) - def sub(self, other, axis: Axis = "columns", level=None, fill_value=None): + def sub( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, operator.sub, level=level, fill_value=fill_value, axis=axis ) @@ -8111,13 +8117,17 @@ def sub(self, other, axis: Axis = "columns", level=None, fill_value=None): subtract = sub @Appender(ops.make_flex_doc("rsub", "dataframe")) - def rsub(self, other, axis: Axis = "columns", level=None, fill_value=None): + def rsub( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, roperator.rsub, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("mul", "dataframe")) - def mul(self, other, axis: Axis = "columns", level=None, fill_value=None): + def mul( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, operator.mul, level=level, fill_value=fill_value, axis=axis ) @@ -8125,13 +8135,17 @@ def mul(self, other, axis: Axis = "columns", level=None, fill_value=None): multiply = mul @Appender(ops.make_flex_doc("rmul", "dataframe")) - def rmul(self, other, axis: Axis = "columns", level=None, fill_value=None): + def rmul( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, roperator.rmul, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("truediv", "dataframe")) - def truediv(self, other, axis: Axis = "columns", level=None, fill_value=None): + def truediv( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, operator.truediv, level=level, fill_value=fill_value, axis=axis ) @@ -8140,7 +8154,9 @@ def truediv(self, other, axis: Axis = "columns", level=None, fill_value=None): divide = truediv @Appender(ops.make_flex_doc("rtruediv", "dataframe")) - def rtruediv(self, other, axis: Axis = "columns", level=None, fill_value=None): + def rtruediv( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, roperator.rtruediv, level=level, fill_value=fill_value, axis=axis ) @@ -8148,37 +8164,49 @@ def rtruediv(self, other, axis: Axis = "columns", level=None, fill_value=None): rdiv = rtruediv @Appender(ops.make_flex_doc("floordiv", "dataframe")) - def floordiv(self, other, axis: Axis = "columns", level=None, fill_value=None): + def floordiv( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, operator.floordiv, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("rfloordiv", "dataframe")) - def rfloordiv(self, other, axis: Axis = "columns", level=None, fill_value=None): + def rfloordiv( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, roperator.rfloordiv, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("mod", "dataframe")) - def mod(self, other, axis: Axis = "columns", level=None, fill_value=None): + def mod( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, operator.mod, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("rmod", "dataframe")) - def rmod(self, other, axis: Axis = "columns", level=None, fill_value=None): + def rmod( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, roperator.rmod, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("pow", "dataframe")) - def pow(self, other, axis: Axis = "columns", level=None, fill_value=None): + def pow( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, operator.pow, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("rpow", "dataframe")) - def rpow(self, other, axis: Axis = "columns", level=None, fill_value=None): + def rpow( + self, other, axis: Axis = "columns", level=None, fill_value=None + ) -> DataFrame: return self._flex_arith_method( other, roperator.rpow, level=level, fill_value=fill_value, axis=axis ) diff --git a/pandas/core/series.py b/pandas/core/series.py index 9a934217ed5c1..318f3fee2756b 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5946,55 +5946,55 @@ def _flex_method(self, other, op, *, level=None, fill_value=None, axis: Axis = 0 return op(self, other) @Appender(ops.make_flex_doc("eq", "series")) - def eq(self, other, level=None, fill_value=None, axis: Axis = 0): + def eq(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.eq, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("ne", "series")) - def ne(self, other, level=None, fill_value=None, axis: Axis = 0): + def ne(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.ne, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("le", "series")) - def le(self, other, level=None, fill_value=None, axis: Axis = 0): + def le(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.le, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("lt", "series")) - def lt(self, other, level=None, fill_value=None, axis: Axis = 0): + def lt(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.lt, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("ge", "series")) - def ge(self, other, level=None, fill_value=None, axis: Axis = 0): + def ge(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.ge, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("gt", "series")) - def gt(self, other, level=None, fill_value=None, axis: Axis = 0): + def gt(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.gt, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("add", "series")) - def add(self, other, level=None, fill_value=None, axis: Axis = 0): + def add(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.add, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("radd", "series")) - def radd(self, other, level=None, fill_value=None, axis: Axis = 0): + def radd(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, roperator.radd, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("sub", "series")) - def sub(self, other, level=None, fill_value=None, axis: Axis = 0): + def sub(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.sub, level=level, fill_value=fill_value, axis=axis ) @@ -6002,7 +6002,7 @@ def sub(self, other, level=None, fill_value=None, axis: Axis = 0): subtract = sub @Appender(ops.make_flex_doc("rsub", "series")) - def rsub(self, other, level=None, fill_value=None, axis: Axis = 0): + def rsub(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, roperator.rsub, level=level, fill_value=fill_value, axis=axis ) @@ -6014,7 +6014,7 @@ def mul( level: Level | None = None, fill_value: float | None = None, axis: Axis = 0, - ): + ) -> Series: return self._flex_method( other, operator.mul, level=level, fill_value=fill_value, axis=axis ) @@ -6022,13 +6022,13 @@ def mul( multiply = mul @Appender(ops.make_flex_doc("rmul", "series")) - def rmul(self, other, level=None, fill_value=None, axis: Axis = 0): + def rmul(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, roperator.rmul, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("truediv", "series")) - def truediv(self, other, level=None, fill_value=None, axis: Axis = 0): + def truediv(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.truediv, level=level, fill_value=fill_value, axis=axis ) @@ -6037,7 +6037,7 @@ def truediv(self, other, level=None, fill_value=None, axis: Axis = 0): divide = truediv @Appender(ops.make_flex_doc("rtruediv", "series")) - def rtruediv(self, other, level=None, fill_value=None, axis: Axis = 0): + def rtruediv(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, roperator.rtruediv, level=level, fill_value=fill_value, axis=axis ) @@ -6045,49 +6045,49 @@ def rtruediv(self, other, level=None, fill_value=None, axis: Axis = 0): rdiv = rtruediv @Appender(ops.make_flex_doc("floordiv", "series")) - def floordiv(self, other, level=None, fill_value=None, axis: Axis = 0): + def floordiv(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.floordiv, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("rfloordiv", "series")) - def rfloordiv(self, other, level=None, fill_value=None, axis: Axis = 0): + def rfloordiv(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, roperator.rfloordiv, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("mod", "series")) - def mod(self, other, level=None, fill_value=None, axis: Axis = 0): + def mod(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.mod, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("rmod", "series")) - def rmod(self, other, level=None, fill_value=None, axis: Axis = 0): + def rmod(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, roperator.rmod, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("pow", "series")) - def pow(self, other, level=None, fill_value=None, axis: Axis = 0): + def pow(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, operator.pow, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("rpow", "series")) - def rpow(self, other, level=None, fill_value=None, axis: Axis = 0): + def rpow(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, roperator.rpow, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("divmod", "series")) - def divmod(self, other, level=None, fill_value=None, axis: Axis = 0): + def divmod(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, divmod, level=level, fill_value=fill_value, axis=axis ) @Appender(ops.make_flex_doc("rdivmod", "series")) - def rdivmod(self, other, level=None, fill_value=None, axis: Axis = 0): + def rdivmod(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: return self._flex_method( other, roperator.rdivmod, level=level, fill_value=fill_value, axis=axis )