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
U
¬ý°du`ã@sâddlmZddlmZddlmZmZmZddlm    Z    m
Z
m Z er`ddl m Z mZddlmZddlmZddlmZmZmZdd    lmZmZmZmZmZmZmZmZm Z dd
l!m"Z"m#Z#Gd d „d e#ƒZ$Gd d„de"e$ƒZ%dS)é)Ú annotations)Údedent)Ú TYPE_CHECKINGÚAnyÚCallable)ÚAxisÚQuantileInterpolationÚWindowingRankType)Ú    DataFrameÚSeries)ÚNDFrame)Údoc)Ú BaseIndexerÚExpandingIndexerÚGroupbyIndexer)    Ú _shared_docsÚcreate_section_headerÚkwargs_numeric_onlyÚ numba_notesÚtemplate_headerÚtemplate_returnsÚtemplate_see_alsoÚwindow_agg_numba_parametersÚwindow_apply_parameters)ÚBaseWindowGroupbyÚRollingAndExpandingMixincs\eZdZUdZdddgZded<d‘d d d dddœ‡fdd„ Zddœdd„Zee    de
dƒe
dƒddd‡fdd„ƒZ e Z ee edƒeed ƒed
d!…d"d#d$d%d’d'd(œ‡fd)d*„ ƒZee ed+ƒeedƒeed ƒed
d!…d"d,d-d%
d“d.d'd/d0d1d2d3œ‡fd4d5„ ƒZee ed+ƒeeƒedƒeed ƒeed6ƒed
d!…d"d7d7d% d”d'd/d0d8œ‡fd9d:„ ƒZee ed+ƒeeƒedƒeed ƒeed6ƒed
d!…d"d;d<d% d•d'd/d0d8œ‡fd=d>„ ƒZee ed+ƒeeƒedƒeed ƒeed6ƒed
d!…d"d?d@d% d–d'd/d0d8œ‡fdAdB„ ƒZee ed+ƒeeƒedƒeed ƒeed6ƒed
d!…d"dCdCd% d—d'd/d0d8œ‡fdDdE„ ƒZee ed+ƒeeƒedƒeed ƒeed6ƒed
d!…d"dFdFd% d˜d'd/d0d8œ‡fdGdH„ ƒZee ed+ƒe
dIƒ dJdd¡eedKƒedƒeed ƒdLeed6ƒe
dMƒ dJdd¡edNƒe
dOƒ dJdd¡d"dPdQd%d™d d'd/d0dRœ‡fdSdT„ ƒZee ed+ƒe
dIƒ dJdd¡eedKƒedƒeed ƒdUeed6ƒe
dVƒ dJdd¡edNƒe
dWƒ dJdd¡d"dXdYd%dšd d'd/d0dRœ‡fdZd[„ ƒZee ed+ƒe
dIƒ dJdd¡eedƒeed ƒeed6ƒd\edNƒe
d]ƒ dJdd¡d"d^d_d%d›d d'd`œ‡fdadb„ ƒZee ed+ƒeedƒeed ƒdceed6ƒddd"dedfd% dœd'd(œ‡fdgdh„ ƒZ ee ed+ƒeedƒeed ƒdieed6ƒdjedNƒe
dkƒ dJdd¡d"dldmd%dd'd(œ‡fdndo„ ƒZ!ee ed+ƒe
dpƒ dJdd¡eedƒeed ƒed
d!…d"dqdqd% dždsdtd'duœ‡fdvdw„ ƒZ"ee dxed+ƒe
dyƒ dJdd¡eedƒeed ƒeedNƒe
dzƒ dJdd¡d"d{d{d%dŸd~d'd'd'dœ‡fd€d„ ƒZ#ee ed+ƒe
d‚ƒ dJdd¡eedƒeed ƒed
d!…d"dƒd„d% d d…d†d d'd‡œ‡fdˆd‰„ ƒZ$ee ed+ƒe
dŠƒ dJdd¡eedƒeed ƒe
d‹ƒ dJdd¡eed6ƒe
dŒƒ dJdd¡d"ddŽd%d¡d…d†d d'd‡œ‡fdd„ ƒZ%‡Z&S)¢Ú    Expandingaê
    Provide expanding window calculations.
 
    Parameters
    ----------
    min_periods : int, default 1
        Minimum number of observations in window required to have a value;
        otherwise, result is ``np.nan``.
 
    axis : int or str, default 0
        If ``0`` or ``'index'``, roll across the rows.
 
        If ``1`` or ``'columns'``, roll across the columns.
 
        For `Series` this parameter is unused and defaults to 0.
 
    method : str {'single', 'table'}, default 'single'
        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.
 
        .. versionadded:: 1.3.0
 
    Returns
    -------
    ``Expanding`` subclass
 
    See Also
    --------
    rolling : Provides rolling window calculations.
    ewm : Provides exponential weighted functions.
 
    Notes
    -----
    See :ref:`Windowing Operations <window.expanding>` 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
 
    **min_periods**
 
    Expanding sum with 1 vs 3 observations needed to calculate a value.
 
    >>> df.expanding(1).sum()
         B
    0  0.0
    1  1.0
    2  3.0
    3  3.0
    4  7.0
    >>> df.expanding(3).sum()
         B
    0  NaN
    1  NaN
    2  3.0
    3  3.0
    4  7.0
    Ú min_periodsÚaxisÚmethodz    list[str]Ú _attributesérÚsingleNr ÚintrÚstrÚNone)ÚobjrrrÚreturncstƒj|||||ddS)N)r&rrrÚ    selection)ÚsuperÚ__init__)Úselfr&rrrr(©Ú    __class__©úSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/window/expanding.pyr*usûzExpanding.__init__r©r'cCstƒS)z[
        Return an indexer class that will compute the window start and end bounds
        )r)r+r.r.r/Ú_get_window_indexer…szExpanding._get_window_indexerÚ    aggregatez£
        See Also
        --------
        pandas.DataFrame.aggregate : Similar DataFrame method.
        pandas.Series.aggregate : Similar Series method.
        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Úklassrcstƒj|f|ž|ŽS)N)r)r2)r+ÚfuncÚargsÚkwargsr,r.r/r2‹s zExpanding.aggregateZReturnszSee AlsoéÿÿÿÿZ    expandingzcount of non NaN observationsÚcount)Z window_methodZaggregation_descriptionZ
agg_methodFÚbool©Ú numeric_onlycstƒj|dS©Nr;)r)r9©r+r<r,r.r/r9¯s zExpanding.countZ
Parameterszcustom aggregation functionÚapplyzCallable[..., Any]z
str | Nonezdict[str, bool] | Noneztuple[Any, ...] | Nonezdict[str, Any] | None)r5ÚrawÚengineÚ engine_kwargsr6r7cstƒj||||||dS)N)r@rArBr6r7)r)r?)r+r5r@rArBr6r7r,r.r/r?¼súzExpanding.applyZNotesÚsum©r<rArBcstƒj|||dS©NrD)r)rC©r+r<rArBr,r.r/rCÚs
ýz Expanding.sumÚmaximumÚmaxcstƒj|||dSrE)r)rHrFr,r.r/rHõs
ýz Expanding.maxZminimumÚmincstƒj|||dSrE)r)rIrFr,r.r/rIs
ýz Expanding.minÚmeancstƒj|||dSrE)r)rJrFr,r.r/rJ+s
ýzExpanding.meanÚmediancstƒj|||dSrE)r)rKrFr,r.r/rKFs
ýzExpanding.medianz¼
        ddof : int, default 1
            Delta Degrees of Freedom.  The divisor used in calculations
            is ``N - ddof``, where ``N`` represents the number of elements.
 
        Ú
z1.4z/numpy.std : Equivalent method for NumPy array.
        The default ``ddof`` of 1 used in :meth:`Series.std` is different
        than the default ``ddof`` of 0 in :func:`numpy.std`.
 
        A minimum of one period is required for the rolling calculation.
 
        ZExamplesa 
        >>> s = pd.Series([5, 5, 6, 7, 5, 5, 5])
 
        >>> s.expanding(3).std()
        0         NaN
        1         NaN
        2    0.577350
        3    0.957427
        4    0.894427
        5    0.836660
        6    0.786796
        dtype: float64
        zstandard deviationÚstd©Úddofr<rArBcstƒj||||dS©NrN)r)rM©r+rOr<rArBr,r.r/rMas 5üz Expanding.stdz/numpy.var : Equivalent method for NumPy array.
        The default ``ddof`` of 1 used in :meth:`Series.var` is different
        than the default ``ddof`` of 0 in :func:`numpy.var`.
 
        A minimum of one period is required for the rolling calculation.
 
        a 
        >>> s = pd.Series([5, 5, 6, 7, 5, 5, 5])
 
        >>> s.expanding(3).var()
        0         NaN
        1         NaN
        2    0.333333
        3    0.916667
        4    0.800000
        5    0.700000
        6    0.619048
        dtype: float64
        ZvarianceÚvarcstƒj||||dSrP)r)rRrQr,r.r/rRs 5üz Expanding.varz:A minimum of one period is required for the calculation.
 
        >>> s = pd.Series([0, 1, 2, 3])
 
        >>> s.expanding().sem()
        0         NaN
        1    0.707107
        2    0.707107
        3    0.745356
        dtype: float64
        zstandard error of meanÚsem©rOr<cstƒj||dS)NrT)r)rS)r+rOr<r,r.r/rSÙs#z Expanding.semz:scipy.stats.skew : Third moment of a probability density.
zDA minimum of three periods is required for the rolling calculation.
zunbiased skewnessÚskewcstƒj|dSr=)r)rUr>r,r.r/rUþszExpanding.skewz/scipy.stats.kurtosis : Reference SciPy method.
z<A minimum of four periods is required for the calculation.
 
a[
        The example below will show a rolling calculation with a window size of
        four matching the equivalent function call using `scipy.stats`.
 
        >>> arr = [1, 2, 3, 4, 999]
        >>> import scipy.stats
        >>> print(f"{{scipy.stats.kurtosis(arr[:-1], bias=False):.6f}}")
        -1.200000
        >>> print(f"{{scipy.stats.kurtosis(arr, bias=False):.6f}}")
        4.999874
        >>> s = pd.Series(arr)
        >>> s.expanding(4).kurt()
        0         NaN
        1         NaN
        2         NaN
        3   -1.200000
        4    4.999874
        dtype: float64
        z,Fisher's definition of kurtosis without biasÚkurtcstƒj|dSr=)r)rVr>r,r.r/rVs&zExpanding.kurta‚
        quantile : float
            Quantile to compute. 0 <= quantile <= 1.
        interpolation : {{'linear', 'lower', 'higher', 'midpoint', 'nearest'}}
            This optional parameter specifies the interpolation method to use,
            when the desired quantile lies between two data points `i` and `j`:
 
                * linear: `i + (j - i) * fraction`, where `fraction` is the
                  fractional part of the index surrounded by `i` and `j`.
                * lower: `i`.
                * higher: `j`.
                * nearest: `i` or `j` whichever is nearest.
                * midpoint: (`i` + `j`) / 2.
        ÚquantileÚlinearÚfloatr©rWÚ interpolationr<cstƒj|||dS)NrZ)r)rW)r+rWr[r<r,r.r/rW8s
"ýzExpanding.quantilez.. versionadded:: 1.4.0 
 
a
        method : {{'average', 'min', 'max'}}, default 'average'
            How to rank the group of records that have the same value (i.e. ties):
 
            * average: average rank of the group
            * min: lowest rank in the group
            * max: highest rank in the group
 
        ascending : bool, default True
            Whether or not the elements should be ranked in ascending order.
        pct : bool, default False
            Whether or not to display the returned rankings in percentile
            form.
        a+
        >>> s = pd.Series([1, 4, 2, 3, 5, 3])
        >>> s.expanding().rank()
        0    1.0
        1    2.0
        2    2.0
        3    3.0
        4    5.0
        5    3.5
        dtype: float64
 
        >>> s.expanding().rank(method="max")
        0    1.0
        1    2.0
        2    2.0
        3    3.0
        4    5.0
        5    4.0
        dtype: float64
 
        >>> s.expanding().rank(method="min")
        0    1.0
        1    2.0
        2    2.0
        3    3.0
        4    5.0
        5    3.0
        dtype: float64
        ÚrankÚaverageTr    ©rÚ    ascendingÚpctr<cstƒj||||dS)Nr^)r)r\)r+rr_r`r<r,r.r/r\`s DüzExpanding.ranka
        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 MultiIndexed DataFrame in the case of DataFrame
            inputs. In the case of missing elements, only complete pairwise
            observations will be used.
        ddof : int, default 1
            Delta Degrees of Freedom.  The divisor used in calculations
            is ``N - ddof``, where ``N`` represents the number of elements.
        zsample covarianceÚcovzDataFrame | Series | Nonez bool | None©ÚotherÚpairwiserOr<cstƒj||||dS©Nrb)r)ra©r+rcrdrOr<r,r.r/ra«s $üz Expanding.covaN
        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 MultiIndexed DataFrame in the case of DataFrame
            inputs. In the case of missing elements, only complete pairwise
            observations will be used.
        z
        cov : Similar method to calculate covariance.
        numpy.corrcoef : NumPy Pearson's correlation calculation.
        an
        This function uses Pearson's definition of correlation
        (https://en.wikipedia.org/wiki/Pearson_correlation_coefficient).
 
        When `other` is not specified, the output will be self correlation (e.g.
        all 1's), except for :class:`~pandas.DataFrame` inputs with `pairwise`
        set to `True`.
 
        Function will return ``NaN`` for correlations of equal valued sequences;
        this is the result of a 0/0 division error.
 
        When `pairwise` is set to `False`, only matching columns between `self` and
        `other` will be used.
 
        When `pairwise` is set to `True`, the output will be a MultiIndex DataFrame
        with the original index on the first level, and the `other` DataFrame
        columns on the second level.
 
        In the case of missing elements, only complete pairwise observations
        will be used.
        Z correlationÚcorrcstƒj||||dSre)r)rgrfr,r.r/rgÖs ?üzExpanding.corr)r!rr"N)F)FNNNN)FNN)FNN)FNN)FNN)FNN)r!FNN)r!FNN)r!F)F)F)rXF)r]TFF)NNr!F)NNr!F)'Ú__name__Ú
__module__Ú __qualname__Ú__doc__r Ú__annotations__r*r1r rrr2Zaggrrrrr9rr?rrrrCrHrIrJrKÚreplacerMrRrSrUrVrWr\rargÚ __classcell__r.r.r,r/r,sB
Fúÿÿã
ø
 
öù 
óü 
óü 
óü 
óü 
óü ÿúÿùÿòÔ0ûÿúÿùÿòÔ0ûÿúÿ õ à"óÿìÝ%ÿñ
æü ÿñÿâÅ?ûÿð
åûÿ óÿûÿêÊ:ûrc@s*eZdZdZejejZddœdd„ZdS)ÚExpandingGroupbyz5
    Provide a expanding groupby implementation.
    rr0cCst|jjtd}|S)z“
        Return an indexer class that will compute the window start and end bounds
 
        Returns
        -------
        GroupbyIndexer
        )Zgroupby_indicesÚwindow_indexer)rÚ_grouperÚindicesr)r+rpr.r.r/r1$s
þz$ExpandingGroupby._get_window_indexerN)rhrirjrkrr rr1r.r.r.r/ros roN)&Ú
__future__rÚtextwraprÚtypingrrrZpandas._typingrrr    Zpandasr
r Zpandas.core.genericr Zpandas.util._decoratorsr Zpandas.core.indexers.objectsrrrZpandas.core.window.docrrrrrrrrrZpandas.core.window.rollingrrrror.r.r.r/Ú<module>s"    , v