Skip to content

Commit 5992c3e

Browse files
committed
allow adjust=False when times is provided
1 parent 3dd8987 commit 5992c3e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pandas/core/window/ewm.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ class ExponentialMovingWindow(BaseWindow):
134134
Provide exponentially weighted (EW) calculations.
135135
136136
Exactly one of ``com``, ``span``, ``halflife``, or ``alpha`` must be
137-
provided if ``times`` is not provided. If ``times`` is provided,
137+
provided if ``times`` is not provided. If ``times`` is provided and ``adjust=True``,
138138
``halflife`` and one of ``com``, ``span`` or ``alpha`` may be provided.
139+
If ``times`` is provided and ``adjust=False``, ``halflife`` must be the only
140+
provided decay-specification parameter.
139141
140142
Parameters
141143
----------
@@ -358,8 +360,6 @@ def __init__(
358360
self.ignore_na = ignore_na
359361
self.times = times
360362
if self.times is not None:
361-
if not self.adjust:
362-
raise NotImplementedError("times is not supported with adjust=False.")
363363
times_dtype = getattr(self.times, "dtype", None)
364364
if not (
365365
is_datetime64_dtype(times_dtype)
@@ -376,6 +376,9 @@ def __init__(
376376
# Halflife is no longer applicable when calculating COM
377377
# But allow COM to still be calculated if the user passes other decay args
378378
if common.count_not_none(self.com, self.span, self.alpha) > 0:
379+
if not self.adjust:
380+
raise NotImplementedError('None of com, span, or alpha can be specified if '
381+
'times is provided and adjust=False')
379382
self._com = get_center_of_mass(self.com, self.span, None, self.alpha)
380383
else:
381384
self._com = 1.0

0 commit comments

Comments
 (0)