Skip to content

BUG: .describe() on unsigned types is resulting in object type result #48340

Closed
@galipremsagar

Description

@galipremsagar

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

In [1]: import pandas as pd

In [2]: s= pd.Series([0, 1, 2, 3, 1, 2, 3])

In [3]: s
Out[3]: 
0    0
1    1
2    2
3    3
4    1
5    2
6    3
dtype: int64

In [4]: s.describe()
Out[4]: 
count    7.000000
mean     1.714286
std      1.112697
min      0.000000
25%      1.000000
50%      2.000000
75%      2.500000
max      3.000000
dtype: float64

In [5]: s.astype('uint64')
Out[5]: 
0    0
1    1
2    2
3    3
4    1
5    2
6    3
dtype: uint64

In [6]: s.astype('uint64').describe()
Out[6]: 
count           7
mean     1.714286
std      1.112697
min             0
25%           1.0
50%           2.0
75%           2.5
max             3
dtype: object

Issue Description

When there are unsigned integers in a series. The result of describe() call is returning a series of object dtype rather than float dtype. Not a pressing issue, but something must be going wrong that is resulting in an object dtype here.

Expected Behavior

Return a series with numeric dtypes.

Installed Versions

INSTALLED VERSIONS

commit : 224458e
python : 3.9.13.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-76-generic
Version : #86-Ubuntu SMP Fri Jan 17 17:24:28 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.5.0rc0
numpy : 1.22.4
pytz : 2022.2.1
dateutil : 2.8.2
setuptools : 65.3.0
pip : 22.2.2
Cython : 0.29.32
pytest : 7.1.2
hypothesis : 6.54.4
sphinx : 5.1.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.4.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli :
fastparquet : None
fsspec : 2022.7.1
gcsfs : None
matplotlib : None
numba : 0.55.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : 2022.7.1
scipy : 1.9.1
snappy :
sqlalchemy : 1.4.40
tables : None
tabulate : 0.8.10
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsNeeds DiscussionRequires discussion from core team before further actionRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions