Skip to content

BUG: RuntimeWarning on describe for a single element Series of dtype Float64 #52515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
arnaudlegout opened this issue Apr 7, 2023 · 0 comments · Fixed by #52518
Closed
2 of 3 tasks

BUG: RuntimeWarning on describe for a single element Series of dtype Float64 #52515

arnaudlegout opened this issue Apr 7, 2023 · 0 comments · Fixed by #52518
Labels
Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays Reduction Operations sum, mean, min, max, etc. Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@arnaudlegout
Copy link
Contributor

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

import pandas as pd
import numpy as np

# here we have a regular behavior for the dtype np.float64
>>> s = pd.Series([0.0], index=[0], dtype=np.float64)
>>> s.describe()
count    1.0
mean     0.0
std      NaN
min      0.0
25%      0.0
50%      0.0
75%      0.0
max      0.0
dtype: float64

# with the dtype Float64, the result is still correct, but there is a strange warning raised
>>> s = pd.Series([0.0], index=[0], dtype='Float64')
>>> s.describe()
C:\Users\alegout\AppData\Local\miniconda3\envs\py3.11\Lib\site-packages\numpy\core\_methods.py:265: RuntimeWarning: Degrees of freedom <= 0 for slice
  ret = _var(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
C:\Users\alegout\AppData\Local\miniconda3\envs\py3.11\Lib\site-packages\numpy\core\_methods.py:257: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
count     1.0
mean      0.0
std      <NA>
min       0.0
25%       0.0
50%       0.0
75%       0.0
max       0.0
dtype: Float64

Issue Description

computing a describe on a single element Series should work without any working. When the dtype is Float64, there is a RuntimeWarning that is not raised with the dtype np.float64.

Expected Behavior

I expect no warning with the extended dtype

Installed Versions

INSTALLED VERSIONS

commit : 478d340
python : 3.11.2.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : fr_FR.cp1252

pandas : 2.0.0
numpy : 1.23.5
pytz : 2022.7
dateutil : 2.8.2
setuptools : 65.6.3
pip : 23.0.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.10.0
pandas_datareader: None
bs4 : 4.12.0
bottleneck : 1.3.5
brotli :
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.7.1
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.0
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.8.10
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : 2.2.0
pyqt5 : None

@arnaudlegout arnaudlegout added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 7, 2023
@phofl phofl added NA - MaskedArrays Related to pd.NA and nullable extension arrays Reduction Operations sum, mean, min, max, etc. Regression Functionality that used to work in a prior pandas version and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 7, 2023
@phofl phofl added this to the 2.0.1 milestone Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays Reduction Operations sum, mean, min, max, etc. Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants