Skip to content

Commit 85fdc79

Browse files
author
Noah Spies
committed
BUG: Series/DataFrame.rank() doesn't handle small floats correctly pandas-dev#6868
1 parent 0f73968 commit 85fdc79

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pandas/algos.pyx

+6-4
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,17 @@ cdef _take_2d_object(ndarray[object, ndim=2] values,
133133
return result
134134

135135

136-
cdef inline float64_are_diff(float64_t left, float64_t right):
137-
if right == np.inf or right == -np.inf:
136+
cdef inline bint float64_are_diff(float64_t left, float64_t right):
137+
cdef double abs_diff, allowed
138+
if right == MAXfloat64 or right == -MAXfloat64:
138139
if left == right:
139140
return False
140141
else:
141142
return True
142143
else:
143-
return fabs(left - right) > REL_TOL * fabs(right)
144-
144+
abs_diff = fabs(left - right)
145+
allowed = REL_TOL * fabs(right)
146+
return abs_diff > allowed
145147

146148
def rank_1d_float64(object in_arr, ties_method='average', ascending=True,
147149
na_option='keep', pct=False):

0 commit comments

Comments
 (0)