Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(3, 4))
df.iloc[0, 0] = np.inf
df
0 1 2 3
0 inf -0.614812 -0.316211 -0.049311
1 1.254238 -0.082490 -0.199442 -0.373851
2 -1.440219 0.723572 0.028726 -0.904849
df.rank()
0 1 2 3
0 NaN 1.0 1.0 3.0
1 2.0 2.0 2.0 2.0
2 1.0 3.0 3.0 1.0
df.iloc[0, 0] = -np.inf
df.rank()
0 1 2 3
0 1.0 1.0 1.0 3.0
1 3.0 2.0 2.0 2.0
2 2.0 3.0 3.0 1.0
Problem description
as you can see, -inf and inf get different results.
Expected Output
Output of pd.show_versions()
INSTALLED VERSIONS
commit : 3e89b4c
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-118-generic
Version : #119-Ubuntu SMP Tue Sep 8 12:30:01 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.0
numpy : 1.18.5
pytz : 2020.5
dateutil : 2.8.1
pip : 20.3.3
setuptools : 51.0.0.post20201207
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.2
html5lib : None
pymysql : 0.10.1
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: 0.9.0
bs4 : None
bottleneck : None
fsspec : 0.8.4
fastparquet : None
gcsfs : None
matplotlib : 3.3.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.52.0