Skip to content

BUG: in agg function #58980

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
3 tasks done
NarottamSharma opened this issue Jun 12, 2024 · 1 comment
Closed
3 tasks done

BUG: in agg function #58980

NarottamSharma opened this issue Jun 12, 2024 · 1 comment
Labels
Apply Apply, Aggregate, Transform, Map Bug Groupby

Comments

@NarottamSharma
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 pandas as pd
import numpy as np
data = {
    'Name': ['Alice', 'Bob', 'Charlie', 'Alice', 'Bob', 'Charlie'],
    'Subject': ['Math', 'Math', 'Math', 'Science', 'Science', 'Science'],
    'Score': [85, 78, 92, 89, 76, 95]
}

df = pd.DataFrame(data)
df.groupby('Subject').agg(['min','max','mean'])

Issue Description

output:-
agg function failed [how->mean,dtype->object]

In previous version the output is coming now not coming due to object dtype, and also unable to change it to numeric_only = True

Expected Behavior

It should show a output in the form of for numeric value

Installed Versions

INSTALLED VERSIONS

commit : a671b5a
python : 3.11.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22631
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_India.1252

pandas : 2.1.4
numpy : 1.26.4
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.3.1
Cython : None
pytest : 7.4.0
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.20.0
pandas_datareader : None
bs4 : 4.12.2
bottleneck : 1.3.7
dataframe-api-compat: None
fastparquet : None
fsspec : 2023.10.0
gcsfs : None
matplotlib : 3.8.0
numba : 0.59.0
numexpr : 2.8.7
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 14.0.2
pyreadstat : None
pyxlsb : None
s3fs : 2023.10.0
scipy : 1.11.4
sqlalchemy : 2.0.25
tables : 3.9.2
tabulate : 0.9.0
xarray : 2023.6.0
xlrd : None
zstandard : 0.19.0
tzdata : 2023.3
qtpy : 2.4.1
pyqt5 : None

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

Thanks for the report - this was changed in #41475 and announced as part of the 2.0 release here: https://pandas.pydata.org/docs/dev/whatsnew/v2.0.0.html#removal-of-prior-version-deprecations-changes

pandas will attempt to operate on any columns you provide. If you do not want to operate on all columns, select the ones you do want to operate on.

df.groupby('Subject')[["Score"]].agg(['min','max','mean'])

@rhshadrach rhshadrach added Groupby Apply Apply, Aggregate, Transform, Map and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Bug Groupby
Projects
None yet
Development

No branches or pull requests

2 participants