We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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.
import numpy as np import pandas as pd rng = np.random.default_rng(42) data = pd.Series(rng.uniform(size=(10, 2)).dot([1, 1j])) gr = data.groupby(data.index % 2) gr.mean() # TypeError: No matching signature found
gr.mean() raises TypeError: No matching signature found when the underlying dtype is complex128. The other complex dtypes present the same behavior.
gr.mean()
TypeError: No matching signature found
complex128
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/goyo/.local/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1684, in mean result = self._cython_agg_general( File "/home/goyo/.local/lib/python3.9/site-packages/pandas/core/groupby/generic.py", line 352, in _cython_agg_general result = array_func(objvals) File "/home/goyo/.local/lib/python3.9/site-packages/pandas/core/groupby/generic.py", line 340, in array_func result = self.grouper._cython_operation( File "/home/goyo/.local/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 978, in _cython_operation return cy_op.cython_operation( File "/home/goyo/.local/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 639, in cython_operation return self._cython_op_ndim_compat( File "/home/goyo/.local/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 481, in _cython_op_ndim_compat res = self._call_cython_op( File "/home/goyo/.local/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 557, in _call_cython_op func(result, counts, values, comp_ids, min_count) File "pandas/_libs/groupby.pyx", line 668, in pandas._libs.groupby.__pyx_fused_cpdef TypeError: No matching signature found
Since data.mean() works I would expect that it also works in the GroupBy object. The expected result is:
data.mean()
GroupBy
>>> gr.mean() 0 0.438939+0.550293j 1 0.652316+0.653820j dtype: complex128
Just like .sum():
.sum()
>>> gr.sum() # this does work. 0 2.194697+2.751466j 1 3.261581+3.269100j dtype: complex128
commit : 73c6825 python : 3.9.5.final.0 python-bits : 64 OS : Linux OS-release : 5.11.0-34-generic Version : #36-Ubuntu SMP Thu Aug 26 19:22:09 UTC 2021 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8
pandas : 1.3.3 numpy : 1.21.2 pytz : 2021.1 dateutil : 2.8.2 pip : 21.2.4 setuptools : 58.0.4 Cython : None pytest : None hypothesis : None sphinx : 3.5.3 blosc : None feather : None xlsxwriter : 3.0.1 lxml.etree : 4.6.3 html5lib : 1.1 pymysql : None psycopg2 : None jinja2 : 3.0.1 IPython : 7.27.0 pandas_datareader: None bs4 : 4.10.0 bottleneck : 1.3.2 fsspec : None fastparquet : None gcsfs : None matplotlib : 3.4.3 numexpr : 2.7.3 odfpy : None openpyxl : 3.0.8 pandas_gbq : None pyarrow : None pyxlsb : None s3fs : None scipy : 1.7.1 sqlalchemy : None tables : 3.6.1 tabulate : None xarray : None xlrd : 2.0.1 xlwt : 1.3.0 numba : None
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
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
gr.mean()
raisesTypeError: No matching signature found
when the underlying dtype iscomplex128
. The other complex dtypes present the same behavior.Expected Behavior
Since
data.mean()
works I would expect that it also works in theGroupBy
object. The expected result is:Just like
.sum()
:Installed Versions
INSTALLED VERSIONS
commit : 73c6825
python : 3.9.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.11.0-34-generic
Version : #36-Ubuntu SMP Thu Aug 26 19:22:09 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.3
numpy : 1.21.2
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.0.4
Cython : None
pytest : None
hypothesis : None
sphinx : 3.5.3
blosc : None
feather : None
xlsxwriter : 3.0.1
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.27.0
pandas_datareader: None
bs4 : 4.10.0
bottleneck : 1.3.2
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.4.3
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.8
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : 1.3.0
numba : None
The text was updated successfully, but these errors were encountered: