1
1
from datetime import datetime
2
2
from typing import (
3
3
Literal ,
4
+ Sequence ,
4
5
TypedDict ,
5
6
Union ,
6
7
overload ,
7
8
)
8
9
9
10
import numpy as np
11
+ import pandas as pd
10
12
from pandas import (
11
13
Index ,
12
14
Timestamp ,
@@ -25,6 +27,7 @@ from pandas._typing import (
25
27
AnyArrayLike ,
26
28
DateTimeErrorChoices ,
27
29
IgnoreRaise ,
30
+ npt ,
28
31
)
29
32
30
33
ArrayConvertible : TypeAlias = Union [list , tuple , AnyArrayLike ]
@@ -53,9 +56,6 @@ class FulldatetimeDict(YearMonthDayDict, total=False):
53
56
54
57
DictConvertible : TypeAlias = Union [FulldatetimeDict , DataFrame ]
55
58
56
- def should_cache (
57
- arg : ArrayConvertible , unique_share : float = ..., check_count : int | None = ...
58
- ) -> bool : ...
59
59
@overload
60
60
def to_datetime (
61
61
arg : DatetimeScalar ,
@@ -67,7 +67,7 @@ def to_datetime(
67
67
exact : bool = ...,
68
68
unit : str | None = ...,
69
69
infer_datetime_format : bool = ...,
70
- origin = ...,
70
+ origin : Literal [ "julian" , "unix" ] | pd . Timestamp = ...,
71
71
cache : bool = ...,
72
72
) -> Timestamp : ...
73
73
@overload
@@ -81,7 +81,7 @@ def to_datetime(
81
81
exact : bool = ...,
82
82
unit : str | None = ...,
83
83
infer_datetime_format : bool = ...,
84
- origin = ...,
84
+ origin : Literal [ "julian" , "unix" ] | pd . Timestamp = ...,
85
85
cache : bool = ...,
86
86
) -> Timestamp | NaTType : ...
87
87
@overload
@@ -95,12 +95,23 @@ def to_datetime(
95
95
exact : bool = ...,
96
96
unit : str | None = ...,
97
97
infer_datetime_format : bool = ...,
98
- origin = ...,
98
+ origin : Literal [ "julian" , "unix" ] | pd . Timestamp = ...,
99
99
cache : bool = ...,
100
100
) -> TimestampSeries : ...
101
101
@overload
102
102
def to_datetime (
103
- arg : list | tuple | np .ndarray | Index | ExtensionArray ,
103
+ # TODO: Test other types
104
+ # TODO: Test dataframe return type
105
+ arg : Sequence [int | float | datetime ]
106
+ | list [int | float | str | datetime ]
107
+ | tuple [int | float | str | datetime , ...]
108
+ | npt .NDArray [np .datetime64 ]
109
+ | npt .NDArray [np .str_ ]
110
+ | npt .NDArray [np .int_ ]
111
+ | npt .NDArray [np .float_ ]
112
+ | Index
113
+ | ExtensionArray
114
+ | pd .DataFrame ,
104
115
errors : DateTimeErrorChoices = ...,
105
116
dayfirst : bool = ...,
106
117
yearfirst : bool = ...,
@@ -109,7 +120,6 @@ def to_datetime(
109
120
exact : bool = ...,
110
121
unit : str | None = ...,
111
122
infer_datetime_format : bool = ...,
112
- origin = ...,
123
+ origin : Literal [ "julian" , "unix" ] | pd . Timestamp = ...,
113
124
cache : bool = ...,
114
125
) -> DatetimeIndex : ...
115
- def to_time (arg , format = ..., infer_time_format : bool = ..., errors : str = ...): ...
0 commit comments