BUG: groupby().agg( ) with min/max on Int64 leads to incorrect results #41743
Labels
Bug
Groupby
NA - MaskedArrays
Related to pd.NA and nullable extension arrays
Reduction Operations
sum, mean, min, max, etc.
Milestone
[x ] I have checked that this issue has not already been reported.
[x ] 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.
Code Sample, a copy-pastable example
Problem description
The above code will output
1618556707013635840
as the minimum which is incorrect.Expected Output
Minimum should be
1618556707013635762
. I suspect there is a cast happening somewhere during the aggregation. If we keep thets
column atint64
(i.e. use the non-nullable type) the result is as expected.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2cb9652
python : 3.9.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.11.7-200.fc33.x86_64
Version : #1 SMP Wed Mar 17 18:55:20 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL :
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.4
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.1
pip : 21.1.1
setuptools : 56.0.0
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 : 7.24.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
Potentially related issues
The issues below seem related, but from what I can see are slightly different:
dtype
of the output column should be. For themin
andmax
I would expect to get the samedtype
as in the input column.The text was updated successfully, but these errors were encountered: