@@ -4,9 +4,11 @@ from datetime import (
4
4
tzinfo as _tzinfo ,
5
5
)
6
6
from typing import (
7
+ Any ,
7
8
Generic ,
8
9
Literal ,
9
10
TypeVar ,
11
+ overload ,
10
12
)
11
13
12
14
import numpy as np
@@ -17,6 +19,7 @@ from pandas import (
17
19
PeriodIndex ,
18
20
Timedelta ,
19
21
TimedeltaIndex ,
22
+ Timestamp ,
20
23
)
21
24
from pandas .core .accessor import PandasDelegate
22
25
from pandas .core .arrays import (
@@ -29,12 +32,13 @@ from pandas.core.series import (
29
32
PeriodSeries ,
30
33
Series ,
31
34
TimedeltaSeries ,
32
- TimestampSeries ,
33
35
)
36
+ from typing_extensions import Never
34
37
35
38
from pandas ._libs .tslibs import BaseOffset
36
39
from pandas ._libs .tslibs .offsets import DateOffset
37
40
from pandas ._typing import (
41
+ S1 ,
38
42
TimeAmbiguous ,
39
43
TimeNonexistent ,
40
44
TimestampConvention ,
@@ -155,14 +159,13 @@ class _DatetimeLikeOps(
155
159
],
156
160
): ...
157
161
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`
159
163
# is invoked, but because of how Series.dt is hooked in and that we may not know the
160
164
# type of the series, we don't know which kind of series was ...ed
161
165
# in to the dt accessor
162
166
163
167
_DTTimestampTimedeltaReturnType = TypeVar (
164
- "_DTTimestampTimedeltaReturnType" ,
165
- bound = Series | TimestampSeries | TimedeltaSeries | DatetimeIndex | TimedeltaIndex ,
168
+ "_DTTimestampTimedeltaReturnType" , bound = Series | DatetimeIndex | TimedeltaIndex
166
169
)
167
170
168
171
class _DatetimeRoundingMethods (Generic [_DTTimestampTimedeltaReturnType ]):
@@ -198,7 +201,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
198
201
) -> _DTTimestampTimedeltaReturnType : ...
199
202
200
203
_DTNormalizeReturnType = TypeVar (
201
- "_DTNormalizeReturnType" , TimestampSeries , DatetimeIndex
204
+ "_DTNormalizeReturnType" , Series [ Timestamp ] , DatetimeIndex
202
205
)
203
206
_DTStrKindReturnType = TypeVar ("_DTStrKindReturnType" , bound = Series [str ] | Index )
204
207
_DTToPeriodReturnType = TypeVar (
@@ -320,7 +323,7 @@ class TimedeltaProperties(
320
323
def as_unit (self , unit : TimeUnit ) -> TimedeltaSeries : ...
321
324
322
325
_PeriodDTReturnTypes = TypeVar (
323
- "_PeriodDTReturnTypes" , bound = TimestampSeries | DatetimeIndex
326
+ "_PeriodDTReturnTypes" , bound = Series [ Timestamp ] | DatetimeIndex
324
327
)
325
328
_PeriodIntReturnTypes = TypeVar ("_PeriodIntReturnTypes" , bound = Series [int ] | Index [int ])
326
329
_PeriodStrReturnTypes = TypeVar ("_PeriodStrReturnTypes" , bound = Series [str ] | Index )
@@ -363,7 +366,7 @@ class PeriodIndexFieldOps(
363
366
class PeriodProperties (
364
367
Properties ,
365
368
_PeriodProperties [
366
- TimestampSeries , Series [int ], Series [str ], DatetimeArray , PeriodArray
369
+ Series [ Timestamp ] , Series [int ], Series [str ], DatetimeArray , PeriodArray
367
370
],
368
371
_DatetimeFieldOps [Series [int ]],
369
372
_IsLeapYearProperty ,
@@ -377,7 +380,7 @@ class CombinedDatetimelikeProperties(
377
380
Series [dt .date ],
378
381
Series [dt .time ],
379
382
str ,
380
- TimestampSeries ,
383
+ Series [ Timestamp ] ,
381
384
Series [str ],
382
385
PeriodSeries ,
383
386
],
@@ -388,11 +391,11 @@ class TimestampProperties(
388
391
DatetimeProperties [
389
392
Series [int ],
390
393
Series [bool ],
391
- TimestampSeries ,
394
+ Series [ Timestamp ] ,
392
395
Series [dt .date ],
393
396
Series [dt .time ],
394
397
str ,
395
- TimestampSeries ,
398
+ Series [ Timestamp ] ,
396
399
Series [str ],
397
400
PeriodSeries ,
398
401
]
@@ -427,3 +430,46 @@ class TimedeltaIndexProperties(
427
430
_TimedeltaPropertiesNoRounding [Index , Index ],
428
431
_DatetimeRoundingMethods [TimedeltaIndex ],
429
432
): ...
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