BUG: Inconsistent data types of Series.min()
return values by python interpreters #55566
Description
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
sukjun@galaxy4:~$ /usr/bin/python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.__version__
'2.1.1'
>>> s = pd.Series([1, 2, 3, 4, 5])
>>> x = s.mean()
>>> x, type(x)
(3.0, <class 'numpy.float64'>)
>>> x = s.min()
>>> x, type(x)
(1, <class 'numpy.int64'>)
>>>
sukjun@galaxy4:~$ anaconda3/envs/myenv/bin/python3
Python 3.10.12 (main, Jul 5 2023, 18:54:27) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.__version__
'2.1.1'
>>> s = pd.Series([1, 2, 3, 4, 5])
>>> x = s.mean()
>>> x, type(x)
(3.0, <class 'numpy.float64'>)
>>> x = s.min()
>>> x, type(x)
(1, <class 'int'>)
>>>
Issue Description
As I expected, the Series.mean()
function returns a consistent data type, numpy.float64
. However, I found that Series.min()
function does not guarantee the same data type. Even though I use the same Python (3.10.12) and pandas (2.1.1) versions, the data type of the return value of the Series.min()
or Series.max()
function is returned differently depending on the Python interpreters. In some cases, it returns numpy.int64
or python's built-in integer type int
. Is there anything I missed in the environment settings?
Expected Behavior
I expect that it returns the value as a consistent data type like numpy.int64
.
Installed Versions
sukjun@galaxy4:~$ /usr/bin/python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.show_versions()
INSTALLED VERSIONS
------------------
commit : e86ed377639948c64c429059127bcf5b359ab6be
python : 3.10.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-84-generic
Version : #93-Ubuntu SMP Tue Sep 5 17:16:10 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.1
numpy : 1.26.1
pytz : 2022.1
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 : 3.0.3
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: 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
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
sukjun@galaxy4:~$ anaconda3/envs/myenv/bin/python3
Python 3.10.12 (main, Jul 5 2023, 18:54:27) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.show_versions()
/lunit/home/sukjun/anaconda3/envs/myenv/lib/python3.10/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
INSTALLED VERSIONS
------------------
commit : e86ed377639948c64c429059127bcf5b359ab6be
python : 3.10.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-84-generic
Version : #93-Ubuntu SMP Tue Sep 5 17:16:10 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.1
numpy : 1.26.1
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.0.0
pip : 23.3
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 : 1.3.5
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : 2.8.7
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None