BUG: Fixes Rounding of an empty Series #63447
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed Rounding of an empty Series
PR summary
This pull request fixes a bug where calling
round()on an empty Series raises aTypeErrorinstead of returning an empty Series. The change makesSeries.round()behave consistently with other numeric operations that already handle empty Series/DataFrames gracefully.What does this change?
Series.round()so that it does not raise on an empty Series with object dtype.pd.Series().round(4)returns an empty Series instead of failing.Why is this change needed?
In the current behavior, code that works for non‑empty Series can unexpectedly fail when it encounters an empty Series and calls
round(). This is surprising because other operations likemin,cumsum, andshiftalready handle the empty case without errors. Aligninground()with these operations removes this inconsistency and avoids hard‑to‑debug edge cases in real pipelines.How was this tested?
pd.Series().round(4)and verifies it does not raise and returns an empty Series.Added section
It verifies that calling round(4) on empty Series of object, float, and int dtypes returns an identical empty Series without raising any error

REPL Tests
1. Verification of the
Fix (object dtype)
Rounding an empty object dtype Series no longer crashes; it returns an empty Series
2. Verification of Consistency (float64 dtype)
Rounding an empty float64 Series still works and matches the behavior of the fixed object version
3. No Regressions:
Rounding a normal Series with data (like 1.123 to 1.12) still works perfectly.
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.AGENTS.md.