Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ Numeric
- Bug in :meth:`Series.__floordiv__` and :meth:`Series.__truediv__` for :class:`ArrowDtype` with integral dtypes raising for large divisors (:issue:`56706`)
- Bug in :meth:`Series.__floordiv__` for :class:`ArrowDtype` with integral dtypes raising for large values (:issue:`56645`)
- Bug in :meth:`Series.pow` not filling missing values correctly (:issue:`55512`)
- Bug in :meth:`Series.round` raising for nullable boolean dtype (:issue:`55936`)

Conversion
^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ def round(self, decimals: int = 0, *args, **kwargs):
DataFrame.round : Round values of a DataFrame.
Series.round : Round values of a Series.
"""
if self.dtype.kind == "b":
return self
nv.validate_round(args, kwargs)
values = np.round(self._data, decimals=decimals, **kwargs)

Expand Down
6 changes: 2 additions & 4 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2789,13 +2789,11 @@ def round(self, decimals: int = 0, *args, **kwargs) -> Series:
dtype: float64
"""
nv.validate_round(args, kwargs)
result = self._values.round(decimals)
result = self._constructor(result, index=self.index, copy=False).__finalize__(
new_mgr = self._mgr.round(decimals=decimals, using_cow=using_copy_on_write())
return self._constructor_from_mgr(new_mgr, axes=new_mgr.axes).__finalize__(
self, method="round"
)

return result

@overload
def quantile(
self, q: float = ..., interpolation: QuantileInterpolation = ...
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/series/methods/test_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,12 @@ def test_round_nat(self, method, freq, unit):
round_method = getattr(ser.dt, method)
result = round_method(freq)
tm.assert_series_equal(result, expected)

def test_round_ea_boolean(self):
# GH#55936
ser = Series([True, False], dtype="boolean")
expected = ser.copy()
result = ser.round(2)
tm.assert_series_equal(result, expected)
result.iloc[0] = False
tm.assert_series_equal(ser, expected)