Skip to content

BUG: ewm(adjust=False) NaN gaps disagree for times vs no-times - #66754

Open
hasancankeles wants to merge 3 commits into
pandas-dev:mainfrom
hasancankeles:bug-ewm-nan-times-66523
Open

BUG: ewm(adjust=False) NaN gaps disagree for times vs no-times#66754
hasancankeles wants to merge 3 commits into
pandas-dev:mainfrom
hasancankeles:bug-ewm-nan-times-66523

Conversation

@hasancankeles

Copy link
Copy Markdown

The adjust=False loop special-cased com == 1 (GH-59142) as new_wt = 1 - old_wt. That is the right convex weight when old_wt is just this step's decay, which is true for irregular times with no missing values. After an ignore_na=False NaN row, old_wt has already been multiplied once, so the same assignment gives the new observation the entire forgotten mass. That is:

Gating the special case on use_deltas (GH-66521) would fix only the first and split the two spellings — the inconsistency filed as #66523.

The intended split, from the documented ignore_na=False recursion, GH-59142's irregular-interval tests, and test_ewma_with_times_equal_spacing, is:

  • weight the new observation by this step's interval: new_wt = 1 - (1-α)^δ (δ = 1 without times);
  • leave decay accumulated across NaN rows in old_wt and renormalize.

That is option 1 from the issue, without switching the irregular no-NaN times path to the normalized form. test_ewma_with_times_variable_spacing is unchanged (0.2376251864…). Equally spaced times again match no-times for every adjust × ignore_na combination, including on NaN data.

Verified: pandas/tests/window/test_ewm.py, test_numba.py, test_online.py, and the other ewm-related window tests.

@github-actions github-actions Bot added the Needs Issue Assignment PR whose author is not assigned to a linked issue label Aug 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the pull request, @hasancankeles! It's linked to #66523, but that issue isn't assigned to you yet. To make sure two people don't unknowingly work on the same thing, we ask contributors to claim an issue first. Just comment /take on #66523 to claim it, and you're good to go. See the contributing guide for the full flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Issue Assignment PR whose author is not assigned to a linked issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG/API: ewm with equally spaced times disagrees with no-times for adjust=False, ignore_na=False on NaN data

1 participant