BUG: groupby(...).agg()
with numpy transformations do not raise "Must produce aggregated value"
#44845
Open
2 of 3 tasks
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 master branch of pandas.
Reproducible Example
Issue Description
It appears that some non-reducing numpy function fastpaths bypass output checking and subsequently fail to raise a
ValueError: Must produce aggregated value
. In the cases that thisValueError
is not raised, the resultant shape is the same as the input shape which is conceptually incompatible with theagg
method (which should always reduce the input shape).Since the result of the lambda wrapped numpy function raises the expected
ValueError
, I am assuming that this has to do with some fastpath coded to intercept direct numpy functions.Expected Behavior
In these examples, I expect each one (except for the one that returns a list object) to raise the aforementioned error. All of these examples produce the same pattern of results if we swap out "cumsum" for "cumprod".
Installed Versions
INSTALLED VERSIONS
commit : 945c9ed
python : 3.9.7.final.0
python-bits : 64
OS : Linux
OS-release : 4.4.0-19041-Microsoft
Version : #1237-Microsoft Sat Sep 11 14:32:00 PST 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.4
numpy : 1.21.4
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 59.4.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 7.30.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.5.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.7.3
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: