18
18
from pandas .core .dtypes .generic import ABCDataFrame , ABCIndexClass , ABCSeries
19
19
from pandas .core .dtypes .missing import notna
20
20
21
+ from pandas ._typing import (
22
+ ArrayLike , IndexLike , IndexLikeOrNdarray , SeriesLike , Union )
21
23
from pandas .core import algorithms
22
24
23
25
26
+ # notations
27
+ IntFltStrDateLisTuplArrSer = Union [int , float , str , list , tuple ,
28
+ datetime , ArrayLike , SeriesLike ]
29
+
30
+
24
31
def _guess_datetime_format_for_array (arr , ** kwargs ):
25
32
# Try to guess the format based on the first non-NaN element
26
33
non_nan_elements = notna (arr ).nonzero ()[0 ]
@@ -60,7 +67,7 @@ def _maybe_cache(arg, format, cache, convert_listlike):
60
67
return cache_array
61
68
62
69
63
- def _box_as_indexlike (dt_array , tz = None , name = None ):
70
+ def _box_as_indexlike (dt_array : ArrayLike , tz = None , name = None ) -> IndexLike :
64
71
"""
65
72
Properly boxes the ndarray of datetimes to DatetimeIndex
66
73
if it is possible or to generic Index instead
@@ -86,7 +93,9 @@ def _box_as_indexlike(dt_array, tz=None, name=None):
86
93
return Index (dt_array , name = name )
87
94
88
95
89
- def _convert_and_box_cache (arg , cache_array , box , name = None ):
96
+ def _convert_and_box_cache (arg : IntFltStrDateLisTuplArrSer ,
97
+ cache_array : SeriesLike ,
98
+ box : bool , name = None ) -> IndexLikeOrNdarray :
90
99
"""
91
100
Convert array of dates with a cache and box the result
92
101
0 commit comments