@@ -25,6 +25,7 @@ from typing import (
25
25
Generic ,
26
26
Literal ,
27
27
NoReturn ,
28
+ TypeVar ,
28
29
overload ,
29
30
)
30
31
@@ -181,6 +182,13 @@ from pandas.core.dtypes.dtypes import CategoricalDtype
181
182
182
183
from pandas .plotting import PlotAccessor
183
184
185
+ _scalar_timedelta : TypeAlias = timedelta | np .timedelta64 | BaseOffset | Timedelta
186
+ _vector_timedelta : TypeAlias = (
187
+ Sequence [timedelta ] | Sequence [Timedelta ] | Series [Timedelta ] | TimedeltaIndex
188
+ )
189
+ _all_timedelta : TypeAlias = _scalar_timedelta | _vector_timedelta
190
+ _stamp_and_delta = TypeVar ("_stamp_and_delta" , bound = Timestamp | Timedelta )
191
+
184
192
class _iLocIndexerSeries (_iLocIndexer , Generic [S1 ]):
185
193
# get item
186
194
@overload
@@ -1591,15 +1599,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1591
1599
) -> Series [int ]: ...
1592
1600
@overload
1593
1601
def __add__ (
1594
- self : Series [Timestamp ],
1595
- other : (
1596
- Timedelta
1597
- | Series [Timedelta ]
1598
- | TimedeltaIndex
1599
- | np .timedelta64
1600
- | timedelta
1601
- | BaseOffset
1602
- ),
1602
+ self : Series [Timestamp ], other : _all_timedelta
1603
1603
) -> Series [Timestamp ]: ...
1604
1604
@overload
1605
1605
def __add__ (self : Series [Timedelta ], other : Period ) -> PeriodSeries : ...
@@ -1686,7 +1686,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1686
1686
def __or__ (self , other : int | np_ndarray_anyint | Series [int ]) -> Series [int ]: ...
1687
1687
@overload
1688
1688
def __radd__ (
1689
- self : Series [Timestamp ], other : Series [ Timedelta ] | np . timedelta64 | timedelta
1689
+ self : Series [Timestamp ], other : _all_timedelta
1690
1690
) -> Series [Timestamp ]: ...
1691
1691
@overload
1692
1692
def __radd__ (
@@ -1707,14 +1707,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1707
1707
def __rdivmod__ (self , other : num | _ListLike | Series [S1 ]) -> Series [S1 ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
1708
1708
@overload
1709
1709
def __rfloordiv__ (
1710
- self : Series [Timedelta ],
1711
- other : (
1712
- timedelta
1713
- | Series [Timedelta ]
1714
- | np .timedelta64
1715
- | TimedeltaIndex
1716
- | Sequence [timedelta ]
1717
- ),
1710
+ self : Series [Timedelta ], other : _all_timedelta
1718
1711
) -> Series [int ]: ...
1719
1712
@overload
1720
1713
def __rfloordiv__ (self , other : num | _ListLike | Series [S1 ]) -> Series [S1 ]: ...
@@ -1737,16 +1730,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1737
1730
def __rsub__ (self , other : num | _ListLike | Series [S1 ]) -> Series : ...
1738
1731
@overload
1739
1732
def __rtruediv__ (
1740
- self : Series [Timedelta ],
1741
- other : (
1742
- timedelta
1743
- | Timedelta
1744
- | Sequence [Timedelta ]
1745
- | Series [Timedelta ]
1746
- | np .timedelta64
1747
- | TimedeltaIndex
1748
- | Sequence [timedelta ]
1749
- ),
1733
+ self : Series [Timedelta ], other : _all_timedelta
1750
1734
) -> Series [float ]: ...
1751
1735
@overload
1752
1736
def __rtruediv__ (self , other : num | _ListLike | Series [S1 ] | Path ) -> Series : ...
@@ -1764,15 +1748,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1764
1748
) -> Series [int ]: ...
1765
1749
@overload
1766
1750
def __sub__ (
1767
- self : Series [Timestamp ],
1768
- other : (
1769
- Timedelta
1770
- | Series [Timedelta ]
1771
- | TimedeltaIndex
1772
- | np .timedelta64
1773
- | timedelta
1774
- | BaseOffset
1775
- ),
1751
+ self : Series [Timestamp ], other : _all_timedelta
1776
1752
) -> Series [Timestamp ]: ...
1777
1753
@overload
1778
1754
def __sub__ (
@@ -1794,16 +1770,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1794
1770
) -> Series [Timestamp ]: ...
1795
1771
@overload
1796
1772
def __truediv__ (
1797
- self : Series [Timedelta ],
1798
- other : (
1799
- timedelta
1800
- | Timedelta
1801
- | Sequence [Timedelta ]
1802
- | Series [Timedelta ]
1803
- | np .timedelta64
1804
- | TimedeltaIndex
1805
- | Sequence [timedelta ]
1806
- ),
1773
+ self : Series [Timedelta ], other : _all_timedelta
1807
1774
) -> Series [float ]: ...
1808
1775
@overload
1809
1776
def __truediv__ (
@@ -1996,25 +1963,16 @@ class Series(IndexOpsMixin[S1], NDFrame):
1996
1963
numeric_only : _bool = ...,
1997
1964
** kwargs : Any ,
1998
1965
) -> S1 : ...
1999
- # @overload
2000
- # def mean(
2001
- # self: Series[Timestamp],
2002
- # axis: AxisIndex | None = ...,
2003
- # skipna: _bool = ...,
2004
- # level: None = ...,
2005
- # numeric_only: _bool = ...,
2006
- # **kwargs: Any,
2007
- # ) -> Timestamp: ...
2008
- # @overload
2009
- # def mean(
2010
- # self: Series[Timedelta],
2011
- # axis: AxisIndex | None = ...,
2012
- # skipna: _bool = ...,
2013
- # level: None = ...,
2014
- # numeric_only: _bool = ...,
2015
- # **kwargs: Any,
2016
- # ) -> Timedelta: ...
2017
- # @overload
1966
+ @overload
1967
+ def mean (
1968
+ self : Series [_stamp_and_delta ],
1969
+ axis : AxisIndex | None = ...,
1970
+ skipna : _bool = ...,
1971
+ level : None = ...,
1972
+ numeric_only : _bool = ...,
1973
+ ** kwargs : Any ,
1974
+ ) -> _stamp_and_delta : ...
1975
+ @overload
2018
1976
def mean (
2019
1977
self ,
2020
1978
axis : AxisIndex | None = ...,
0 commit comments