Skip to content

Commit 88ea9cb

Browse files
committed
raise TypeError when Series dtype is object on calling Series.round()
1 parent fe60f43 commit 88ea9cb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/series.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,6 +2514,8 @@ def round(self, decimals: int = 0, *args, **kwargs) -> Series:
25142514
dtype: float64
25152515
"""
25162516
nv.validate_round(args, kwargs)
2517+
if self._mgr.dtype == "object":
2518+
raise TypeError("Expected numeric dtype, got object instead.")
25172519
new_mgr = self._mgr.round(decimals=decimals)
25182520
return self._constructor_from_mgr(new_mgr, axes=new_mgr.axes).__finalize__(
25192521
self, method="round"

0 commit comments

Comments
 (0)