BUG: DataFrameGroupBy.agg
has different behavior when input function receives keyword argument
#60379
Closed
2 of 3 tasks
Labels
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
When performing an aggregation over groups, my colleagues and I observed that
DataFrameGroupBy.agg
has inconsistent behavior when the function passed to theagg
method has or not keyword arguments.If
agg
receives the function_agg_func
without keyword arguments, then the input to_agg_func
will be apandas.Series
. If keyword arguments are passed, then the input to_agg_func
is apandas.DataFrame
.Expected Behavior
As per the docs, the parameter
func
should be able to receive apandas.DataFrame
as input, hence, I would expect that the input for_agg_func
should always be apandas.DataFrame
, independently if the function receives or not a keyword argument.Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.11.10
python-bits : 64
OS : Linux
OS-release : 5.15.133.1-microsoft-standard-WSL2
Version : #1 SMP Thu Oct 5 21:02:42 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.3
numpy : 2.0.1
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 23.3.1
Cython : None
sphinx : None
IPython : 8.29.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.4
lxml.etree : None
matplotlib : 3.9.0
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : 2.9.9
pymysql : None
pyarrow : 18.0.0
pyreadstat : None
pytest : 8.3.2
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.14.1
sqlalchemy : 2.0.32
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: