Skip to content
Merged
252 changes: 241 additions & 11 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ from typing import (
Generic,
Literal,
NoReturn,
TypeVar,
final,
overload,
)
Expand Down Expand Up @@ -175,6 +176,8 @@ from pandas._typing import (
VoidDtypeArg,
WriteBuffer,
np_ndarray_anyint,
np_ndarray_complex,
np_ndarray_float,
npt,
num,
)
Expand All @@ -184,6 +187,8 @@ from pandas.core.dtypes.dtypes import CategoricalDtype

from pandas.plotting import PlotAccessor

_T_COMPLEX = TypeVar("_T_COMPLEX", bound=complex)

class _iLocIndexerSeries(_iLocIndexer, Generic[S1]):
# get item
@overload
Expand Down Expand Up @@ -1617,12 +1622,48 @@ class Series(IndexOpsMixin[S1], NDFrame):
# just failed to generate these so I couldn't match
# them up.
@overload
def __add__(self, other: S1 | Self) -> Self: ...
@overload
def __add__(
self,
other: num | _str | timedelta | Timedelta | _ListLike | Series | np.timedelta64,
self: Series[Never],
other: Scalar | _ListLike | Series,
) -> Series: ...
@overload
def __add__(self, other: Series[Never]) -> Series: ...
@overload
def __add__(
self: Series[int], other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX]
) -> Series[_T_COMPLEX]: ...
@overload
def __add__(self: Series[int], other: np_ndarray_anyint) -> Series[int]: ...
@overload
def __add__(self: Series[int], other: np_ndarray_float) -> Series[float]: ...
@overload
def __add__(self: Series[int], other: np_ndarray_complex) -> Series[complex]: ...
@overload
def __add__(
self: Series[float],
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float | Series[int],
) -> Series[float]: ...
@overload
def __add__(
self: Series[float],
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
) -> Series[_T_COMPLEX]: ...
@overload
def __add__(self: Series[float], other: np_ndarray_complex) -> Series[complex]: ...
@overload
def __add__(
self: Series[complex],
other: (
_T_COMPLEX
| Sequence[_T_COMPLEX]
| Series[_T_COMPLEX]
| np_ndarray_anyint
| np_ndarray_float
| np_ndarray_complex
),
) -> Series[complex]: ...
@overload
def __add__(self, other: S1 | Self) -> Self: ...
# ignore needed for mypy as we want different results based on the arguments
@overload # type: ignore[override]
def __and__( # pyright: ignore[reportOverlappingOverload]
Expand Down Expand Up @@ -1663,9 +1704,40 @@ class Series(IndexOpsMixin[S1], NDFrame):
@overload
def __or__(self, other: int | np_ndarray_anyint | Series[int]) -> Series[int]: ...
@overload
def __radd__(self, other: S1 | Series[S1]) -> Self: ...
def __radd__(self: Series[Never], other: Scalar | _ListLike) -> Series: ...
@overload
def __radd__(
self: Series[int], other: _T_COMPLEX | Sequence[_T_COMPLEX]
) -> Series[_T_COMPLEX]: ...
@overload
def __radd__(self: Series[int], other: np_ndarray_anyint) -> Series[int]: ...
@overload
def __radd__(self: Series[int], other: np_ndarray_float) -> Series[float]: ...
@overload
def __radd__(self: Series[int], other: np_ndarray_complex) -> Series[complex]: ...
@overload
def __radd__(
self: Series[float],
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float,
) -> Series[float]: ...
@overload
def __radd__(
self: Series[float], other: _T_COMPLEX | Sequence[_T_COMPLEX]
) -> Series[_T_COMPLEX]: ...
@overload
def __radd__(self, other: num | _str | _ListLike | Series) -> Series: ...
def __radd__(self: Series[float], other: np_ndarray_complex) -> Series[complex]: ...
@overload
def __radd__(
self: Series[complex],
other: (
np_ndarray_anyint
| np_ndarray_float
| np_ndarray_complex
| Sequence[_T_COMPLEX]
),
) -> Series[complex]: ...
@overload
def __radd__(self, other: S1) -> Self: ...
# ignore needed for mypy as we want different results based on the arguments
@overload # type: ignore[override]
def __rand__( # pyright: ignore[reportOverlappingOverload]
Expand Down Expand Up @@ -1741,13 +1813,92 @@ class Series(IndexOpsMixin[S1], NDFrame):
@property
def loc(self) -> _LocIndexerSeries[S1]: ...
# Methods
@overload
def add(
self: Series[Never],
other: Scalar | _ListLike | Series,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series: ...
@overload
def add(
self: Series[int],
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[_T_COMPLEX]: ...
@overload
def add(
self: Series[int],
other: np_ndarray_anyint,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[int]: ...
@overload
def add(
self: Series[int],
other: np_ndarray_float,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[float]: ...
@overload
def add(
self: Series[int],
other: np_ndarray_complex,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[complex]: ...
@overload
def add(
self: Series[float],
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float | Series[int],
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[float]: ...
@overload
def add(
self: Series[float],
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[_T_COMPLEX]: ...
@overload
def add(
self: Series[float],
other: np_ndarray_complex,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[complex]: ...
@overload
def add(
self: Series[complex],
other: (
Sequence[_T_COMPLEX]
| np_ndarray_anyint
| np_ndarray_float
| np_ndarray_complex
| Series[_T_COMPLEX]
),
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[complex]: ...
@overload
def add(
self,
other: Series[S1] | Scalar,
other: S1 | Series[S1],
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[S1]: ...
) -> Self: ...
def all(
self,
axis: AxisIndex = ...,
Expand Down Expand Up @@ -1985,13 +2136,92 @@ class Series(IndexOpsMixin[S1], NDFrame):
min_count: int = ...,
**kwargs: Any,
) -> Scalar: ...
@overload
def radd(
self: Series[Never],
other: Scalar | _ListLike | Series,
level: Level | None = ...,
fill_value: float | None = ...,
axis: AxisIndex = ...,
) -> Series: ...
@overload
def radd(
self: Series[int],
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[_T_COMPLEX]: ...
@overload
def radd(
self: Series[int],
other: np_ndarray_anyint,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[int]: ...
@overload
def radd(
self: Series[int],
other: np_ndarray_float,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[float]: ...
@overload
def radd(
self: Series[int],
other: np_ndarray_complex,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[complex]: ...
@overload
def radd(
self: Series[float],
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float | Series[int],
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[float]: ...
@overload
def radd(
self: Series[float],
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[_T_COMPLEX]: ...
@overload
def radd(
self: Series[float],
other: np_ndarray_complex,
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[complex]: ...
@overload
def radd(
self: Series[complex],
other: (
Sequence[_T_COMPLEX]
| np_ndarray_anyint
| np_ndarray_float
| np_ndarray_complex
| Series[_T_COMPLEX]
),
level: Level | None = ...,
fill_value: float | None = ...,
axis: int = ...,
) -> Series[complex]: ...
@overload
def radd(
self,
other: Series[S1] | Scalar,
other: S1 | Series[S1],
level: Level | None = ...,
fill_value: float | None = ...,
axis: AxisIndex = ...,
) -> Series[S1]: ...
) -> Self: ...
def rdivmod(
self,
other: Series[S1] | Scalar,
Expand Down Expand Up @@ -2395,7 +2625,7 @@ class PeriodSeries(Series[Period]):
) -> Never: ...

class OffsetSeries(Series[BaseOffset]):
@overload # type: ignore[override]
@overload
def __radd__(self, other: Period) -> PeriodSeries: ...
@overload
def __radd__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mypy = "1.17.0"
pandas = "2.3.1"
pyarrow = ">=10.0.1"
pytest = ">=7.1.2"
pyright = ">=1.1.400"
pyright = ">=1.1.403"
ty = "^0.0.1a8"
pyrefly = "^0.21.0"
poethepoet = ">=0.16.5"
Expand Down
Empty file added tests/series/__init__.py
Empty file.
Empty file.
Empty file.
Loading
Loading