You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the Python built-in function min() to find the smallest item in each column of my dataframe. The issue I am facing is that whenever the first value in the column b is np.nan the result is that np.nan is the smallest value when it should be -574.0. The unexpected behavior happens when I change the order of the rows, like df_2 and it returns the correct -574.0 value.
Expected Behavior
I would expect that the output for the min() value in column b is -574.0 regardless of whether the first value in the column is np.nan.
If I replace the min() for np.nanmin() I get the expected value in both cases
There seems to be a problem with the inbuilt min function itself. I have seen that, internally it is taking the column values and calling the inbuilt python min function. I would like to work on this issue if anyone is willing to guide me.
Thanks
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Hello,
I am using the Python built-in function
min()
to find the smallest item in each column of my dataframe. The issue I am facing is that whenever the first value in the column b isnp.nan
the result is thatnp.nan
is the smallest value when it should be-574.0
. The unexpected behavior happens when I change the order of the rows, likedf_2
and it returns the correct-574.0
value.Expected Behavior
I would expect that the output for the
min()
value in column b is-574.0
regardless of whether the first value in the column isnp.nan
.If I replace the
min()
fornp.nanmin()
I get the expected value in both casesOutput:
Output:
Installed Versions
INSTALLED VERSIONS
commit : 0f43794
python : 3.10.6.final.0
python-bits : 64
OS : Linux
OS-release : 5.19.0-46-generic
Version : #47~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 21 15:35:31 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : pt_BR.UTF-8
pandas : 2.0.3
numpy : 1.25.1
pytz : 2023.3
dateutil : 2.8.2
setuptools : 59.6.0
pip : 22.0.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: