1818from pandas .core .dtypes .generic import ABCDataFrame , ABCIndexClass , ABCSeries
1919from pandas .core .dtypes .missing import notna
2020
21+ from pandas ._typing import (
22+ ArrayLike , IndexLike , IndexLikeOrNdarray , SeriesLike , Union )
2123from pandas .core import algorithms
2224
2325
26+ # notations
27+ IntFltStrDateLisTuplArrSer = Union [int , float , str , list , tuple ,
28+ datetime , ArrayLike , SeriesLike ]
29+
30+
2431def _guess_datetime_format_for_array (arr , ** kwargs ):
2532 # Try to guess the format based on the first non-NaN element
2633 non_nan_elements = notna (arr ).nonzero ()[0 ]
@@ -60,7 +67,7 @@ def _maybe_cache(arg, format, cache, convert_listlike):
6067 return cache_array
6168
6269
63- def _box_as_indexlike (dt_array , tz = None , name = None ):
70+ def _box_as_indexlike (dt_array : ArrayLike , tz = None , name = None ) -> IndexLike :
6471 """
6572 Properly boxes the ndarray of datetimes to DatetimeIndex
6673 if it is possible or to generic Index instead
@@ -86,7 +93,9 @@ def _box_as_indexlike(dt_array, tz=None, name=None):
8693 return Index (dt_array , name = name )
8794
8895
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 :
9099 """
91100 Convert array of dates with a cache and box the result
92101
0 commit comments