| 667 | _attributes: list[str] = ["_grouper"] |
| 668 | |
| 669 | def __init__( |
| 670 | self, |
| 671 | obj: DataFrame | Series, |
| 672 | *args, |
| 673 | _grouper: BaseGrouper, |
| 674 | _as_index: bool = True, |
| 675 | **kwargs, |
| 676 | ) -> None: |
| 677 | from pandas.core.groupby.ops import BaseGrouper |
| 678 | |
| 679 | if not isinstance(_grouper, BaseGrouper): |
| 680 | raise ValueError("Must pass a BaseGrouper object.") |
| 681 | self._grouper = _grouper |
| 682 | self._as_index = _as_index |
| 683 | # GH 32262: It's convention to keep the grouping column in |
| 684 | # groupby.<agg_func>, but unexpected to users in |
| 685 | # groupby.rolling.<agg_func> |
| 686 | obj = obj.drop(columns=self._grouper.names, errors="ignore") |
| 687 | # GH 15354 |
| 688 | if kwargs.get("step") is not None: |
| 689 | raise NotImplementedError("step not implemented for groupby") |
| 690 | super().__init__(obj, *args, **kwargs) |
| 691 | |
| 692 | def _apply( |
| 693 | self, |