-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: pd.Series.groupby
issues FutureWarning
#60831
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
Comments
Thanks for the report. It appears to me we should only be doing this check when |
take |
Hi @rhshadrach, |
This is because that deprecation has been enforced on the main branch for the 3.0 release. However we will be releasing 2.3 prior to this, and the warning still shows on the 2.3.x branch. This is where the fix should go. |
This can be closed right, as the pr is merged |
I originally thought that the implementation on main might be even more dangerous: pandas/pandas/core/groupby/grouper.py Line 853 in d72f165
I have experimented a bit to get a bug (by making a series containing series, etc.), but I could never get pandas/pandas/core/groupby/grouper.py Line 857 in d72f165
True . Therefore, it seems to be fine. I was intentionally trying to break it anyway, and it would probably never happen naturally.
But the point I was trying to make might still be valid, just from a "cleaner code" standpoint: I believe an assumption is made in line 853 (that the I would gladly add this quick check, if wanted. But as I could not trigger a bug, I don't longer think this is strictly necessary. So in short: Yes, I believe this issue can be closed. Thanks @sanggon6107 for the fast fix! |
Thanks @Anurag-Varma - agreed. Closing. |
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
Issue Description
The warning comes from this line:
pandas/pandas/core/groupby/grouper.py
Line 1015 in 0691c5c
Here,
gpr.name
is2
, which results in the warning. If the index consists of integers, this meansobj[gpr.name]
will actually return the line (which then fails the comparison).I have not checked on the main branch, but the same line might be present here:
pandas/pandas/core/groupby/grouper.py
Line 853 in d72f165
Expected Behavior
Don't issue
FutureWarning
Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.13.0
python-bits : 64
OS : Windows
OS-release : 11
Version : 10.0.22621
machine : AMD64
processor : Intel64 Family 6 Model 186 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : English_United Kingdom.1252
pandas : 2.2.3
numpy : 2.2.2
pytz : 2025.1
dateutil : 2.9.0.post0
pip : 25.0
Cython : None
sphinx : None
IPython : 8.32.0
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 : 3.10.0
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : 8.3.4
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.15.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : 0.23.0
tzdata : 2025.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: