1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
U
¬ý°dP…ã@s®ddlmZddlZddlmZddlmZddlmZddl    Z
ddl m Z ddl mmmZddlmZmZer”ddlmZmZdd    lmZdd
lmZdd lmZmZdd lm Z dd l!m"Z"ddl#m$Z$m%Z%m&Z&ddl'm(Z(m)Z)ddl*m+Z+ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4ddl5m6Z6m7Z7ddl8m9Z9m:Z:ddl;m<Z<m=Z=ddddddœdd„Z>ddddœdd„Z?Gd d!„d!e<ƒZ@Gd"d#„d#e=e@ƒZAGd$d%„d%e@ƒZBdS)&é)Ú annotationsN)Úpartial)Údedent)Ú TYPE_CHECKING)Ú    Timedelta)ÚAxisÚTimedeltaConvertibleTypes)Ú    DataFrameÚSeries)ÚNDFrame)Údoc)Úis_datetime64_ns_dtypeÚis_numeric_dtype)Úisna)Úcommon)Ú BaseIndexerÚExponentialMovingWindowIndexerÚGroupbyIndexer)Úget_jit_argumentsÚmaybe_use_numba)Úzsqrt)Ú _shared_docsÚcreate_section_headerÚkwargs_numeric_onlyÚ numba_notesÚtemplate_headerÚtemplate_returnsÚtemplate_see_alsoÚwindow_agg_numba_parameters)Úgenerate_numba_ewm_funcÚgenerate_numba_ewm_table_func)Ú EWMMeanStateÚgenerate_online_numba_ewma_func)Ú
BaseWindowÚBaseWindowGroupbyú float | NoneÚfloat)ÚcomassÚspanÚhalflifeÚalphaÚreturncCsÜt ||||¡}|dkr tdƒ‚|dk    r:|dkrÔtdƒ‚nš|dk    r`|dkrRtdƒ‚|dd}nt|dk    rž|dkrxtdƒ‚dt t d¡|¡}d|d}n6|dk    rÌ|dks¶|dkr¾td    ƒ‚d||}ntd
ƒ‚t|ƒS) Néz8comass, span, halflife, and alpha are mutually exclusiverz comass must satisfy: comass >= 0zspan must satisfy: span >= 1éz#halflife must satisfy: halflife > 0gà?z"alpha must satisfy: 0 < alpha <= 1z1Must pass one of comass, span, halflife, or alpha)rÚcount_not_noneÚ
ValueErrorÚnpÚexpÚlogr&)r'r(r)r*Z valid_countZdecay©r3úMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/window/ewm.pyÚget_center_of_mass@s*
r5znp.ndarray | NDFrameú(float | TimedeltaConvertibleTypes | Noneú
np.ndarray)Útimesr)r+cCs:tj| tj¡tjd}tt|ƒ d¡jƒ}t     |¡|S)aå
    Return the diff of the times divided by the half-life. These values are used in
    the calculation of the ewm mean.
 
    Parameters
    ----------
    times : np.ndarray, Series
        Times corresponding to the observations. Must be monotonically increasing
        and ``datetime64[ns]`` dtype.
    halflife : float, str, timedelta, optional
        Half-life specifying the decay
 
    Returns
    -------
    np.ndarray
        Diff of the times divided by the half-life
    ©ÚdtypeÚns)
r0ZasarrayÚviewÚint64Úfloat64r&rZas_unitÚ_valueZdiff)r8r)Z_timesZ    _halflifer3r3r4Ú_calculate_deltasasr@cs¨eZdZdZdddddddd    d
d g
Zd^d dœdddddddddddddœ ‡fdd„Zddddd œd!d"„Zd#d$œd%d&„Zd_dd(d)œd*d+„Ze    e
d,e d-ƒe d.ƒd/d0d1‡fd2d3„ƒZ e Z e    eed4ƒeeƒed5ƒeed6ƒeed7ƒe d8d0d9¡d:d;d<d= d`dd>œd?d@„ƒZe    eed4ƒeeƒed5ƒeed6ƒeed7ƒe d8d0d9¡d:dAdBd= dadd>œdCdD„ƒZe    eed4ƒe dEƒ d8d0d9¡eed5ƒeed6ƒed dF…d:dGdHd= dbdddIœdJdK„ƒZe    eed4ƒe dEƒ d8d0d9¡eed5ƒeed6ƒed dF…d:dLdMd= dcdddIœdNdO„ƒZe    eed4ƒe dPƒ d8d0d9¡eed5ƒeed6ƒed dF…d:dQdRd= dddSdTdddUœdVdW„ƒZe    eed4ƒe dXƒ d8d0d9¡eed5ƒeed6ƒed dF…d:dYdZd= dedSdTdd[œd\d]„ƒZ‡ZS)fÚExponentialMovingWindowa&
    Provide exponentially weighted (EW) calculations.
 
    Exactly one of ``com``, ``span``, ``halflife``, or ``alpha`` must be
    provided if ``times`` is not provided. If ``times`` is provided,
    ``halflife`` and one of ``com``, ``span`` or ``alpha`` may be provided.
 
    Parameters
    ----------
    com : float, optional
        Specify decay in terms of center of mass
 
        :math:`\alpha = 1 / (1 + com)`, for :math:`com \geq 0`.
 
    span : float, optional
        Specify decay in terms of span
 
        :math:`\alpha = 2 / (span + 1)`, for :math:`span \geq 1`.
 
    halflife : float, str, timedelta, optional
        Specify decay in terms of half-life
 
        :math:`\alpha = 1 - \exp\left(-\ln(2) / halflife\right)`, for
        :math:`halflife > 0`.
 
        If ``times`` is specified, a timedelta convertible unit over which an
        observation decays to half its value. Only applicable to ``mean()``,
        and halflife value will not apply to the other functions.
 
        .. versionadded:: 1.1.0
 
    alpha : float, optional
        Specify smoothing factor :math:`\alpha` directly
 
        :math:`0 < \alpha \leq 1`.
 
    min_periods : int, default 0
        Minimum number of observations in window required to have a value;
        otherwise, result is ``np.nan``.
 
    adjust : bool, default True
        Divide by decaying adjustment factor in beginning periods to account
        for imbalance in relative weightings (viewing EWMA as a moving average).
 
        - When ``adjust=True`` (default), the EW function is calculated using weights
          :math:`w_i = (1 - \alpha)^i`. For example, the EW moving average of the series
          [:math:`x_0, x_1, ..., x_t`] would be:
 
        .. math::
            y_t = \frac{x_t + (1 - \alpha)x_{t-1} + (1 - \alpha)^2 x_{t-2} + ... + (1 -
            \alpha)^t x_0}{1 + (1 - \alpha) + (1 - \alpha)^2 + ... + (1 - \alpha)^t}
 
        - When ``adjust=False``, the exponentially weighted function is calculated
          recursively:
 
        .. math::
            \begin{split}
                y_0 &= x_0\\
                y_t &= (1 - \alpha) y_{t-1} + \alpha x_t,
            \end{split}
    ignore_na : bool, default False
        Ignore missing values when calculating weights.
 
        - When ``ignore_na=False`` (default), weights are based on absolute positions.
          For example, the weights of :math:`x_0` and :math:`x_2` used in calculating
          the final weighted average of [:math:`x_0`, None, :math:`x_2`] are
          :math:`(1-\alpha)^2` and :math:`1` if ``adjust=True``, and
          :math:`(1-\alpha)^2` and :math:`\alpha` if ``adjust=False``.
 
        - When ``ignore_na=True``, weights are based
          on relative positions. For example, the weights of :math:`x_0` and :math:`x_2`
          used in calculating the final weighted average of
          [:math:`x_0`, None, :math:`x_2`] are :math:`1-\alpha` and :math:`1` if
          ``adjust=True``, and :math:`1-\alpha` and :math:`\alpha` if ``adjust=False``.
 
    axis : {0, 1}, default 0
        If ``0`` or ``'index'``, calculate across the rows.
 
        If ``1`` or ``'columns'``, calculate across the columns.
 
        For `Series` this parameter is unused and defaults to 0.
 
    times : np.ndarray, Series, default None
 
        .. versionadded:: 1.1.0
 
        Only applicable to ``mean()``.
 
        Times corresponding to the observations. Must be monotonically increasing and
        ``datetime64[ns]`` dtype.
 
        If 1-D array like, a sequence with the same shape as the observations.
 
    method : str {'single', 'table'}, default 'single'
        .. versionadded:: 1.4.0
 
        Execute the rolling operation per single column or row (``'single'``)
        or over the entire object (``'table'``).
 
        This argument is only implemented when specifying ``engine='numba'``
        in the method call.
 
        Only applicable to ``mean()``
 
    Returns
    -------
    ``ExponentialMovingWindow`` subclass
 
    See Also
    --------
    rolling : Provides rolling window calculations.
    expanding : Provides expanding transformations.
 
    Notes
    -----
    See :ref:`Windowing Operations <window.exponentially_weighted>`
    for further usage details and examples.
 
    Examples
    --------
    >>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
    >>> df
         B
    0  0.0
    1  1.0
    2  2.0
    3  NaN
    4  4.0
 
    >>> df.ewm(com=0.5).mean()
              B
    0  0.000000
    1  0.750000
    2  1.615385
    3  1.615385
    4  3.670213
    >>> df.ewm(alpha=2 / 3).mean()
              B
    0  0.000000
    1  0.750000
    2  1.615385
    3  1.615385
    4  3.670213
 
    **adjust**
 
    >>> df.ewm(com=0.5, adjust=True).mean()
              B
    0  0.000000
    1  0.750000
    2  1.615385
    3  1.615385
    4  3.670213
    >>> df.ewm(com=0.5, adjust=False).mean()
              B
    0  0.000000
    1  0.666667
    2  1.555556
    3  1.555556
    4  3.650794
 
    **ignore_na**
 
    >>> df.ewm(com=0.5, ignore_na=True).mean()
              B
    0  0.000000
    1  0.750000
    2  1.615385
    3  1.615385
    4  3.225000
    >>> df.ewm(com=0.5, ignore_na=False).mean()
              B
    0  0.000000
    1  0.750000
    2  1.615385
    3  1.615385
    4  3.670213
 
    **times**
 
    Exponentially weighted mean with weights calculated with a timedelta ``halflife``
    relative to ``times``.
 
    >>> times = ['2020-01-01', '2020-01-03', '2020-01-10', '2020-01-15', '2020-01-17']
    >>> df.ewm(halflife='4 days', times=pd.DatetimeIndex(times)).mean()
              B
    0  0.000000
    1  0.585786
    2  1.523889
    3  1.523889
    4  3.233686
    Úcomr(r)r*Ú min_periodsÚadjustÚ    ignore_naÚaxisr8ÚmethodNrTFÚsingle©Ú    selectionr r%r6ú
int | NoneÚboolrúnp.ndarray | NDFrame | NoneÚstrÚNone) ÚobjrBr(r)r*rCrDrErFr8rGr+c 
sŽtƒj||dkrdn tt|ƒdƒddd| |    | d||_||_||_||_||_||_    |
|_
|j
dk    r |jsvt dƒ‚t |j
ƒsˆt dƒ‚t|j
ƒt|ƒkr¢t dƒ‚t|jttjtjfƒsÀt dƒ‚t|j
ƒ ¡rÖt dƒ‚t|j
|jƒ|_t |j|j|j¡d    krt|j|jd|jƒ|_nd
|_nj|jdk    rLt|jttjtjfƒrLt d ƒ‚tjt|jj|j dd    ƒtj!d |_t|j|j|j|jƒ|_dS) Nr,F)rPrCÚonÚcenterÚclosedrGrFrJz)times is not supported with adjust=False.z#times must be datetime64[ns] dtype.z,times must be the same length as the object.z/halflife must be a timedelta convertible objectz$Cannot convert NaT values to integerrgð?zKhalflife can only be a timedelta convertible argument if times is not None.r9)"ÚsuperÚ__init__ÚmaxÚintrBr(r)r*rDrEr8ÚNotImplementedErrorr r/ÚlenÚ
isinstancerNÚdatetimeÚ    timedeltar0Z timedelta64rÚanyr@Ú_deltasrr.r5Ú_comÚonesrPÚshaperFr>) ÚselfrPrBr(r)r*rCrDrErFr8rGrJ©Ú    __class__r3r4rUKsbø
 
 ÿÿÿùz ExponentialMovingWindow.__init__r7rW)ÚstartÚendÚnum_valsr+cCsdS©Nr3)rbrerfrgr3r3r4Ú_check_window_bounds”sz,ExponentialMovingWindow._check_window_boundsr©r+cCstƒS)z[
        Return an indexer class that will compute the window start and end bounds
        )r©rbr3r3r4Ú_get_window_indexer›sz+ExponentialMovingWindow._get_window_indexerÚnumbaÚOnlineExponentialMovingWindow)Úenginer+cCs8t|j|j|j|j|j|j|j|j|j    |j
|||j d S)aª
        Return an ``OnlineExponentialMovingWindow`` object to calculate
        exponentially moving window aggregations in an online method.
 
        .. versionadded:: 1.3.0
 
        Parameters
        ----------
        engine: str, default ``'numba'``
            Execution engine to calculate online aggregations.
            Applies to all supported aggregation methods.
 
        engine_kwargs : dict, default None
            Applies to all supported aggregation methods.
 
            * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
              and ``parallel`` dictionary keys. The values must either be ``True`` or
              ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
              ``{{'nopython': True, 'nogil': False, 'parallel': False}}`` and will be
              applied to the function
 
        Returns
        -------
        OnlineExponentialMovingWindow
        ) rPrBr(r)r*rCrDrErFr8roÚ engine_kwargsrJ) rnrPrBr(r)r*rCrDrErFr8Z
_selection)rbrorpr3r3r4Úonline¡sózExponentialMovingWindow.onlineÚ    aggregatezV
        See Also
        --------
        pandas.DataFrame.rolling.aggregate
        aœ
        Examples
        --------
        >>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6], "C": [7, 8, 9]})
        >>> df
           A  B  C
        0  1  4  7
        1  2  5  8
        2  3  6  9
 
        >>> df.ewm(alpha=0.5).mean()
                  A         B         C
        0  1.000000  4.000000  7.000000
        1  1.666667  4.666667  7.666667
        2  2.428571  5.428571  8.428571
        zSeries/DataframeÚ)Zsee_alsoZexamplesÚklassrFcstƒj|f|ž|ŽSrh)rTrr©rbÚfuncÚargsÚkwargsrcr3r4rrÍsz!ExponentialMovingWindow.aggregateZ
ParametersZReturnszSee AlsoZNotesÚ
r,Úewmz"(exponential weighted moment) meanÚmean)Z window_methodZaggregation_descriptionZ
agg_method)Ú numeric_onlyc    Cs¸t|ƒrT|jdkrt}nt}|ft|ƒ|j|j|jt|j    ƒddœ—Ž}|j
|ddS|dkr¬|dk    rlt dƒ‚|j dkrzdn|j    }t tj|j|j|j|dd}|j
|d|dSt d    ƒ‚dS)
NrHT©rBrDrEÚdeltasÚ    normalizer{©Úname©ZcythonNú+cython engine does not accept engine_kwargs©rr|ú)engine must be either 'numba' or 'cython')rrGrr rr_rDrEÚtupler^Ú_applyr/r8rÚwindow_aggregationsrz©rbr|rorprvZewm_funcr~Ú window_funcr3r3r4r{ðs6
ú
úzExponentialMovingWindow.meanz!(exponential weighted moment) sumÚsumc    CsÆ|jstdƒ‚t|ƒrb|jdkr&t}nt}|ft|ƒ|j|j|jt    |j
ƒddœ—Ž}|j |ddS|dkrº|dk    rzt dƒ‚|j dkrˆdn|j
}ttj|j|j|j|dd}|j |d|d    St d
ƒ‚dS) Nz(sum is not implemented with adjust=FalserHFr}r‹r€r‚rƒr„r…)rDrXrrGrr rr_rEr†r^r‡r/r8rrˆrzr‰r3r3r4r‹$s:
ú
úzExponentialMovingWindow.sumzc
        bias : bool, default False
            Use a standard estimation bias correction.
        éÿÿÿÿz0(exponential weighted moment) standard deviationÚstd©Úbiasr|cCsB|r0|jjdkr0t|jjƒs0tt|ƒj›dƒ‚t|j||dƒS)Nr,z$.std does not implement numeric_onlyrŽ)    Ú _selected_objÚndimrr:rXÚtypeÚ__name__rÚvar©rbrr|r3r3r4rZsÿ
þ
ýÿzExponentialMovingWindow.stdz&(exponential weighted moment) variancer”cs:tj}t||j|j|j|d‰‡fdd„}|j|d|dS)N)rBrDrErcsˆ|||||ƒSrhr3)ÚvaluesÚbeginrfrC©Zwfuncr3r4Úvar_func”sz-ExponentialMovingWindow.var.<locals>.var_funcr”r„)rˆÚewmcovrr_rDrEr‡)rbrr|rŠr™r3r˜r4r”xsû zExponentialMovingWindow.vara§
        other : Series or DataFrame , optional
            If not supplied then will default to self and produce pairwise
            output.
        pairwise : bool, default None
            If False then only matching columns between self and other will be
            used and the output will be a DataFrame.
            If True then all pairwise combinations will be calculated and the
            output will be a MultiIndex DataFrame in the case of DataFrame
            inputs. In the case of missing elements, only complete pairwise
            observations will be used.
        bias : bool, default False
            Use a standard estimation bias correction.
        z/(exponential weighted moment) sample covarianceÚcovúDataFrame | Series | Noneú bool | None©ÚotherÚpairwiserr|cs<ddlm‰ˆ d|¡‡‡‡fdd„}ˆ ˆj||||¡S)Nr©r
r›c     sŠˆ |¡}ˆ |¡}ˆ ¡}ˆjdk    r,ˆjn|j}|jt|ƒ|ˆjˆjˆjd\}}t     
|||ˆj|ˆj ˆj ˆj ˆ¡    }ˆ||j|jddS)N©Z
num_valuesrCrRrSÚstepF©ÚindexrÚcopy)Ú _prep_valuesrlrCÚ window_sizeÚget_window_boundsrYrRrSr£rˆršr_rDrEr¥r)    ÚxÚyÚx_arrayÚy_arrayÚwindow_indexerrCrerfÚresult©r
rrbr3r4Úcov_funcÀs4
 
ÿýû
õ z-ExponentialMovingWindow.cov.<locals>.cov_func©Úpandasr
Z_validate_numeric_onlyZ_apply_pairwiser)rbrŸr rr|r±r3r°r4r›™s#  ÿzExponentialMovingWindow.covaL
        other : Series or DataFrame, optional
            If not supplied then will default to self and produce pairwise
            output.
        pairwise : bool, default None
            If False then only matching columns between self and other will be
            used and the output will be a DataFrame.
            If True then all pairwise combinations will be calculated and the
            output will be a MultiIndex DataFrame in the case of DataFrame
            inputs. In the case of missing elements, only complete pairwise
            observations will be used.
        z0(exponential weighted moment) sample correlationÚcorr©rŸr r|cs:ddlm‰ˆ d|¡‡‡fdd„}ˆ ˆj||||¡S)Nrr¡r´c
    sÀˆ |¡}ˆ |¡}ˆ ¡}ˆjdk    r,ˆjn|j‰|jt|ƒˆˆjˆjˆjd\‰‰‡‡‡‡fdd„}t    j
dd4|||ƒ}|||ƒ}|||ƒ}|t ||ƒ}    W5QRXˆ|    |j |j ddS)Nr¢c s t |ˆˆˆ|ˆjˆjˆjd¡    S)NT)rˆršr_rDrE)ÚXÚY)rfrCrbrer3r4Ú_covs÷z<ExponentialMovingWindow.corr.<locals>.cov_func.<locals>._covÚignore)ÚallFr¤)r§rlrCr¨r©rYrRrSr£r0Zerrstaterr¥r)
rªr«r¬r­r®r¸r›Zx_varZy_varr¯©r
rb)rfrCrer4r±s*
 
ÿýû
 
 
 
z.ExponentialMovingWindow.corr.<locals>.cov_funcr²)rbrŸr r|r±r3r»r4r´ãs   %ÿzExponentialMovingWindow.corr)
NNNNrTFrNrH)rmN)FNN)FNN)FF)FF)NNFF)NNF)r“Ú
__module__Ú __qualname__Ú__doc__Ú _attributesrUrirlrqr rrrrZaggrrrrrrrÚreplacer{r‹rr”r›r´Ú __classcell__r3r3rcr4rA|sRCöôò,Iÿ,ÿÿä óü% óü'ÿû
ð ÿû
ðÿñ
æû.ÿ ó
èürAcsFeZdZdZejejZddœddœ‡fdd„Zddœd    d
„Z‡Z    S) ÚExponentialMovingWindowGroupbyzF
    Provide an exponential moving window groupby implementation.
    N)Ú_grouperrOrjcs\tƒj|f|žd|i|—Ž|jsX|jdk    rXt t|jj     ¡ƒ¡}t
|j  |¡|j ƒ|_ dS)NrÃ)rTrUÚemptyr8r0Ú concatenateÚlistrÃÚindicesr–r@Ztaker)r^)rbrPrÃrwrxZ groupby_orderrcr3r4rU8s
þz'ExponentialMovingWindowGroupby.__init__rcCst|jjtd}|S)z“
        Return an indexer class that will compute the window start and end bounds
 
        Returns
        -------
        GroupbyIndexer
        )Zgroupby_indicesr®)rrÃrÇr)rbr®r3r3r4rlCs
þz2ExponentialMovingWindowGroupby._get_window_indexer)
r“r¼r½r¾rAr¿r$rUrlrÁr3r3rcr4rÂ1s  rÂcs´eZdZd*ddœdddd    dd
d d d d ddddœ ‡fdd„Zddœdd„Zdd„Zd+d dœdd„Zd,ddd dœdd „Zd-ddd d d!œd"d#„Zd.d d d$œd%d&„Z    ddd'œd(d)„Z
‡Z S)/rnNrTFrmrIr r%r6rKrLrrMrNzdict[str, bool] | NonerO) rPrBr(r)r*rCrDrErFr8rorpr+c  sp|
dk    rtdƒ‚tƒj|||||||||    |
| d t|j|j|j|j|jƒ|_    t
| ƒrd| |_ | |_ nt dƒ‚dS)Nz0times is not implemented with online operations.) rPrBr(r)r*rCrDrErFr8rJz$'numba' is the only supported engine)rXrTrUr!r_rDrErFraÚ_meanrrorpr/)rbrPrBr(r)r*rCrDrErFr8rorprJrcr3r4rUSs8ÿõ ÿz&OnlineExponentialMovingWindow.__init__rjcCs|j ¡dS)z=
        Reset the state captured by `update` calls.
        N)rÈÚresetrkr3r3r4rÉ~sz#OnlineExponentialMovingWindow.resetcOs tdƒ‚dS)Nzaggregate is not implemented.©rXrur3r3r4rr„sz'OnlineExponentialMovingWindow.aggregate)rcOs tdƒ‚dS)Nzstd is not implemented.rÊ)rbrrwrxr3r3r4r‡sz!OnlineExponentialMovingWindow.stdrœrrµcCs tdƒ‚dS)Nzcorr is not implemented.rÊ)rbrŸr r|r3r3r4r´Šsz"OnlineExponentialMovingWindow.corrržcCs tdƒ‚dS)Nzcov is not implemented.rÊ)rbrŸr rr|r3r3r4r›’sz!OnlineExponentialMovingWindow.covrŽcCs tdƒ‚dS)Nzvar is not implemented.rÊr•r3r3r4r”›sz!OnlineExponentialMovingWindow.var)ÚupdateÚ update_timesc Oshi}|jjdk}|dk    r tdƒ‚tjt|jj|jdddƒtjd}|dk    r¾|j    j
dkrdt dƒ‚d}|j |d<|r˜|j    j
tj dd…f}    |j|d    <n|j    j
}    |j|d
<t |    | ¡f¡}
n@d}|jj |d<|rà|jj|d    <n |jj|d
<|j tj¡ ¡}
tft|jƒŽ} |j     |r|
n|
dd…tj f||j| ¡} |sH|  ¡} | |d…} |jj| f|Ž} | S) a[
        Calculate an online exponentially weighted mean.
 
        Parameters
        ----------
        update: DataFrame or Series, default None
            New values to continue calculating the
            exponentially weighted mean from the last values and weights.
            Values should be float64 dtype.
 
            ``update`` needs to be ``None`` the first time the
            exponentially weighted mean is calculated.
 
        update_times: Series or 1-D np.ndarray, default None
            New times to continue calculating the
            exponentially weighted mean from the last values and weights.
            If ``None``, values are assumed to be evenly spaced
            in time.
            This feature is currently unsupported.
 
        Returns
        -------
        DataFrame or Series
 
        Examples
        --------
        >>> df = pd.DataFrame({"a": range(5), "b": range(5, 10)})
        >>> online_ewm = df.head(2).ewm(0.5).online()
        >>> online_ewm.mean()
              a     b
        0  0.00  5.00
        1  0.75  5.75
        >>> online_ewm.mean(update=df.tail(3))
                  a         b
        2  1.615385  6.615385
        3  2.550000  7.550000
        4  3.520661  8.520661
        >>> online_ewm.reset()
        >>> online_ewm.mean()
              a     b
        0  0.00  5.00
        1  0.75  5.75
        r-Nz update_times is not implemented.r,rr9z;Must call mean with update=None first before passing updater¥Úcolumnsr)rr‘rXr0r`rVrarFr>rÈZlast_ewmr/r¥ZnewaxisrÍrrÅZto_numpyZastyper"rrpZrun_ewmrCZsqueezeZ _constructor) rbrËrÌrwrxZ result_kwargsZis_frameZ update_deltasZ result_fromÚ
last_valueZnp_arrayZ    ewma_funcr¯r3r3r4r{žsR, ÿ ÿ
 
  ÿü z"OnlineExponentialMovingWindow.mean) NNNNrTFrNrmN)F)NNF)NNFF)FF) r“r¼r½rUrÉrrrr´r›r”r{rÁr3r3rcr4rnRs8óñ.+ü
û    rn)CÚ
__future__rr[Ú    functoolsrÚtextwraprÚtypingrÚnumpyr0Zpandas._libs.tslibsrZ pandas._libs.window.aggregationsZ_libsZwindowZ aggregationsrˆZpandas._typingrrr³r    r
Zpandas.core.genericr Zpandas.util._decoratorsr Zpandas.core.dtypes.commonr rZpandas.core.dtypes.missingrZ pandas.corerZpandas.core.indexers.objectsrrrZpandas.core.util.numba_rrZpandas.core.window.commonrZpandas.core.window.docrrrrrrrrZpandas.core.window.numba_rr Zpandas.core.window.onliner!r"Zpandas.core.window.rollingr#r$r5r@rArÂrnr3r3r3r4Ú<module>s@          (
!:!