Skip to content

Commit c9f47ff

Browse files
committed
return with proper typing
1 parent 25e57c3 commit c9f47ff

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,10 +1481,20 @@ def to_numpy(
14811481
return result
14821482

14831483
def map(self, mapper, na_action: Literal["ignore"] | None = None):
1484-
if is_numeric_dtype(self.dtype) or self.dtype.kind in "mM":
1484+
from pandas import Series
1485+
1486+
pa_type = self._pa_array.type
1487+
1488+
if pa.types.is_timestamp(pa_type) or pa.types.is_duration(pa_type):
1489+
datelike = self._maybe_convert_datelike_array()
1490+
temp = Series(datelike, dtype=datelike.dtype)
1491+
mapped = temp.map(mapper, na_action=na_action)
1492+
return mapped._values
1493+
1494+
if is_numeric_dtype(self.dtype):
14851495
return map_array(self.to_numpy(), mapper, na_action=na_action)
1486-
else:
1487-
return super().map(mapper, na_action)
1496+
1497+
return super().map(mapper, na_action=na_action)
14881498

14891499
@doc(ExtensionArray.duplicated)
14901500
def duplicated(

0 commit comments

Comments
 (0)