File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 2424 lib ,
2525)
2626from pandas ._libs .missing import NA
27- from pandas ._libs .tslibs .timestamps import Timestamp
2827from pandas ._typing import (
2928 AnyArrayLike ,
3029 ArrayLike ,
6059)
6160from pandas .core .dtypes .concat import concat_compat
6261from pandas .core .dtypes .dtypes import (
63- ArrowDtype ,
6462 BaseMaskedDtype ,
6563 CategoricalDtype ,
6664 ExtensionDtype ,
@@ -1693,14 +1691,6 @@ def map_array(
16931691 if na_action == "ignore" :
16941692 mapper = mapper [mapper .index .notna ()]
16951693
1696- if isinstance (arr .dtype , ArrowDtype ) and arr .dtype .name .startswith ("timestamp" ):
1697- try :
1698- # Convert elements to pandas.Timestamp (or datetime64[ns])
1699- arr = arr .astype ("datetime64[ns]" )
1700- except Exception :
1701- # fallback: safe, slow path
1702- arr = np .array ([Timestamp (x .as_py ()) for x in arr ])
1703-
17041694 # Since values were input this means we came from either
17051695 # a dict or a series and mapper should be an index
17061696 indexer = mapper .index .get_indexer (arr )
Original file line number Diff line number Diff line change @@ -1483,6 +1483,14 @@ def to_numpy(
14831483 def map (self , mapper , na_action : Literal ["ignore" ] | None = None ):
14841484 if is_numeric_dtype (self .dtype ):
14851485 return map_array (self .to_numpy (), mapper , na_action = na_action )
1486+ if self .dtype .name .startswith ("timestamp" ):
1487+ try :
1488+ # Convert elements to pandas.Timestamp (or datetime64[ns])
1489+ self = self .astype ("datetime64[ns]" )
1490+ except Exception :
1491+ # fallback: safe, slow path
1492+ self = np .array ([Timestamp (x .as_py ()) for x in self ])
1493+ return map_array (self , mapper , na_action = na_action )
14861494 else :
14871495 return super ().map (mapper , na_action )
14881496
You can’t perform that action at this time.
0 commit comments