Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pandas-stubs/core/arraylike.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class OpsMixin:
def __rxor__(self, other: Any) -> Self: ...
# -------------------------------------------------------------
# Arithmetic Methods
def __sub__(self, other: Any) -> Self: ...
def __rsub__(self, other: Any) -> Self: ...
def __mul__(self, other: Any) -> Self: ...
def __rmul__(self, other: Any) -> Self: ...
# Handled by subclasses that specify only the valid values
Expand Down
37 changes: 16 additions & 21 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,22 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
level: Level | None = None,
fill_value: float | None = None,
) -> Self: ...
def __sub__(self, other: Any) -> Self: ...
def sub(
self,
other: num | ListLike | DataFrame,
axis: Axis | None = ...,
level: Level | None = ...,
fill_value: float | None = None,
) -> Self: ...
def __rsub__(self, other: Any) -> Self: ...
def rsub(
self,
other,
axis: Axis = ...,
level: Level | None = ...,
fill_value: float | None = None,
) -> Self: ...
@final
def add_prefix(self, prefix: _str, axis: Axis | None = None) -> Self: ...
@final
Expand Down Expand Up @@ -2353,13 +2369,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
level: Level | None = ...,
fill_value: float | None = None,
) -> Self: ...
def rsub(
self,
other,
axis: Axis = ...,
level: Level | None = ...,
fill_value: float | None = None,
) -> Self: ...
def rtruediv(
self,
other,
Expand Down Expand Up @@ -2405,20 +2414,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
numeric_only: _bool = False,
**kwargs: Any,
) -> Series: ...
def sub(
self,
other: num | ListLike | DataFrame,
axis: Axis | None = ...,
level: Level | None = ...,
fill_value: float | None = None,
) -> Self: ...
def subtract(
self,
other: num | ListLike | DataFrame,
axis: Axis | None = ...,
level: Level | None = ...,
fill_value: float | None = None,
) -> Self: ...
def sum(
self,
axis: Axis = 0,
Expand Down
164 changes: 164 additions & 0 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ from pandas import (
PeriodDtype,
PeriodIndex,
Series,
Timedelta,
TimedeltaIndex,
Timestamp,
)
from pandas.core.arrays import ExtensionArray
from pandas.core.base import IndexOpsMixin
Expand Down Expand Up @@ -60,6 +62,7 @@ from pandas._typing import (
GenericT_co,
HashableT,
IgnoreRaise,
Just,
Label,
Level,
MaskType,
Expand All @@ -77,12 +80,23 @@ from pandas._typing import (
np_ndarray_complex,
np_ndarray_float,
np_ndarray_str,
np_ndarray_td,
type_t,
)

class InvalidIndexError(Exception): ...

_ListLike: TypeAlias = ArrayLike | dict[_str, np.ndarray] | SequenceNotStr[S1]
_NumListLike: TypeAlias = (
ExtensionArray
| np_ndarray_bool
| np_ndarray_anyint
| np_ndarray_float
| np_ndarray_complex
| dict[_str, np.ndarray]
| Sequence[complex]
| IndexOpsMixin[complex]
)

class Index(IndexOpsMixin[S1]):
__hash__: ClassVar[None] # type: ignore[assignment]
Expand Down Expand Up @@ -626,6 +640,156 @@ class Index(IndexOpsMixin[S1]):
self: Index[_str], other: _str | Sequence[_str] | np_ndarray_str | Index[_str]
) -> Index[_str]: ...
@overload
def __sub__(self: Index[Never], other: DatetimeIndex) -> Never: ...
@overload
def __sub__(self: Index[Never], other: complex | _NumListLike | Index) -> Index: ...
@overload
def __sub__(self, other: Index[Never]) -> Index: ... # type: ignore[overload-overlap]
@overload
def __sub__(
self: Index[bool],
other: Just[int] | Sequence[Just[int]] | np_ndarray_anyint | Index[int],
) -> Index[int]: ...
@overload
def __sub__(
self: Index[bool],
other: Just[float] | Sequence[Just[float]] | np_ndarray_float | Index[float],
) -> Index[float]: ...
@overload
def __sub__(
self: Index[int],
other: (
int
| Sequence[int]
| np_ndarray_bool
| np_ndarray_anyint
| Index[bool]
| Index[int]
),
) -> Index[int]: ...
@overload
def __sub__(
self: Index[int],
other: Just[float] | Sequence[Just[float]] | np_ndarray_float | Index[float],
) -> Index[float]: ...
@overload
def __sub__(
self: Index[float],
other: (
float
| Sequence[float]
| np_ndarray_bool
| np_ndarray_anyint
| np_ndarray_float
| Index[bool]
| Index[int]
| Index[float]
),
) -> Index[float]: ...
@overload
def __sub__(
self: Index[complex],
other: (
T_COMPLEX
| Sequence[T_COMPLEX]
| np_ndarray_bool
| np_ndarray_anyint
| np_ndarray_float
| Index[T_COMPLEX]
),
) -> Index[complex]: ...
@overload
def __sub__(
self: Index[T_COMPLEX],
other: (
Just[complex]
| Sequence[Just[complex]]
| np_ndarray_complex
| Index[complex]
),
) -> Index[complex]: ...
@overload
def __sub__(
self: Index[Timestamp],
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaIndex,
) -> DatetimeIndex: ...
@overload
def __sub__(
self: Index[Timedelta],
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaIndex,
) -> TimedeltaIndex: ...
@overload
def __rsub__(self: Index[Never], other: DatetimeIndex) -> Never: ... # type: ignore[misc]
@overload
def __rsub__(
self: Index[Never], other: complex | _NumListLike | Index
) -> Index: ...
@overload
def __rsub__(self, other: Index[Never]) -> Index: ...
@overload
def __rsub__(
self: Index[bool],
other: Just[int] | Sequence[Just[int]] | np_ndarray_anyint | Index[int],
) -> Index[int]: ...
@overload
def __rsub__(
self: Index[bool],
other: Just[float] | Sequence[Just[float]] | np_ndarray_float | Index[float],
) -> Index[float]: ...
@overload
def __rsub__(
self: Index[int],
other: (
int
| Sequence[int]
| np_ndarray_bool
| np_ndarray_anyint
| Index[bool]
| Index[int]
),
) -> Index[int]: ...
@overload
def __rsub__(
self: Index[int],
other: Just[float] | Sequence[Just[float]] | np_ndarray_float | Index[float],
) -> Index[float]: ...
@overload
def __rsub__(
self: Index[float],
other: (
float
| Sequence[float]
| np_ndarray_bool
| np_ndarray_anyint
| np_ndarray_float
| Index[bool]
| Index[int]
| Index[float]
),
) -> Index[float]: ...
@overload
def __rsub__(
self: Index[complex],
other: (
T_COMPLEX
| Sequence[T_COMPLEX]
| np_ndarray_bool
| np_ndarray_anyint
| np_ndarray_float
| Index[T_COMPLEX]
),
) -> Index[complex]: ...
@overload
def __rsub__(
self: Index[T_COMPLEX],
other: (
Just[complex]
| Sequence[Just[complex]]
| np_ndarray_complex
| Index[complex]
),
) -> Index[complex]: ...
@overload
def __mul__(
self: Index[int] | Index[float], other: timedelta
) -> TimedeltaIndex: ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/indexes/datetimelike.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DatetimeIndexOpsMixin(ExtensionIndex[S1, GenericT_co]):
def argmax(
self, axis: AxisIndex | None = None, skipna: bool = True, *args, **kwargs
) -> np.int64: ...
def __rsub__( # type: ignore[override]
def __rsub__( # type: ignore[misc,override] # pyright: ignore[reportIncompatibleMethodOverride]
self, other: DatetimeIndexOpsMixin
) -> TimedeltaIndex: ...

Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/indexes/datetimes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ class DatetimeIndex(
def __add__( # pyright: ignore[reportIncompatibleMethodOverride]
self, other: timedelta | Timedelta | TimedeltaIndex | BaseOffset
) -> DatetimeIndex: ...
@overload
@overload # type: ignore[override]
def __sub__(self, other: TimedeltaSeries) -> TimestampSeries: ...
@overload
def __sub__(
self, other: timedelta | Timedelta | TimedeltaIndex | BaseOffset
) -> DatetimeIndex: ...
@overload
def __sub__(
def __sub__( # pyright: ignore[reportIncompatibleMethodOverride]
self, other: datetime | Timestamp | DatetimeIndex
) -> TimedeltaIndex: ...
@final
Expand Down
6 changes: 4 additions & 2 deletions pandas-stubs/core/indexes/period.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period, np.object_], PeriodIndexField
) -> Self: ...
@property
def values(self) -> np_1darray[np.object_]: ...
@overload
@overload # type: ignore[override]
def __sub__(self, other: Period) -> Index: ...
@overload
def __sub__(self, other: Self) -> Index: ...
Expand All @@ -45,7 +45,9 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period, np.object_], PeriodIndexField
@overload
def __sub__(self, other: NaTType) -> NaTType: ...
@overload
def __sub__(self, other: TimedeltaIndex | pd.Timedelta) -> Self: ...
def __sub__( # pyright: ignore[reportIncompatibleMethodOverride]
self, other: TimedeltaIndex | pd.Timedelta
) -> Self: ...
@overload # type: ignore[override]
def __rsub__(self, other: Period) -> Index: ...
@overload
Expand Down
4 changes: 3 additions & 1 deletion pandas-stubs/core/indexes/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class TimedeltaIndex(
self, other: dt.timedelta | Timedelta | Self
) -> Self: ...
def __radd__(self, other: dt.datetime | Timestamp | DatetimeIndex) -> DatetimeIndex: ... # type: ignore[override]
def __sub__(self, other: dt.timedelta | Timedelta | Self) -> Self: ...
def __sub__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
self, other: dt.timedelta | Timedelta | Self
) -> Self: ...
def __mul__(self, other: num) -> Self: ...
@overload # type: ignore[override]
def __truediv__(self, other: num | Sequence[float]) -> Self: ...
Expand Down
Loading
Loading