Skip to content
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

ENH: Passing a single value to .describe(percentiles = [0.25]) returns 25th- and 50th-percentile #60550

Open
3 tasks done
ZenithClown opened this issue Dec 12, 2024 · 2 comments · May be fixed by #60557
Open
3 tasks done

Comments

@ZenithClown
Copy link

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 numpy as np
import pandas as pd

# creating a single series dataframe
frame = pd.DataFrame(np.array([1, 2, 3, 4, 5, 100]))

# getting the describe with single percentile value
frame.describe(percentiles = [0.25])

Issue Description

Using a single percentile value below 50 for percentiles for data frame describe function returns 50th percentile data by default, while the same is not reflected when the value is more than 50.

# considering the above dataframe in example
>>> frame.describe(percentiles = [0.25])
                0
count    6.000000
mean    19.166667
std     39.625329
min      1.000000
25%      2.250000
50%      3.500000
max    100.000000
>>> frame.describe(percentiles = [0.35])
                0
count    6.000000
mean    19.166667
std     39.625329
min      1.000000
35%      2.750000
50%      3.500000
max    100.000000
>>> frame.describe(percentiles = [0.51])
                0
count    6.000000
mean    19.166667
std     39.625329
min      1.000000
50%      3.500000
51%      3.550000
max    100.000000

Expected Behavior

Should return only given percentile value instead.

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.12.4
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 140 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_India.1252

pandas : 2.2.3
numpy : 2.2.0
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.1
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None

@ZenithClown ZenithClown added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 12, 2024
@rhshadrach
Copy link
Member

Thanks for the report. This goes back to ivanovmg@843aa60 and is indeed intentional.

But it is certainly not well documented, and I'm supportive of removing the behavior where we always include 0.5.

@rhshadrach rhshadrach added Enhancement and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 12, 2024
@rhshadrach rhshadrach changed the title BUG: Passing a single value to .describe(percentiles = [0.25]) returns 25th- and 50th-percentile ENH: Passing a single value to .describe(percentiles = [0.25]) returns 25th- and 50th-percentile Dec 12, 2024
@kevkle
Copy link

kevkle commented Dec 12, 2024

take

ZenithClown added a commit to ZenithClown/pandas that referenced this issue Dec 13, 2024
- fixes pandas-dev#60550
- median percentile is default when a blank list of percentiles is passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants