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 24
24
lib ,
25
25
)
26
26
from pandas ._libs .missing import NA
27
- from pandas ._libs .tslibs .timestamps import Timestamp
28
27
from pandas ._typing import (
29
28
AnyArrayLike ,
30
29
ArrayLike ,
60
59
)
61
60
from pandas .core .dtypes .concat import concat_compat
62
61
from pandas .core .dtypes .dtypes import (
63
- ArrowDtype ,
64
62
BaseMaskedDtype ,
65
63
CategoricalDtype ,
66
64
ExtensionDtype ,
@@ -1693,14 +1691,6 @@ def map_array(
1693
1691
if na_action == "ignore" :
1694
1692
mapper = mapper [mapper .index .notna ()]
1695
1693
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
-
1704
1694
# Since values were input this means we came from either
1705
1695
# a dict or a series and mapper should be an index
1706
1696
indexer = mapper .index .get_indexer (arr )
Original file line number Diff line number Diff line change @@ -1483,6 +1483,14 @@ def to_numpy(
1483
1483
def map (self , mapper , na_action : Literal ["ignore" ] | None = None ):
1484
1484
if is_numeric_dtype (self .dtype ):
1485
1485
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 )
1486
1494
else :
1487
1495
return super ().map (mapper , na_action )
1488
1496
You can’t perform that action at this time.
0 commit comments