-
-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Open
Labels
BugNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member
Description
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 numpy as np
from pandas import DataFrame
df = DataFrame({"A": range(4, 8), "B": range(4)})
df.ewm(1).aggregate(sum) # fails
df.ewm(1).aggregate("sum") # works
df.ewm(1).aggregate(np.sum) # failsIssue Description
ExponentialMovingWindow.agg/aggregate fails when using a function (strings are fine).
Seems like there is an issue in how the aggregate call is wired, rolling does not suffer from the same issue (but any ExponentialGroupBy and alike will).
The traceback is the following:
File "<python-input-15>", line 1, in <module>
df.ewm(1).aggregate(np.sum) # fails
~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/Users/loic.diridollou/Documents/Code/pandas-stubs/gh1641_pandas_30/.venv/lib/python3.14/site-packages/pandas/core/window/ewm.py", line 524, in aggregate
return super().aggregate(func, *args, **kwargs)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/loic.diridollou/Documents/Code/pandas-stubs/gh1641_pandas_30/.venv/lib/python3.14/site-packages/pandas/core/window/rolling.py", line 654, in aggregate
return self.apply(func, raw=False, args=args, kwargs=kwargs)
^^^^^^^^^^
File "/Users/loic.diridollou/Documents/Code/pandas-stubs/gh1641_pandas_30/.venv/lib/python3.14/site-packages/pandas/core/window/rolling.py", line 305, in __getattr__
raise AttributeError(
f"'{type(self).__name__}' object has no attribute '{attr}'"
)
AttributeError: 'ExponentialMovingWindow' object has no attribute 'apply'. Did you mean: '_apply'?
Expected Behavior
The use of a callable should not fail since other functions passed as string (mean, cov, corr, sum, ...). are working fine.
Installed Versions
Details
Replace this line with the output of pd.show_versions()
Metadata
Metadata
Assignees
Labels
BugNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member