Skip to content

Commit 95d07fa

Browse files
committed
fix pyarrow round dtypes
1 parent e5d500d commit 95d07fa

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,8 @@ def round(self, decimals: int = 0, *args, **kwargs) -> Self:
10851085
DataFrame.round : Round values of a DataFrame.
10861086
Series.round : Round values of a Series.
10871087
"""
1088-
return type(self)(pc.round(self._pa_array, ndigits=decimals))
1088+
result = pc.round(self._pa_array, ndigits=decimals)
1089+
return type(self)(result.cast(self._pa_array.type))
10891090

10901091
@doc(ExtensionArray.searchsorted)
10911092
def searchsorted(

pandas/tests/extension/test_arrow.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,23 +1023,8 @@ def _get_arith_xfail_marker(self, opname, pa_dtype):
10231023
raises=pa.ArrowInvalid,
10241024
reason="Invalid decimal function: power_checked",
10251025
)
1026-
10271026
return mark
10281027

1029-
def test_round(self, data, request):
1030-
mark = None
1031-
if not (
1032-
pa.types.is_float32(data.dtype.pyarrow_dtype)
1033-
or pa.types.is_float64(data.dtype.pyarrow_dtype)
1034-
or pa.types.is_decimal(data.dtype.pyarrow_dtype)
1035-
):
1036-
pytest.mark.xfail(
1037-
reason="ArrowArray.round converts dtype to double",
1038-
)
1039-
if mark is not None:
1040-
request.node.add_marker(mark)
1041-
super().test_round(data)
1042-
10431028
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
10441029
pa_dtype = data.dtype.pyarrow_dtype
10451030

0 commit comments

Comments
 (0)