Skip to content

Commit 49e130c

Browse files
committed
Updated condition
1 parent 4445ecd commit 49e130c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,14 +1483,8 @@ 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)
1486+
elif self.dtype == "timestamp[ns][pyarrow]":
1487+
return map_array(self.to_numpy(dtype=object), mapper, na_action=na_action)
14941488
else:
14951489
return super().map(mapper, na_action)
14961490

0 commit comments

Comments
 (0)