Skip to content

Commit e0e89b9

Browse files
committed
fix and and tests for divmod
1 parent 969f342 commit e0e89b9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pandas/core/indexes/base.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4192,8 +4192,7 @@ def dispatch_missing(op, left, right, result):
41924192
result = missing.fill_zeros(result, left, right,
41934193
opstr, np.nan)
41944194
elif op is divmod:
4195-
res0 = missing.fill_zeros(result[0], left, right,
4196-
opstr, np.nan)
4195+
res0 = missing.mask_zero_div_zero(left, right, result[0])
41974196
res1 = missing.fill_zeros(result[1], left, right,
41984197
opstr, np.nan)
41994198
result = (res0, res1)

pandas/tests/indexes/test_numeric.py

+13
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ def test_mod_zero(self, zero):
197197
ser_compat = Series(idx).astype('i8') % np.array(zero).astype('i8')
198198
tm.assert_series_equal(ser_compat, Series(result))
199199

200+
@pytest.mark.parametrize('zero', zeros)
201+
def test_divmod_zero(self, zero):
202+
idx = self.create_index()
203+
204+
exleft = Index([np.nan, np.inf, np.inf, np.inf, np.inf],
205+
dtype=np.float64)
206+
exright = Index([np.nan, np.nan, np.nan, np.nan, np.nan],
207+
dtype=np.float64)
208+
209+
result = divmod(idx, zero)
210+
tm.assert_index_equal(result[0], exleft)
211+
tm.assert_index_equal(result[1], exright)
212+
200213
def test_explicit_conversions(self):
201214

202215
# GH 8608

0 commit comments

Comments
 (0)