Reproducible Example
import pandas as pd
import numpy as np
data = {
'integers': np.linspace(-10_000_000, 10_000_000, 100),
'small_integers': np.linspace(1, 200, 100),
}
df = pd.DataFrame(data)
df['integers'] = df['integers'].astype('int64')
df['small_integers'] = df['small_integers'].astype('uint8')
print(df.dtypes)
# integers int64
# small_integers uint8
# dtype: object
print(df.describe())
# integers small_integers
# count 1.000000e+02 100.000000
# mean 0.000000e+00 100.010000
# std 5.860907e+06 58.040302
# min -1.000000e+07 1.000000
# 25% -4.999999e+06 50.500000
# 50% 0.000000e+00 100.000000
# 75% 4.999999e+06 149.500000
# max 1.000000e+07 200.000000
print(df.agg(['min', 'max']))
# integers small_integers
# min -10000000 1
# max 10000000 -56
Issue Description
describe
works ok, but agg
works wrong with uint8 (may be other uint too)
Expected Behavior
print(df.agg(['min', 'max']))
# integers small_integers
# min -10000000 1
# max 10000000 200
Installed Versions
INSTALLED VERSIONS
------------------
commit : 66e3805b8cabe977f40c05259cc3fcf7ead5687d
python : 3.7.10.final.0
python-bits : 64
OS : Linux
OS-release : 4.14.304-226.531.amzn2.x86_64
Version : #1 SMP Wed Feb 1 21:34:38 UTC 2023
machine : x86_64
processor :
byteorder : little
LC_ALL : C.UTF-8
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.5
numpy : 1.21.6
pytz : 2019.3
dateutil : 2.8.2
pip : 23.0
setuptools : 59.3.0
Cython : 0.29.15
pytest : 5.3.5
hypothesis : 5.5.4
sphinx : 2.4.0
blosc : None
feather : None
xlsxwriter : 1.2.7
lxml.etree : 4.9.2
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 7.34.0
pandas_datareader: None
bs4 : 4.8.2
bottleneck : 1.3.2
fsspec : 2023.1.0
fastparquet : None
gcsfs : None
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : 11.0.0
pyxlsb : None
s3fs : 0.4.2
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : 3.6.1
tabulate : 0.9.0
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.56.4
Comment From: jayendra-patil33
The bug is not reproducible on the main branch.
Comment From: topper-123
I see the expected behavior on the main branch as well, so this looks fixed.
From your install version, I see that you use pandas v1.3 which isn't supported any more, so this may have been fixed quite a while ago. Can you please always check if the reported bug is present in the latest release, before filing an issue.
I'm closing this issue.