Skip to content

BUG: Fix .rolling().mean() reassignment returning NaNs (pandas-dev#61841) #61851

New issue

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
)
from pandas.core.dtypes.missing import notna


from pandas import (
DataFrame,
Series,
)
from pandas.core._numba import executor
from pandas.core.algorithms import factorize
from pandas.core.apply import (
Expand Down Expand Up @@ -119,10 +124,7 @@
npt,
)

from pandas import (
DataFrame,
Series,
)

from pandas.core.generic import NDFrame
from pandas.core.groupby.ops import BaseGrouper

Expand Down Expand Up @@ -1230,9 +1232,13 @@ def calc(x):

return result

return self._apply_columnwise(homogeneous_func, name, numeric_only)[
:: self.step
]
result = self._apply_columnwise(homogeneous_func, name, numeric_only)
if self.step is not None and self.step > 1:
if isinstance(result, Series):
result = result.iloc[:: self.step]
elif isinstance(result, DataFrame):
result = result.iloc[:: self.step, :]
return result

@doc(
_shared_docs["aggregate"],
Expand Down
Loading