Skip to content

Commit e15cf72

Browse files
committed
Revise the doc, refactor test case and remove the incorrect if condition.
Signed-off-by: HE, Tao <[email protected]>
1 parent 81e87bc commit e15cf72

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

doc/source/whatsnew/v0.25.0.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ Bug Fixes
122122
~~~~~~~~~
123123
- Bug in :func:`to_datetime` which would raise an (incorrect) ``ValueError`` when called with a date far into the future and the ``format`` argument specified instead of raising ``OutOfBoundsDatetime`` (:issue:`23830`)
124124
- Bug in an error message in :meth:`DataFrame.plot`. Improved the error message if non-numerics are passed to :meth:`DataFrame.plot` (:issue:`25481`)
125-
- Fixed bug in :meth:`Series.divmod` and :meth:`Series.rdivmod` (:issue:`25557`)
126-
-
125+
- Bug in :meth:`Series.divmod` and :meth:`Series.rdivmod` which would raise an (incorrect) ``ValueError`` rather than return a pair of :class:`Series` object as result (:issue:`25557`)
127126

128127
Categorical
129128
^^^^^^^^^^^

pandas/core/ops.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1661,8 +1661,7 @@ def _construct_result(left, result, index, name, dtype=None):
16611661
"""
16621662
out = left._constructor(result, index=index, dtype=dtype)
16631663
out.__finalize__(left)
1664-
if name is None:
1665-
out.name = name
1664+
out.name = name
16661665
return out
16671666

16681667

pandas/tests/series/test_operators.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -746,15 +746,15 @@ def test_divmod(self):
746746
a = Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
747747
b = Series([2, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
748748

749-
r1 = divmod(a, b)
750-
r2 = a.divmod(b)
751-
assert_series_equal(r1[0], r2[0])
752-
assert_series_equal(r1[1], r2[1])
753-
754-
r3 = divmod(b, a)
755-
r4 = a.rdivmod(b)
756-
assert_series_equal(r3[0], r4[0])
757-
assert_series_equal(r3[1], r4[1])
749+
result = a.divmod(b)
750+
expected = divmod(a, b)
751+
assert_series_equal(result[0], expected[0])
752+
assert_series_equal(result[1], expected[1])
753+
754+
result = a.rdivmod(b)
755+
expected = divmod(b, a)
756+
assert_series_equal(result[0], expected[0])
757+
assert_series_equal(result[1], expected[1])
758758

759759

760760
class TestSeriesUnaryOps(object):

0 commit comments

Comments
 (0)