Skip to content

Commit 0568ed7

Browse files
committed
Merge pull request pandas-dev#7786 from jreback/div
BUG: Bug in Series 0-division with a float and integer operand dtypes (GH7785)
2 parents 30764bd + 337bae4 commit 0568ed7

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

doc/source/v0.15.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ There are no experimental changes in 0.15.0
184184

185185
Bug Fixes
186186
~~~~~~~~~
187-
187+
- Bug in Series 0-division with a float and integer operand dtypes (:issue:`7785`)
188188
- Bug in ``Series.astype("unicode")`` not calling ``unicode`` on the values correctly (:issue:`7758`)
189189
- Bug in ``DataFrame.as_matrix()`` with mixed ``datetime64[ns]`` and ``timedelta64[ns]`` dtypes (:issue:`7778`)
190190

pandas/core/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ def _fill_zeros(result, x, y, name, fill):
13281328
# correctly
13291329
# GH 6178
13301330
if np.isinf(fill):
1331-
np.putmask(result,signs<0 & mask, -fill)
1331+
np.putmask(result,(signs<0) & mask, -fill)
13321332

13331333
result = result.reshape(shape)
13341334

pandas/tests/test_series.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -2362,6 +2362,17 @@ def test_div(self):
23622362
expected = Series([np.nan,np.inf,-np.inf])
23632363
assert_series_equal(result, expected)
23642364

2365+
# float/integer issue
2366+
# GH 7785
2367+
p = DataFrame({'first': (1,0), 'second': (-0.01,-0.02)})
2368+
expected = Series([-0.01,-np.inf])
2369+
2370+
result = p['second'].div(p['first'])
2371+
assert_series_equal(result, expected)
2372+
2373+
result = p['second'] / p['first']
2374+
assert_series_equal(result, expected)
2375+
23652376
def test_operators(self):
23662377

23672378
def _check_op(series, other, op, pos_only=False):
@@ -4865,12 +4876,12 @@ def test_astype_unicode(self):
48654876
test_series = [
48664877
Series([digits * 10, tm.rands(63), tm.rands(64), tm.rands(1000)]),
48674878
Series([u"データーサイエンス、お前はもう死んでいる"]),
4868-
4879+
48694880
]
4870-
4881+
48714882
former_encoding = None
48724883
if not compat.PY3:
4873-
# in python we can force the default encoding
4884+
# in python we can force the default encoding
48744885
# for this test
48754886
former_encoding = sys.getdefaultencoding()
48764887
reload(sys)

0 commit comments

Comments
 (0)