Skip to content

Commit 2fa5d5d

Browse files
committed
REF: use _cast_pointwise_result in map
1 parent 188b2da commit 2fa5d5d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,8 @@ def to_numpy(
15941594

15951595
def map(self, mapper, na_action: Literal["ignore"] | None = None):
15961596
if is_numeric_dtype(self.dtype):
1597-
return map_array(self.to_numpy(), mapper, na_action=na_action)
1597+
result = map_array(self.to_numpy(), mapper, na_action=na_action)
1598+
return self._cast_pointwise_result(result)
15981599
else:
15991600
return super().map(mapper, na_action)
16001601

pandas/core/arrays/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,8 @@ def map(self, mapper, na_action: Literal["ignore"] | None = None):
25302530
If the function returns a tuple with more than one element
25312531
a MultiIndex will be returned.
25322532
"""
2533-
return map_array(self, mapper, na_action=na_action)
2533+
results = map_array(self, mapper, na_action=na_action)
2534+
return self._cast_pointwise_result(results)
25342535

25352536
# ------------------------------------------------------------------------
25362537
# GroupBy Methods

pandas/core/arrays/masked.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,8 @@ def max(self, *, skipna: bool = True, axis: AxisInt | None = 0, **kwargs):
13951395
return self._wrap_reduction_result("max", result, skipna=skipna, axis=axis)
13961396

13971397
def map(self, mapper, na_action: Literal["ignore"] | None = None):
1398-
return map_array(self.to_numpy(), mapper, na_action=na_action)
1398+
result = map_array(self.to_numpy(), mapper, na_action=na_action)
1399+
return self._cast_pointwise_result(result)
13991400

14001401
@overload
14011402
def any(

0 commit comments

Comments
 (0)