|
44 | 44 |
|
45 | 45 | from pandas.core._numba import executor |
46 | 46 | from pandas.core.algorithms import factorize |
47 | | -from pandas.core.apply import ResamplerWindowApply |
| 47 | +from pandas.core.apply import ( |
| 48 | + ResamplerWindowApply, |
| 49 | + reconstruct_func, |
| 50 | +) |
48 | 51 | from pandas.core.arrays import ExtensionArray |
49 | 52 | from pandas.core.base import SelectionMixin |
50 | 53 | import pandas.core.common as com |
@@ -646,8 +649,12 @@ def _numba_apply( |
646 | 649 | out = obj._constructor(result, index=index, columns=columns) |
647 | 650 | return self._resolve_output(out, obj) |
648 | 651 |
|
649 | | - def aggregate(self, func, *args, **kwargs): |
| 652 | + def aggregate(self, func=None, *args, **kwargs): |
| 653 | + relabeling, func, columns, order = reconstruct_func(func, **kwargs) |
650 | 654 | result = ResamplerWindowApply(self, func, args=args, kwargs=kwargs).agg() |
| 655 | + if isinstance(result, ABCDataFrame) and relabeling: |
| 656 | + result = result.iloc[:, order] |
| 657 | + result.columns = columns # type: ignore[union-attr] |
651 | 658 | if result is None: |
652 | 659 | return self.apply(func, raw=False, args=args, kwargs=kwargs) |
653 | 660 | return result |
@@ -1239,7 +1246,7 @@ def calc(x): |
1239 | 1246 | klass="Series/DataFrame", |
1240 | 1247 | axis="", |
1241 | 1248 | ) |
1242 | | - def aggregate(self, func, *args, **kwargs): |
| 1249 | + def aggregate(self, func=None, *args, **kwargs): |
1243 | 1250 | result = ResamplerWindowApply(self, func, args=args, kwargs=kwargs).agg() |
1244 | 1251 | if result is None: |
1245 | 1252 | # these must apply directly |
@@ -1951,7 +1958,7 @@ def _raise_monotonic_error(self, msg: str): |
1951 | 1958 | klass="Series/Dataframe", |
1952 | 1959 | axis="", |
1953 | 1960 | ) |
1954 | | - def aggregate(self, func, *args, **kwargs): |
| 1961 | + def aggregate(self, func=None, *args, **kwargs): |
1955 | 1962 | return super().aggregate(func, *args, **kwargs) |
1956 | 1963 |
|
1957 | 1964 | agg = aggregate |
|
0 commit comments