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 : int | Literal [ "julian" , "unix" ] | pd . Timestamp = ...,
71
71
cache : bool = ...,
72
72
) -> Timestamp : ...
73
73
@overload
@@ -81,11 +81,12 @@ 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
88
88
def to_datetime (
89
+ # TODO: Test dataframe return type
89
90
arg : Series | DictConvertible ,
90
91
errors : DateTimeErrorChoices = ...,
91
92
dayfirst : bool = ...,
@@ -95,12 +96,23 @@ def to_datetime(
95
96
exact : bool = ...,
96
97
unit : str | None = ...,
97
98
infer_datetime_format : bool = ...,
98
- origin = ...,
99
+ origin : int | Literal [ "julian" , "unix" ] | pd . Timestamp = ...,
99
100
cache : bool = ...,
100
101
) -> TimestampSeries : ...
101
102
@overload
102
103
def to_datetime (
103
- arg : list | tuple | np .ndarray | Index | ExtensionArray ,
104
+ # TODO: Test other types
105
+ arg : list [str ]
106
+ | list [int ]
107
+ | list [float ]
108
+ | list [datetime ]
109
+ | tuple [int | float | str | datetime , ...]
110
+ | npt .NDArray [np .datetime64 ]
111
+ | npt .NDArray [np .str_ ]
112
+ | npt .NDArray [np .int_ ]
113
+ | npt .NDArray [np .float_ ]
114
+ | Index
115
+ | ExtensionArray ,
104
116
errors : DateTimeErrorChoices = ...,
105
117
dayfirst : bool = ...,
106
118
yearfirst : bool = ...,
@@ -109,7 +121,6 @@ def to_datetime(
109
121
exact : bool = ...,
110
122
unit : str | None = ...,
111
123
infer_datetime_format : bool = ...,
112
- origin = ...,
124
+ origin : int | Literal [ "julian" , "unix" ] | pd . Timestamp = ...,
113
125
cache : bool = ...,
114
126
) -> DatetimeIndex : ...
115
- def to_time (arg , format = ..., infer_time_format : bool = ..., errors : str = ...): ...
0 commit comments