@@ -2,6 +2,7 @@ from datetime import timedelta
2
2
from typing import (
3
3
ClassVar ,
4
4
Literal ,
5
+ NamedTuple ,
5
6
TypeVar ,
6
7
Union ,
7
8
overload ,
@@ -11,11 +12,21 @@ import numpy as np
11
12
from typing_extensions import TypeAlias
12
13
13
14
from pandas ._libs .tslibs import (
15
+ BaseOffset ,
14
16
NaTType ,
15
17
Tick ,
16
18
)
17
19
from pandas ._typing import npt
18
20
21
+ class Components (NamedTuple ):
22
+ days : int
23
+ hours : int
24
+ minutes : int
25
+ seconds : int
26
+ milliseconds : int
27
+ microseconds : int
28
+ nanoseconds : int
29
+
19
30
# This should be kept consistent with the keys in the dict timedelta_abbrevs
20
31
# in pandas/_libs/tslibs/timedeltas.pyx
21
32
TimeDeltaUnitChoices : TypeAlias = Literal [
@@ -70,18 +81,6 @@ UnitChoices: TypeAlias = Union[
70
81
71
82
_S = TypeVar ("_S" , bound = timedelta )
72
83
73
- def ints_to_pytimedelta (
74
- arr : npt .NDArray [np .int64 ], # const int64_t[:]
75
- box : bool = ...,
76
- ) -> npt .NDArray [np .object_ ]: ...
77
- def array_to_timedelta64 (
78
- values : npt .NDArray [np .object_ ],
79
- unit : str | None = ...,
80
- errors : str = ...,
81
- ) -> np .ndarray : ... # np.ndarray[m8ns]
82
- def parse_timedelta_unit (unit : str | None ) -> UnitChoices : ...
83
- def delta_to_nanoseconds (delta : np .timedelta64 | timedelta | Tick ) -> int : ...
84
-
85
84
class Timedelta (timedelta ):
86
85
min : ClassVar [Timedelta ]
87
86
max : ClassVar [Timedelta ]
@@ -106,6 +105,8 @@ class Timedelta(timedelta):
106
105
@property
107
106
def days (self ) -> int : ...
108
107
@property
108
+ def nanoseconds (self ) -> int : ...
109
+ @property
109
110
def seconds (self ) -> int : ...
110
111
@property
111
112
def microseconds (self ) -> int : ...
@@ -115,9 +116,9 @@ class Timedelta(timedelta):
115
116
@property
116
117
def asm8 (self ) -> np .timedelta64 : ...
117
118
# TODO: round/floor/ceil could return NaT?
118
- def round (self : _S , freq : str ) -> _S : ...
119
- def floor (self : _S , freq : str ) -> _S : ...
120
- def ceil (self : _S , freq : str ) -> _S : ...
119
+ def round (self : _S , freq : str | BaseOffset ) -> _S : ...
120
+ def floor (self : _S , freq : str | BaseOffset ) -> _S : ...
121
+ def ceil (self : _S , freq : str | BaseOffset ) -> _S : ...
121
122
@property
122
123
def resolution_string (self ) -> str : ...
123
124
def __add__ (self , other : timedelta ) -> Timedelta : ...
@@ -162,6 +163,5 @@ class Timedelta(timedelta):
162
163
def isoformat (self ) -> str : ...
163
164
def to_numpy (self ) -> np .timedelta64 : ...
164
165
@property
165
- def freq (self ) -> None : ...
166
- @property
167
- def is_populated (self ) -> bool : ...
166
+ def components (self ) -> Components : ...
167
+ def view (self , dtype : npt .DTypeLike = ...) -> object : ...
0 commit comments