Skip to content

Commit 0588f6f

Browse files
committed
revert accident
1 parent 84a46eb commit 0588f6f

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

doc/source/whatsnew/v1.1.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ Groupby/resample/rolling
310310

311311
- Bug in :meth:`GroupBy.apply` raises ``ValueError`` when the ``by`` axis is not sorted and has duplicates and the applied ``func`` does not mutate passed in objects (:issue:`30667`)
312312
- Bug in :meth:`DataFrameGroupby.transform` produces incorrect result with transformation functions (:issue:`30918`)
313+
- Bug in :meth:`pandas.core.groupby.RollingGroupby.apply` was including the grouped-by column in its values, rather than just in the index (:issue:`32262`)
313314

314315
Reshaping
315316
^^^^^^^^^

pandas/core/groupby/groupby.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,6 @@ def rolling(self, *args, **kwargs):
15771577
"""
15781578
from pandas.core.window import RollingGroupby
15791579

1580-
self.obj = self._obj_with_exclusions
15811580
return RollingGroupby(self, *args, **kwargs)
15821581

15831582
@Substitution(name="groupby")

pandas/core/window/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def _apply(
8181

8282
# TODO: can we de-duplicate with _dispatch?
8383
def f(x, name=name, *args):
84-
x = self._shallow_copy(x)
84+
x = self._shallow_copy(x, exclusions=self._groupby.exclusions)
85+
x.obj = x._obj_with_exclusions
8586

8687
if isinstance(name, str):
8788
return getattr(x, name)(*args, **kwargs)

pandas/tests/window/test_rolling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,4 @@ def test_by_column_not_in_values():
475475
r = g.rolling(4)
476476
result = r.sum()
477477
assert "A" not in result.columns
478+
assert "A" in g.obj.columns # check for side-effects

0 commit comments

Comments
 (0)