Skip to content
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

BUG: EWM(online) not raising NotImplementedError for unsupported #48834

Merged
merged 3 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ Plotting

Groupby/resample/rolling
^^^^^^^^^^^^^^^^^^^^^^^^
- Bug in :class:`.ExponentialMovingWindow` with ``online`` not raising a ``NotImplementedError`` for unsupported operations (:issue:`48834`)
- Bug in :meth:`DataFrameGroupBy.sample` raises ``ValueError`` when the object is empty (:issue:`48459`)
-

Expand Down
10 changes: 5 additions & 5 deletions pandas/core/window/ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,10 @@ def reset(self) -> None:
self._mean.reset()

def aggregate(self, func, *args, **kwargs):
return NotImplementedError
raise NotImplementedError("aggregate is not implemented.")

def std(self, bias: bool = False, *args, **kwargs):
return NotImplementedError
raise NotImplementedError("std is not implemented.")

def corr(
self,
Expand All @@ -979,7 +979,7 @@ def corr(
numeric_only: bool = False,
**kwargs,
):
return NotImplementedError
raise NotImplementedError("corr is not implemented.")

def cov(
self,
Expand All @@ -989,10 +989,10 @@ def cov(
numeric_only: bool = False,
**kwargs,
):
return NotImplementedError
raise NotImplementedError("cov is not implemented.")

def var(self, bias: bool = False, *args, **kwargs):
return NotImplementedError
raise NotImplementedError("var is not implemented.")

def mean(self, *args, update=None, update_times=None, **kwargs):
"""
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/window/test_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,13 @@ def test_update_times_mean(
tm.assert_equal(result, expected.tail(3))

online_ewm.reset()

@pytest.mark.parametrize("method", ["aggregate", "std", "corr", "cov", "var"])
def test_ewm_notimplementederror_raises(self, method):
ser = Series(range(10))
kwargs = {}
if method == "aggregate":
kwargs["func"] = lambda x: x

with pytest.raises(NotImplementedError, match=".* is not implemented."):
getattr(ser.ewm(1).online(), method)(**kwargs)