Skip to content

Commit 2827ac3

Browse files
committed
BUG: 0/0 and nan/0 should equal nan
1 parent 7c89dfa commit 2827ac3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pandas/src/sparse.pyx

+8-4
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,12 @@ cdef inline float64_t __rsub(float64_t a, float64_t b):
987987

988988
cdef inline float64_t __div(float64_t a, float64_t b):
989989
if b == 0:
990-
if a >= 0:
990+
if a > 0:
991991
return INF
992-
else:
992+
elif a < 0:
993993
return -INF
994+
else:
995+
return NaN
994996
else:
995997
return a / b
996998

@@ -999,10 +1001,12 @@ cdef inline float64_t __rdiv(float64_t a, float64_t b):
9991001

10001002
cdef inline float64_t __floordiv(float64_t a, float64_t b):
10011003
if b == 0:
1002-
if a >= 0:
1004+
if a > 0:
10031005
return INF
1004-
else:
1006+
elif a < 0:
10051007
return -INF
1008+
else:
1009+
return NaN
10061010
else:
10071011
return a // b
10081012

0 commit comments

Comments
 (0)