Skip to content

Commit ce082fb

Browse files
authored
ERR: Raise NotImplimentedError for EWMA with times and adjust=False (#40314)
1 parent 602ab16 commit ce082fb

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

doc/source/whatsnew/v1.3.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ Groupby/resample/rolling
570570
- Bug in :meth:`DataFrameGroupBy.sample` where column selection was not applied to sample result (:issue:`39928`)
571571
- Bug in :class:`core.window.ewm.ExponentialMovingWindow` when calling ``__getitem__`` would incorrectly raise a ``ValueError`` when providing ``times`` (:issue:`40164`)
572572
- Bug in :class:`core.window.ewm.ExponentialMovingWindow` when calling ``__getitem__`` would not retain ``com``, ``span``, ``alpha`` or ``halflife`` attributes (:issue:`40164`)
573+
- :class:`core.window.ewm.ExponentialMovingWindow` now raises a ``NotImplementedError`` when specifying ``times`` with ``adjust=False`` due to an incorrect calculation (:issue:`40098`)
573574

574575
Reshaping
575576
^^^^^^^^^

pandas/core/window/ewm.py

+2
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ def __init__(
255255
self.ignore_na = ignore_na
256256
self.times = times
257257
if self.times is not None:
258+
if not self.adjust:
259+
raise NotImplementedError("times is not supported with adjust=False.")
258260
if isinstance(self.times, str):
259261
self.times = self._selected_obj[self.times]
260262
if not is_datetime64_ns_dtype(self.times):

pandas/tests/window/test_ewm.py

+10
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,13 @@ def test_ewm_vol_deprecated():
171171
result = ser.ewm(com=0.1).vol()
172172
expected = ser.ewm(com=0.1).std()
173173
tm.assert_series_equal(result, expected)
174+
175+
176+
def test_ewma_times_adjust_false_raises():
177+
# GH 40098
178+
with pytest.raises(
179+
NotImplementedError, match="times is not supported with adjust=False."
180+
):
181+
Series(range(1)).ewm(
182+
0.1, adjust=False, times=date_range("2000", freq="D", periods=1)
183+
)

0 commit comments

Comments
 (0)