@@ -4,9 +4,11 @@ from datetime import (
44 tzinfo as _tzinfo ,
55)
66from typing import (
7+ Any ,
78 Generic ,
89 Literal ,
910 TypeVar ,
11+ overload ,
1012)
1113
1214import numpy as np
@@ -17,6 +19,7 @@ from pandas import (
1719 PeriodIndex ,
1820 Timedelta ,
1921 TimedeltaIndex ,
22+ Timestamp ,
2023)
2124from pandas .core .accessor import PandasDelegate
2225from pandas .core .arrays import (
@@ -29,12 +32,13 @@ from pandas.core.series import (
2932 PeriodSeries ,
3033 Series ,
3134 TimedeltaSeries ,
32- TimestampSeries ,
3335)
36+ from typing_extensions import Never
3437
3538from pandas ._libs .tslibs import BaseOffset
3639from pandas ._libs .tslibs .offsets import DateOffset
3740from pandas ._typing import (
41+ S1 ,
3842 TimeAmbiguous ,
3943 TimeNonexistent ,
4044 TimestampConvention ,
@@ -155,14 +159,13 @@ class _DatetimeLikeOps(
155159 ],
156160): ...
157161
158- # Ideally, the rounding methods would return TimestampSeries when `Series.dt.method`
162+ # Ideally, the rounding methods would return Series[Timestamp] when `Series.dt.method`
159163# is invoked, but because of how Series.dt is hooked in and that we may not know the
160164# type of the series, we don't know which kind of series was ...ed
161165# in to the dt accessor
162166
163167_DTTimestampTimedeltaReturnType = TypeVar (
164- "_DTTimestampTimedeltaReturnType" ,
165- bound = Series | TimestampSeries | TimedeltaSeries | DatetimeIndex | TimedeltaIndex ,
168+ "_DTTimestampTimedeltaReturnType" , bound = Series | DatetimeIndex | TimedeltaIndex
166169)
167170
168171class _DatetimeRoundingMethods (Generic [_DTTimestampTimedeltaReturnType ]):
@@ -198,7 +201,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
198201 ) -> _DTTimestampTimedeltaReturnType : ...
199202
200203_DTNormalizeReturnType = TypeVar (
201- "_DTNormalizeReturnType" , TimestampSeries , DatetimeIndex
204+ "_DTNormalizeReturnType" , Series [ Timestamp ] , DatetimeIndex
202205)
203206_DTStrKindReturnType = TypeVar ("_DTStrKindReturnType" , bound = Series [str ] | Index )
204207_DTToPeriodReturnType = TypeVar (
@@ -320,7 +323,7 @@ class TimedeltaProperties(
320323 def as_unit (self , unit : TimeUnit ) -> TimedeltaSeries : ...
321324
322325_PeriodDTReturnTypes = TypeVar (
323- "_PeriodDTReturnTypes" , bound = TimestampSeries | DatetimeIndex
326+ "_PeriodDTReturnTypes" , bound = Series [ Timestamp ] | DatetimeIndex
324327)
325328_PeriodIntReturnTypes = TypeVar ("_PeriodIntReturnTypes" , bound = Series [int ] | Index [int ])
326329_PeriodStrReturnTypes = TypeVar ("_PeriodStrReturnTypes" , bound = Series [str ] | Index )
@@ -363,7 +366,7 @@ class PeriodIndexFieldOps(
363366class PeriodProperties (
364367 Properties ,
365368 _PeriodProperties [
366- TimestampSeries , Series [int ], Series [str ], DatetimeArray , PeriodArray
369+ Series [ Timestamp ] , Series [int ], Series [str ], DatetimeArray , PeriodArray
367370 ],
368371 _DatetimeFieldOps [Series [int ]],
369372 _IsLeapYearProperty ,
@@ -377,7 +380,7 @@ class CombinedDatetimelikeProperties(
377380 Series [dt .date ],
378381 Series [dt .time ],
379382 str ,
380- TimestampSeries ,
383+ Series [ Timestamp ] ,
381384 Series [str ],
382385 PeriodSeries ,
383386 ],
@@ -388,11 +391,11 @@ class TimestampProperties(
388391 DatetimeProperties [
389392 Series [int ],
390393 Series [bool ],
391- TimestampSeries ,
394+ Series [ Timestamp ] ,
392395 Series [dt .date ],
393396 Series [dt .time ],
394397 str ,
395- TimestampSeries ,
398+ Series [ Timestamp ] ,
396399 Series [str ],
397400 PeriodSeries ,
398401 ]
@@ -427,3 +430,46 @@ class TimedeltaIndexProperties(
427430 _TimedeltaPropertiesNoRounding [Index , Index ],
428431 _DatetimeRoundingMethods [TimedeltaIndex ],
429432): ...
433+
434+ class _dtDescriptor (CombinedDatetimelikeProperties , Generic [S1 ]):
435+ @overload
436+ def __get__ (self , instance : Series [Never ], owner : Any ) -> Never : ...
437+ @overload
438+ def __get__ (
439+ self , instance : Series [Timestamp ], owner : Any
440+ ) -> TimestampProperties : ...
441+ @overload
442+ def __get__ (
443+ self , instance : Series [S1 ], owner : Any
444+ ) -> CombinedDatetimelikeProperties : ...
445+ def round (
446+ self ,
447+ freq : str | BaseOffset | None ,
448+ ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
449+ nonexistent : (
450+ Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
451+ | timedelta
452+ | Timedelta
453+ ) = ...,
454+ ) -> Series [S1 ]: ...
455+ def floor (
456+ self ,
457+ freq : str | BaseOffset | None ,
458+ ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
459+ nonexistent : (
460+ Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
461+ | timedelta
462+ | Timedelta
463+ ) = ...,
464+ ) -> Series [S1 ]: ...
465+ def ceil (
466+ self ,
467+ freq : str | BaseOffset | None ,
468+ ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
469+ nonexistent : (
470+ Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
471+ | timedelta
472+ | Timedelta
473+ ) = ...,
474+ ) -> Series [S1 ]: ...
475+ def as_unit (self , unit : TimeUnit ) -> Series [S1 ]: ...
0 commit comments