HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/pandas/core/window/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/pandas/core/window/__pycache__/expanding.cpython-36.pyc
3

���h�@s�ddlmZddlmZmZddlmZddlm	Z	m
Z
mZddlm
Z
mZmZddlmZGdd�de�ZGd	d
�d
e
e�ZdS)�)�dedent)�Dict�Optional)�function)�Appender�Substitution�doc)�WindowGroupByMixin�
_doc_template�_shared_docs)�_Rolling_and_Expandingc	s�eZdZdZdddgZdH�fdd	�	Zed
d��ZdIdd
�Ze	d�Z
e	d�Zee
de
edddd��fdd��ZeZedd�ee
d��fdd���Zedd�ee
d�dJeeeeeeefd��fdd�
��Zedd�ee
d ��fd!d"���Zedd#d$�ee�ee
d#��fd%d&����Zedd�ee
d'��fd(d)���Zedd�ee
d*��fd+d,���Zedd�ee
d-��fd.d/���Zeddd0�ee
d1�dK�fd2d3�	��Zeddd0�ee
d4�dL�fd5d6�	��Zedd7d$�ee�ee
d7��fd8d9����Z e	d:�Z!ee!�edd�ee
d;��fd<d=����Z"edd�ee
d>�dM�fd@dA�	��Z#eddBd$�ee�ee
dB�dN�fdCdD�	���Z$edd�ee
dE�dO�fdFdG�	��Z%�Z&S)P�	Expandinga�
    Provide expanding transformations.

    Parameters
    ----------
    min_periods : int, default 1
        Minimum number of observations in window required to have a value
        (otherwise result is NA).
    center : bool, default False
        Set the labels at the center of the window.
    axis : int or str, default 0

    Returns
    -------
    a Window sub-classed for the particular operation

    See Also
    --------
    rolling : Provides rolling window calculations.
    ewm : Provides exponential weighted functions.

    Notes
    -----
    By default, the result is set to the right edge of the window. This can be
    changed to the center of the window by setting ``center=True``.

    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.expanding(2).sum()
         B
    0  NaN
    1  1.0
    2  3.0
    3  3.0
    4  7.0
    �min_periods�center�axis�Nrcst�j||||d�dS)N)�objrrr)�super�__init__)�selfrrrr�kwargs)�	__class__��>/tmp/pip-build-5_djhm0z/pandas/pandas/core/window/expanding.pyr<szExpanding.__init__cCstS)N)r
)rrrr�_constructor?szExpanding._constructorcKs:|jj|j�}t|�|dk	t|�}|jp.d}t||�S)au
        Get the window length over which to perform some operation.

        Parameters
        ----------
        other : object, default None
            The other object that is involved in the operation.
            Such an object is involved for operations like covariance.

        Returns
        -------
        window : int
            The window length.
        Nr���)rZ	_get_axisr�lenr�max)r�otherrr�lengthrrr�_get_windowCs
zExpanding._get_windowz�
    See Also
    --------
    pandas.DataFrame.aggregate : Similar DataFrame method.
    pandas.Series.aggregate : Similar Series method.
    ad
    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
    �	aggregate�zSeries/Dataframe)Zsee_alsoZexamples�versionadded�klassrcst�j|f|�|�S)N)rr!)r�func�argsr)rrrr!ts	zExpanding.aggregateZ	expanding)�name�countcst�jf|�S)N)rr()rr)rrrr(�szExpanding.count�applyF)�raw�engine�
engine_kwargscst�j||||||d�S)N)r*r+r,r&r)rr))rr%r*r+r,r&r)rrrr)�szExpanding.apply�sumcstjd||�t�j||�S)Nr-)�nv�validate_expanding_funcrr-)rr&r)rrrr-�sz
Expanding.sumr)r'�	func_namecstjd||�t�j||�S)Nr)r.r/rr)rr&r)rrrr�sz
Expanding.max�mincstjd||�t�j||�S)Nr1)r.r/rr1)rr&r)rrrr1�sz
Expanding.min�meancstjd||�t�j||�S)Nr2)r.r/rr2)rr&r)rrrr2�szExpanding.mean�mediancst�jf|�S)N)rr3)rr)rrrr3�szExpanding.median)r'r#�stdcs$tjd||�t�jfd|i|��S)Nr4�ddof)r.r/rr4)rr5r&r)rrrr4�sz
Expanding.std�varcs$tjd||�t�jfd|i|��S)Nr6r5)r.r/rr6)rr5r&r)rrrr6�sz
Expanding.var�skewcst�jf|�S)N)rr7)rr)rrrr7�szExpanding.skewa1
    Examples
    --------

    The example below will show an expanding 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
    �kurtcst�jf|�S)N)rr8)rr)rrrr8�szExpanding.kurt�quantile�linearcst�jf||d�|��S)N)r9�
interpolation)rr9)rr9r;r)rrrr9�szExpanding.quantile�covcst�jf|||d�|��S)N)r�pairwiser5)rr<)rrr=r5r)rrrr<�sz
Expanding.cov�corrcst�jf||d�|��S)N)rr=)rr>)rrr=r)rrrr>�szExpanding.corr)rNr)N)FNNNN)r)r)r:)NNr)NN)'�__name__�
__module__�__qualname__�__doc__�_attributesr�propertyrr rZ_agg_see_also_docZ_agg_examples_docrrr!Zaggrrr(�boolr�strrr)r-r
rr1r2r3r4r6r7Z_agg_docr8r9r<r>�
__classcell__rr)rrr
sz-


,









r
c@seZdZdZedd��ZdS)�ExpandingGroupbyz5
    Provide a expanding groupby implementation.
    cCstS)N)r
)rrrrrszExpandingGroupby._constructorN)r?r@rArBrDrrrrrrH�srHN)�textwraprZtypingrrZpandas.compat.numpyrr.Zpandas.util._decoratorsrrrZpandas.core.window.commonr	r
rZpandas.core.window.rollingrr
rHrrrr�<module>sr