BUG: Series.rank(pct=True, method='dense').max() != 1 for repeated values #18296
Labels
Bug
Duplicate Report
Duplicate issue or pull request
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Code Sample, a copy-pastable example if possible
Output:
Problem description
If you chose both the
pct=True
andmethod='dense'
options ofSeries.rank
, you don't get the expected maximum percentile of 1 if there are repeated values in theSeries
. This is because the function (e.g.,rank_1d_float64()
) always divides by the total number of elements in theSeries
. But in the case of thedense
method, we should divide by the maximum rank value.I'm working on a PR now.
Expected Output
I would expect the values of
Rank_Pct
andRank_Pct_Manual
to be the same, and that the maximum of both should be 1.Output of
pd.show_versions()
commit: None
python: 3.6.3.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.21.0
pytest: 3.2.3
pip: 9.0.1
setuptools: 36.3.0
Cython: None
numpy: 1.13.3
scipy: 0.19.1
pyarrow: 0.7.1
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: 1.1.15
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: