pydata/pandas — pull request #8379 by behzadnouri (2014-09-24 01:40:16+00:00)
Title: ranking floats cannot be done with tolerance

closes https://github.com/pydata/pandas/issues/8365

using tolerance in ranking floats can result in inconsistent behavior; currently on master:

>>> pd.Series([1001, 1001.0002]).rank()
0 1
1 2
dtype: float64
>>> pd.Series([1001, 1001.0001, 1001.0002]).rank()
0 2
1 2
2 2
dtype: float64

so, in effect `1001 == 1001.0002` if one takes small steps in between.

on branch:

>>> pd.Series([1001, 1001.0002]).rank()
0 1
1 2
dtype: float64
>>> pd.Series([1001, 1001.0001, 1001.0002]).rank()
0 1
1 2
2 3
dtype: float64

original issue(https://github.com/pydata/pandas/issues/8365):

>>> from scipy import stats
>>> ts = pd.Series([1000.000669 , 1000.000041 , 1000.000059 , 1000.000063 , 1000.000121 , 1000.000104 , 1000.000040 , 1000.000062 , 1000.000095 , 1000.000091 , 1000.000050 , 1000.000074 , 1000.000063 , 1000.000076 , 1000.000083 , 1000.000061 , 1000.000030 , 1000.000069 , 1000.000090 , 1000.000116 , 1000.000058 , 1000.000074 , 1000.000035 , 1000.000084 , 1000.000067 , 1000.000072 , 1000.000105 , 1000.000091 , 1000.000077 , 1000.000040 , 1000.000108 , 1000.000117 , 1000.000114 , 1000.000117 , 1000.000099 , 1000.000039 , 1000.000046 , 1000.000105 , 1000.000057])
>>> np.all(ts.rank() == stats.rankdata(ts))
True