Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/core/window/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/core/window/__pycache__/rolling.cpython-312.pyc

�

Mٜgu���dZddlmZddlZddlmZddlmZddlZddl	m
Z
ddlmZm
Z
mZmZddlZddlmZmZmZddlmcmcmZdd	lmZdd
lmZddlm Z m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'dd
l(m)Z)ddl*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:cm;Z<ddl=m>Z>m?Z?m@Z@mAZAddlBmCZCmDZDmEZEmFZFmGZGddlHmIZIddlJmKZKmLZLddlMmNZNmOZOddlPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZddl[m\Z\m]Z]m^Z^er.ddl_m`Z`maZambZbddlcmdZdmeZemfZfmgZgmhZhmiZiddljmkZkmlZlddlmmnZndd lompZpdd!lqmrZrGd"�d#e8�ZsGd$�d%es�ZtGd&�d'es�ZuGd(�d)es�ZvGd*�d+ev�Zweujew_Gd,�d-etew�Zxy).zc
Provide a generic structure to support window functions,
similar to how we have a Groupby object.
�)�annotationsN)�	timedelta)�partial)�dedent)�
TYPE_CHECKING�Any�Callable�Literal)�
BaseOffset�	Timedelta�	to_offset)�import_optional_dependency)�	DataError)�deprecate_kwarg�doc)�ensure_float64�is_bool�
is_integer�is_numeric_dtype�needs_i8_conversion)�
ArrowDtype)�ABCDataFrame�	ABCSeries)�notna)�executor)�	factorize)�ResamplerWindowApply)�ExtensionArray)�SelectionMixin)�BaseIndexer�FixedWindowIndexer�GroupbyIndexer�VariableWindowIndexer)�
DatetimeIndex�Index�
MultiIndex�PeriodIndex�TimedeltaIndex)�concat)�get_jit_arguments�maybe_use_numba)�flex_binary_moment�zsqrt)
�_shared_docs�create_section_header�kwargs_numeric_only�kwargs_scipy�numba_notes�template_header�template_returns�template_see_also�window_agg_numba_parameters�window_apply_parameters)�'generate_manual_numpy_nan_agg_with_axis�generate_numba_apply_func�generate_numba_table_func)�Hashable�Iterator�Sized)�	ArrayLike�Axis�NDFrameT�QuantileInterpolation�WindowingRankType�npt)�	DataFrame�Series)�NDFrame��BaseGrouper)�
dtype_to_unitc���eZdZUdZgZded<e�Zded<ded<									d"dd	�																			d#d
�Zd$d�Z									d%d�Z
d&d'd
�Zd(d�Zd)d�Z
d*d+d�Zd&d�Zd,d�Zd�Zd-d�Zd.d�Zd/d�Zd0d�Zed1d��Zd2d�Zd3d�Z	d&					d4d�Z	d*							d5d�Z		d6							d7d�Z												d8d�Z		d9							d:d�Z	d&			d;d �Zd!�Z e Z!y)<�
BaseWindowz7Provides utilities for performing windowing operations.�	list[str]�_attributeszfrozenset[Hashable]�
exclusionsr%�_onN)�	selectionc���||_||_||_|	|_||_||_||_||_|�|j|�nd|_	|
|_
d|_|j�G|jdk(r|jj|_
n�|jj|_
n�t|jt �r|j|_
n}t|jt"�rJ|j|jjvr(t!|j|j�|_
nt%d|j�d���||_|j)�y)Nrzinvalid on specified as z3, must be a column (of DataFrame), an Index or None)�obj�on�closed�step�window�min_periods�center�win_type�_get_axis_number�axis�method�_win_freq_i8�indexrO�columns�
isinstancer%r�
ValueError�
_selection�	_validate)�selfrRrVrWrXrYr[rSrTrUr\rPs            �E/usr/local/lib/python3.12/site-packages/pandas/core/window/rolling.py�__init__zBaseWindow.__init__s'�������������	����&������ ��
�26�2B�C�(�(��.���	����(,����7�7�?��y�y�A�~��8�8�>�>��� �8�8�+�+���
�����
'��w�w�D�H�
����,�
/�D�G�G�t�x�x�?O�?O�4O��T�X�X�d�g�g�.�/�D�H��*�4�7�7�)�4D�D��
�
$�������c��|j� t|j�std��|j��t	|j�std��|jdkrtd��t	|j
�r>|j|j
kDr%td|j�d|j
����|j�|jdvrtd��t|jttf�std	t|�����t|j
t�r�tj|j
j �j"j%�}tjt�j �j"j%�}||k7r+tt|j
�j&�d
���|j(dvrtd��|j*�;t	|j*�std
��|j*dkrtd��yy)Nzcenter must be a booleanzmin_periods must be an integerrzmin_periods must be >= 0zmin_periods z must be <= window )�right�both�left�neitherz3closed must be 'right', 'left', 'both' or 'neither'zinvalid type: z? does not implement the correct signature for get_window_bounds)�table�singlez!method must be 'table' or 'singlezstep must be an integerzstep must be >= 0)rXrrarWrrVrTr`rRrr�	TypeError�typer �inspect�	signature�get_window_bounds�
parameters�keys�__name__r\rU)rd�get_window_bounds_signature�expected_signatures   rerczBaseWindow._validate�s����;�;�"�7�4�;�;�+?��7�8�8����'��d�.�.�/� �!A�B�B����!�#� �!;�<�<��$�+�+�&�4�+;�+;�d�k�k�+I� �"�4�#3�#3�"4�4G����}�U����;�;�"�t�{�{�;
�(
��R�S�S��$�(�(�Y��$=�>��n�T�$�Z�L�9�:�:��d�k�k�;�/�+2�*;�*;����-�-�+��j����
(�")�!2�!2��
�/�/�"��j����
�+�.@�@� ��D�K�K�(�1�1�2�3B�C����;�;�1�1��@�A�A��9�9� ��d�i�i�(� �!:�;�;��y�y�1�}� �!4�5�5��!rgc	�0�t|�t|�k7r$tdt|��dt|��d���t|�||jxsdzdz
|jxsdzk7r(tdt|��d|�d|j�d���y)	Nzstart (z) and end (z ) bounds must be the same length�zstart and end bounds (z)) must be the same length as the object (z) divided by the step (z) if given and rounded up)�lenrarU)rd�start�end�num_valss    re�_check_window_boundszBaseWindow._check_window_bounds�s����u�:��S��!���#�e�*��[��S��
�;���
��u�:�(�d�i�i�n�1�5��9�t�y�y�~�A�N�N��(��U���5"�"*��+B�4�9�9�+�N*�+��
�Orgc�\�|�t|�t|�k(r|S|dd|j�S)zJ
        Slices the index for a given result and the preset step.
        N)r{rU)rdr^�results   re�_slice_axis_for_stepzBaseWindow._slice_axis_for_step�s9���~��V���E�
�!:�
�	
��|�$�)�)�|�$�	
rgc���|jjdk(rG|rDt|jj�s$t	t|�j�d|�d���yyy)z�
        Validate numeric_only argument, raising if invalid for the input.

        Parameters
        ----------
        name : str
            Name of the operator (kernel).
        numeric_only : bool
            Value passed by user.
        rz�.z  does not implement numeric_onlyN)�
_selected_obj�ndimr�dtype�NotImplementedErrorrprv)rd�name�numeric_onlys   re�_validate_numeric_onlyz!BaseWindow._validate_numeric_only�sg��
���#�#�q�(��$�T�%7�%7�%=�%=�>�%���:�&�&�'�q���.N�O��
�?��
)rgc�0�|jdgdg��}|S)z�Subset DataFrame to numeric columns.

        Parameters
        ----------
        obj : DataFrame

        Returns
        -------
        obj subset to numeric-only columns.
        �numberr)�include�exclude)�
select_dtypes)rdrRr�s   re�_make_numeric_onlyzBaseWindow._make_numeric_onlys"���"�"�H�:��}�"�M���
rgc���|j�`t|jt�sF|jdk(r7|j	|j
j
|jg�d��}|jdkDr"|s|jdk(r|j|�}|jdk(r2|jdd��}|jj�|_
|S)�A
        Split data into blocks & return conformed data.
        �F)r_�copyrz�float64)r�)rSr`r%r��reindexr_�
differencer[r��astype�_mgr�consolidate)rdrRr�s   re�_create_datazBaseWindow._create_datas���
�7�7��z�$�'�'�5�'A�c�h�h�RS�m��+�+�c�k�k�&<�&<�d�g�g�Y�&G�e�+�T�C��8�8�a�<�\�T�Y�Y�!�^��)�)�#�.�C��9�9��>��*�*�Y�U�*�3�C��x�x�+�+�-�C�H��
rgc��|�|j}|jD�cic]}|t||���}}|j||�}t	|�|fd|i|��}|Scc}w)a
        Sub-classes to define. Return a sliced object.

        Parameters
        ----------
        key : str / list of selections
        ndim : {1, 2}
            requested ndim of result
        subset : object, default None
            subset to act on
        rP)rRrM�getattr�_infer_selectionrp)rd�keyr��subset�attr�kwargsrP�new_wins        re�_gotitemzBaseWindow._gotitem#ss���>��X�X�F�9=�8H�8H�I�8H��$���d�+�+�8H��I��)�)�#�v�6�	��$�t�*�V�C�y�C�F�C�����	Js�Ac��||jvrtj||�S||jvr||St	dt|�j�d|�d���)N�'z' object has no attribute ')�_internal_names_set�object�__getattribute__rR�AttributeErrorrprv)rdr�s  re�__getattr__zBaseWindow.__getattr__;sd���4�+�+�+��*�*�4��6�6��4�8�8����:�����T�
�#�#�$�$?��v�Q�G�
�	
rgc�6�|jj�S�N)rR�_dir_additions�rds rer�zBaseWindow._dir_additionsEs���x�x�&�&�(�(rgc����fd��jD�}dj|�}t��j�d|�d�S)z@
        Provide a nice str repr of our rolling object.
        c3�j�K�|]*}t�|d��|ddk7r|�dt�|������,y�w)Nr�_�=)r�)�.0�	attr_namerds  �re�	<genexpr>z&BaseWindow.__repr__.<locals>.<genexpr>LsF�����
�-�	��t�Y��-�9�i��l�c�>Q��k��7�4��3�4�5�-�s�03�,z [�])rM�joinrprv)rd�
attrs_list�attrss`  re�__repr__zBaseWindow.__repr__HsF���
�!�-�-�
�
�
����$���t�*�%�%�&�b���q�1�1rgc#��K�|jj|j�}|j|�}|j	�}|jt
|�|j|j|j|j��\}}|j||t
|��t||�D]"\}}|jt||�}|���$y�w�N��
num_valuesrWrXrTrU)r��set_axisrOr��_get_window_indexerrsr{rWrXrTrUr�zip�iloc�slice)rdrR�indexerr|r}�s�er�s        re�__iter__zBaseWindow.__iter__Ts������ � �)�)�$�(�(�3������$���*�*�,���.�.��3�x��(�(��;�;��;�;����/�
�
��s�	
�!�!�%��c�#�h�7���s�O�D�A�q��X�X�e�A�q�k�*�F��L�$�s�CC!c��t|j�r/tdt|�j�d|j�d���	t|t�r0|jtjtj��}nt|�}tj|�}|j�r%tj |tj|�}|S#ttf$r}td|j���|�d}~wwxYw)z1Convert input to numpy arrays for Cython routineszops for z for this dtype z are not implemented)�na_valuezcannot handle this type -> N)rr�r�rprvr`r�to_numpy�npr��nanrraro�isinf�any�where)rd�values�err�infs    re�_prep_valueszBaseWindow._prep_valuesfs����v�|�|�,�%��4��:�.�.�/�0�����&:�<��
�	S��&�.�1�������b�f�f��E��'��/��
�h�h�v����7�7�9��X�X�c�2�6�6�6�2�F��
���I�&�	S��9�&�,�,��H�I�s�R��	S�s�AC�D
�,D�D
c�X�ddlm}|j��|jj	|j
�s�|jj}||j|jj
|d��}||jvr|||<y||j
jvry||jjvrf|jj}|j}|j|�}|j|d|�}	t|	�}
|j|
||�y|||<yyy)Nr�rEF�r^r�r�)�pandasrErSrO�equalsr^r�rRr_�namesr��get_loc�intersectionr{�insert)rdr�rRrEr��	extra_col�old_cols�new_cols�old_loc�overlap�new_locs           re�_insert_on_columnzBaseWindow._insert_on_column~s���	"��7�7��t�x�x���s�y�y�'A��8�8�=�=�D��t�x�x�t�x�x�~�~�D�u�U�I��v�~�~�%�(��t������+�+�+����+�+�3�3�3��-�-�5�5��!�>�>��"�*�*�4�0��"�/�/���'�0B�C���g�,���
�
�g�t�Y�7� )��t��%(B�rgc�Z�t|jtttf�r|jj
St|jjt�rL|jjjdvr*|jjtj��Sy)N�mM�r�)r`rOr'r$r(�asi8r�r�kindr�r��int64r�s re�_index_arrayzBaseWindow._index_array�sm���d�h�h��m�^� L�M��8�8�=�=� �
������
�
3������8K�8K�t�8S��8�8�$�$�2�8�8�$�4�4�rgc���|jddk(r|jddkDrtd��|jddk(r|jd�S|j||�|S)zValidate and finalize result.rzr�No numeric types to aggregater�)�shaperr�r�)rd�outrRs   re�_resolve_outputzBaseWindow._resolve_output�sa���9�9�Q�<�1�����1���!1��;�<�<��9�9�Q�<�1���:�:�i�(�(����s�C�(��
rgc���t|jt�r|jS|j�,t	|j
|j|j��St|j��S)z[
        Return an indexer class that will compute the window start and end bounds
        )�index_array�window_sizerX)r�)r`rVr r]r#r�rXr!r�s rer�zBaseWindow._get_window_indexer�s_���d�k�k�;�/��;�;�����(�(� �-�-� �-�-��{�{��
�
"�d�k�k�:�:rgc��|j|j�}|dk(rt|�jt�}	|j|j�}||�}|j|j|�}|j|||j��S#ttf$r}td�|�d}~wwxYw)z5
        Series version of _apply_columnwise
        �countr�N�r^r�)r�r�rr��intr��_valuesror�rr�r^�_constructorr�)rd�homogeneous_funcr�rRr�r�r�r^s        re�
_apply_serieszBaseWindow._apply_series�s������� 2� 2�3���7�?���*�#�#�C�(�C�	F��&�&�s�{�{�3�F�"�&�)���)�)�#�)�)�V�<������e�#�(�(��C�C���.�/�	F��;�<�#�E��	F�s�B�B=�,B8�8B=c��|j||�|jjdk(r|j||�S|j	|j|�}|dk(r=t|�j
t�}|jj�|_|jdk(r|j}g}g}t|j��D]A\}}	|j|�}||�}
|j'|
�|j'|��C|j)|j*t-|�dkDr|dnd�}t/|�j1|||j2j5|�d��}|jdk(r|j}|j7||�S#tt f$r}	t#d|j$���|	�d}	~	wwxYw)zl
        Apply the given function to the DataFrame broken down into homogeneous
        sub-frames.
        rzr�z#Cannot aggregate non-numeric type: NrF)r^r_�verify_integrity)r�r�r�r�r�rr�r�r�r�r[�T�	enumerate�_iter_column_arraysr�ror�rr��appendr�r^r{rp�_from_arraysr_�taker�)
rdr�r�r�rR�taker�
res_values�i�arrr��resr^�dfs
             re�_apply_columnwisezBaseWindow._apply_columnwise�s���	
�#�#�D�,�7����"�"�a�'��%�%�&6��=�=����� 2� 2�L�A���7�?���*�#�#�C�(�C��x�x�+�+�-�C�H��9�9��>��%�%�C����
��� 7� 7� 9�:�F�A�s�
��'�'��,��
#�3�'�C����c�"��L�L��O�;��)�)��I�I��J��!�(;�z�!�}��
���#�Y�
#�
#����K�K�$�$�U�+�"�	$�
���9�9��>����B��#�#�B��,�,��+�2�3�
��9�#�)�)��E�����
�s�F+�+G�:G�Gc�b�|jjdk(rtd��|j|j|�}|j	|j��}|jdk(r|jn|}||�}|jdk(r|jn|}|j|j|�}|jdt|j�k(r|jn|jdd|j�}|j|||��}	|j|	|�S)zT
        Apply the given function to the DataFrame across the entire object
        rzz1method='table' not applicable for Series objects.N�r^r_)r�r�rar�r�r�r[rr�r^r�r{r_rUr�r�)
rdr�r�r�rRr�r�r^r_r�s
          re�_apply_tablewisezBaseWindow._apply_tablewises�����"�"�a�'��P�Q�Q����� 2� 2�L�A���"�"�3�<�<�>�2��!�Y�Y�!�^������!�&�)��!�Y�Y�!�^�������)�)�#�)�)�V�<���|�|�A��#�c�k�k�"2�2�
�K�K����\��	�	�\�*�	�
���v�U�G��D���#�#�C��-�-rgc���|j||�}|�	|}|�dn|}nCt|ttf�st	d��|j
dk(r|r|j
|�}t|||t|���S)�]
        Apply the given pairwise function given 2 pandas objects (DataFrame/Series)
        Tz#other must be a DataFrame or Seriesr�)�pairwise)	r�r`rrrar�r�r,�bool)rd�target�otherr�funcr�s      re�_apply_pairwisezBaseWindow._apply_pairwisesy���"�"�6�<�8���=��E�'�/�t�X�H��E�L�)�#<�=��B�C�C�
�Z�Z�1�_���+�+�E�2�E�!�&�%���X��O�Orgc���������j���j��jn�j�d�����fd�}�jdk(r�j	|||�S�j|||�S)a�
        Rolling statistical measure using supplied function.

        Designed to be used with passed-in Cython array-based functions.

        Parameters
        ----------
        func : callable function to apply
        name : str,
        numba_args : tuple
            args to be passed when func is a numba func
        **kwargs
            additional arguments for rolling function and window function

        Returns
        -------
        y : type of input
        c���|jdk(r|j�S�����fd�}tjd��5||�}ddd�|S#1swYSxYw)Nrc�����jt|���j�j�j��\}}�j||t|���|||�g����Sr�)rsr{rXrTrUr)�xr|r}rrW�
numba_argsrd�window_indexers   �����re�calcz9BaseWindow._apply.<locals>.homogeneous_func.<locals>.calcYsi���+�=�=�"�1�v� +��;�;��;�;����>��
��s��)�)�%��c�!�f�=��A�u�c�;�D��D�Drg�ignore��all)�sizer�r��errstate)r�rr�rrWrrdrs   �����rer�z+BaseWindow._apply.<locals>.homogeneous_funcSsY����{�{�a���{�{�}�$�

E�

E�����*��f���+��M�+��M�s�	A�Arn�r��
np.ndarray)r�rWr�r\rr)	rdrr�r�rr�r�rWrs	``  `  @@re�_applyzBaseWindow._apply2s~���4�1�1�3�����+�
����+�+�	�	�	�.�;�;�(�"��)�)�*:�D�,�O�O��(�(�)9�4��N�Nrgc�<�|j�}|j�|jn|j}|j|j�}|j
dk(r|j}|j|j��}|jdk(r|jdd�}|jt|�||j|j|j��\}}	|j!||	t|��t"j$}
t#j&||
fddit)|���}||jf||	|d�|��j}|j
dk(r|jn|}|j+|j,|�}
|jdk(r0|j/�}|j1||
|j2��}|S|j+|j4|j�}|j1||
|��}|j7||�S)	Nrz���r��is_grouped_kernelF)r|r}rWr�r)r�rWr�r�r�r[rr�r�r��reshapersr{rXrTrUrr�float_dtype_mapping�generate_shared_aggregatorr*r�r^�squeezer�r�r_r�)rdr�
engine_kwargs�func_kwargsrrWrRr�r|r}�
dtype_mapping�
aggregatorr�r^r�r_s                re�_numba_applyzBaseWindow._numba_applyos����1�1�3�����+�
����+�+�	�
���� 2� 2�3���9�9��>��%�%�C��"�"�3�<�<�>�2���;�;�!���^�^�B��*�F�#�5�5��6�{�#��;�;��;�;����6�
�
��s�	
�!�!�%��c�&�k�:�
!�4�4�
��8�8���
�$�
� �
�.�	
�
���H�H�
�!�s��
�GR�
�
�!�	�"�Y�Y�!�^�������)�)�#�)�)�V�<���8�8�q�=��^�^�%�F��"�"�6��S�X�X�"�F�C��J��/�/����V�X�X�F�G��"�"�6���"�H�C��'�'��S�1�1rgc�n�t||||��j�}|�|j|d||��S|S)N��argsr�F)�rawr5r�)r�agg�apply�rdrr5r�r�s     re�	aggregatezBaseWindow.aggregate�s<��%�d�D�t�F�K�O�O�Q���>��:�:�d��D��:�H�H��
rg)	NNFNrNNNrn)rRrFrW�
int | NonerX�bool | NonerY�
str | Noner[r?rSzstr | Index | NonerTr=rUr;r\�str�return�None�r?r@)r|r%r}r%r~r�r?r@r�)r^r%r�zSized | Noner?r%)r�r>r�rr?r@)rRr@r?r@�F�rRr@r�rr?r@)r�r>)r?r>)r?r<)r�r>r?r%)r�rDrRrDr?r@)r?znpt.NDArray[np.int64] | None)r�rDrRrDr?rD)r?r )r��Callable[..., ArrayLike]r�r=r?rE)r�rDr�r>r�rr?�DataFrame | Series)NF)r�rDr�r=r�rr?rE�rrEr�DataFrame | Series | Nonerr<rzFCallable[[DataFrame | Series, DataFrame | Series], DataFrame | Series]r�rr?rE�F�)r�Callable[..., Any]r�r>r�rr�tuple[Any, ...])rrJr.�dict[str, bool] | None)"rv�
__module__�__qualname__�__doc__rM�__annotations__�	frozensetrNrfrcrr�r�r�r�r�r�r�r�r�r�r��propertyr�r�r�r�rrrr&r2r:r7rIrgrerKrKxse��A��K���&/�k�J�#�1�	�J�
�"&�#�#��!%�!���+��+�
�+� �	+�
�+��
+��+�
�+��+��+��+�
�+�Z)6�V
��
�&0�
�<?�
�	
�
�
��(��"�0
�)�
2��$�0)�2�����;�NR�D� 8�D�@J�D�	�D�0#�	3-�2�3-��3-��	3-�

�3-�p �"�	.�2�.��.��	.�

�.�4P�"�P�)�P��	P�
U�P��
P�
�P�6#�&(�;O� �;O��;O��	;O�
$�;O�@15�12� �12�.�12�f��CrgrKc���eZdZUdZded<ded<dgZded<dd	�							d�fd
�Z		d									d�fd�
Z												d�fd�Zdd�fd
�
Z	d�fd�	Z
�xZS)�BaseWindowGroupbyz3
    Provide the groupby windowing facilities.
    rH�_grouperr�	_as_indexrLrMT)rVc���ddlm}t||�std��||_||_|j
|jjd��}|jd��td��t�|�,|g|��i|��y)NrrGzMust pass a BaseGrouper object.r�r_�errorsrUz step not implemented for groupby)�pandas.core.groupby.opsrHr`rarUrV�dropr��getr��superrf)rdrRrUrVr5r�rH�	__class__s       �rerfzBaseWindowGroupby.__init__�s|���	8��(�K�0��>�?�?� ��
�"����h�h�t�}�}�2�2�8�h�D���:�:�f��)�%�&H�I�I�
����.�t�.�v�.rgc	���t�|�||||fi|��}|jj}g|j�}tj
|jj�}	|	|z}
|jjD�cgc](}||jjjvs|�|��*}}t|�t|	�k7r|j|d��}|jj}
tj
|jj�}|jjj�}|rtjt|��}n%tj gtj"��}|
D�cgc]}|j%|���}
}|�|j%|�}t'|t(�st)j*|g�}|
j-t|j��|j-t|j��t)||
|
d��}||_|j.s-|j1tt3t|	�����}|Scc}wcc}w)NrrXr�F�r�r�)�level)r]r&rRr^r�r�rUr{r[�codes�levels�indicesr�r��concatenate�list�array�intprr`r&�from_arrays�extendrV�reset_index�range)rdrr�r�rr�r��grouped_object_index�grouped_index_name�groupby_keys�result_index_namesr��drop_columnsrbrc�
group_indicesr��c�idx�result_indexr^s                    �rer&zBaseWindowGroupby._apply�s����������	
�
�
�� $�x�x�~�~��:�3�9�9�:���y�y����!4�!4�5��)�,>�>���}�}�*�*�
�*���$�(�(�.�.�.�.�.�#�+�
�*�	�
��|���L� 1�1��[�[��h�[�G�F��
�
�#�#�����4�=�=�/�/�0���
�
�-�-�4�4�6�
���n�n�T�-�%8�9�G��h�h�r����1�G�*/�0�%�Q������%��0� �+�&�+�+�G�4�C��c�:�.� �,�,�c�U�3���L�L��c�i�i��)��M�M�$�s�z�z�*�+�!��E�!3�e�
��$����~�~��'�'�d�5��\�9J�3K�.L�'�M�F��
��I
��$1s�?-I1�I6c�����|j|jjd��}t�|�|�|||�}���It�fd�|jjj�D���st|�}t|jjj�D�cgc],}|j|�j|j���.c}�}d�|jjj�D�}	g}
g}ttt!|	��D][}t#j$t#j&|�|�}
t)|
�\}}|
j+|�|j+|��]n�|jj,}
|jj.}|jjj�}|rt#j0t|��}n%t#j&gt"j2��}|j4dk(rd}nt|j6�}|
D�cgc]'}t#j$|j|�|���)}
}t9|jt:�r^t|jj,�}t|jj.�}t|jj�}n5t)|j�\}}|g}|g}|jj<g}|
|z}||z}|jj|z}t;|||d��}||_|Scc}wcc}w)	rrrXc3�L�K�|]}t|�t��k(���y�wr�)r{)r��grouprs  �rer�z4BaseWindowGroupby._apply_pairwise.<locals>.<genexpr>s#�����)
�2P��C��J�#�e�*�$�2P�s�!$c3�FK�|]}tj|����y�wr�)�com�maybe_make_list)r��pairs  rer�z4BaseWindowGroupby._apply_pairwise.<locals>.<genexpr>&s �����6R�d��#�#�D�)�6R�s�!r�rzFr`)r[rUr�r]rr!rdr�r{r)rr�r^ru�maprfr�r��repeatrgrrrbrcrerhr�r_r`r&r�)rdrrrrr�r��old_result_len�
gb_indices�gb_pairs�
groupby_codes�groupby_levels�
gb_level_pair�labelsrbrcrrr��	repeat_byrs�result_codes�
result_levels�result_names�	idx_codes�
idx_levelsrur^s  `                       �rerz!BaseWindowGroupby._apply_pairwises�������T�]�]�%8�%8���J����(����$��U����S�)
�26�-�-�2G�2G�2N�2N�2P�)
�&
�!��[�N��'+�m�m�&;�&;�&B�&B�&D��&D�
��K�K�
�+�3�3�F�L�L�A�&D���F��6:�m�m�6K�6K�6P�6P�6R��H��M��N�!$�T�3��>�!:�
����2�8�8�M�#:�N�K�� )�&� 1�
��v��$�$�U�+��%�%�f�-�	";�!�M�M�/�/�M�"�]�]�1�1�N� �M�M�1�1�8�8�:�M���.�.��m�)<�=���(�(�2�R�W�W�5���{�{�a���	�����/�	�?L��?L�!��	�	�!�&�&��/�9�5�}�
���f�l�l�J�/����� 2� 2�3�L� ����!4�!4�5�M����� 2� 2�3�L�$-�f�l�l�$;�!�I�z�%�;�L�'�L�M�"�L�L�-�-�.�L�%�|�3��&��6�
��}�}�*�*�\�9��!��<�|�e�
��$����
��u��Fs�-1M �
,M%c���|jsntjt|jj
j
���jtj�}|j|�}t�|�-||�S)r�)�emptyr�rerfrUrdr�r�r�rr]r�)rdrRr��
groupby_orderr^s    �rer�zBaseWindowGroupby._create_data\sf����y�y��N�N�4��
�
�0E�0E�0L�0L�0N�+O�P�W�W�����M��(�(�=�)�C��w�#�C��6�6rgc���|j�%|jj|j�}t�|�|||��S)N)r�)rSrR�	set_indexrOr]r�)rdr�r�r�r^s    �rer�zBaseWindowGroupby._gotitemjs>����7�7���X�X�'�'����1�F��w���T�&��9�9rg)rRrErUrHrVrr?r@rH)
rrJr�r>r�rrrKr?rErFrBrCr�)rvrMrNrOrPrMrfr&rr�r��
__classcell__�r^s@rerTrT�s��������O�(�\�K��)��/�
�/��	/�
�/�
�/�6#�&(�;� �;��;��	;�
$�;�
�;�zR�"�R�)�R��	R�
U�R��
R�
�R�h7�:�:rgrTc�n��eZdZdZgd�Z�fd�Zd#d�Z		d$							d%d�Zee	de
d�e
d�d	d
��d��ZeZee
ed
�eeed�eed�eed�e
d�ddd��
d&d'd��Zee
ed
�eeed�eed�eed�e
d�ddd��
d&d'd��Zee
ed
�eeed�eed�eed�e
d�ddd��
d(d)d��Zee
ed
�eeed�eed�eed�e
d�dd d!��
d(d)d"��Z�xZS)*�Windowa�
    Provide rolling window calculations.

    Parameters
    ----------
    window : int, timedelta, str, offset, or BaseIndexer subclass
        Size of the moving window.

        If an integer, the fixed number of observations used for
        each window.

        If a timedelta, str, or offset, the time period of each window. Each
        window will be a variable sized based on the observations included in
        the time-period. This is only valid for datetimelike indexes.
        To learn more about the offsets & frequency strings, please see `this link
        <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`__.

        If a BaseIndexer subclass, the window boundaries
        based on the defined ``get_window_bounds`` method. Additional rolling
        keyword arguments, namely ``min_periods``, ``center``, ``closed`` and
        ``step`` will be passed to ``get_window_bounds``.

    min_periods : int, default None
        Minimum number of observations in window required to have a value;
        otherwise, result is ``np.nan``.

        For a window that is specified by an offset, ``min_periods`` will default to 1.

        For a window that is specified by an integer, ``min_periods`` will default
        to the size of the window.

    center : bool, default False
        If False, set the window labels as the right edge of the window index.

        If True, set the window labels as the center of the window index.

    win_type : str, default None
        If ``None``, all points are evenly weighted.

        If a string, it must be a valid `scipy.signal window function
        <https://docs.scipy.org/doc/scipy/reference/signal.windows.html#module-scipy.signal.windows>`__.

        Certain Scipy window types require additional parameters to be passed
        in the aggregation function. The additional parameters must match
        the keywords specified in the Scipy window type method signature.

    on : str, optional
        For a DataFrame, a column label or Index level on which
        to calculate the rolling window, rather than the DataFrame's index.

        Provided integer column is ignored and excluded from result since
        an integer index is not used to calculate the rolling window.

    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.

        .. deprecated:: 2.1.0

            The axis keyword is deprecated. For ``axis=1``,
            transpose the DataFrame first instead.

    closed : str, default None
        If ``'right'``, the first point in the window is excluded from calculations.

        If ``'left'``, the last point in the window is excluded from calculations.

        If ``'both'``, the no points in the window are excluded from calculations.

        If ``'neither'``, the first and last points in the window are excluded
        from calculations.

        Default ``None`` (``'right'``).

    step : int, default None

        .. versionadded:: 1.5.0

        Evaluate the window at every ``step`` result, equivalent to slicing as
        ``[::step]``. ``window`` must be an integer. Using a step argument other
        than None or 1 will produce a result with a different shape than the input.

    method : str {'single', 'table'}, default 'single'

        .. versionadded:: 1.3.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.

    Returns
    -------
    pandas.api.typing.Window or pandas.api.typing.Rolling
        An instance of Window is returned if ``win_type`` is passed. Otherwise,
        an instance of Rolling is returned.

    See Also
    --------
    expanding : Provides expanding transformations.
    ewm : Provides exponential weighted functions.

    Notes
    -----
    See :ref:`Windowing Operations <window.generic>` 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

    **window**

    Rolling sum with a window length of 2 observations.

    >>> df.rolling(2).sum()
         B
    0  NaN
    1  1.0
    2  3.0
    3  NaN
    4  NaN

    Rolling sum with a window span of 2 seconds.

    >>> df_time = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},
    ...                        index=[pd.Timestamp('20130101 09:00:00'),
    ...                               pd.Timestamp('20130101 09:00:02'),
    ...                               pd.Timestamp('20130101 09:00:03'),
    ...                               pd.Timestamp('20130101 09:00:05'),
    ...                               pd.Timestamp('20130101 09:00:06')])

    >>> df_time
                           B
    2013-01-01 09:00:00  0.0
    2013-01-01 09:00:02  1.0
    2013-01-01 09:00:03  2.0
    2013-01-01 09:00:05  NaN
    2013-01-01 09:00:06  4.0

    >>> df_time.rolling('2s').sum()
                           B
    2013-01-01 09:00:00  0.0
    2013-01-01 09:00:02  1.0
    2013-01-01 09:00:03  3.0
    2013-01-01 09:00:05  NaN
    2013-01-01 09:00:06  4.0

    Rolling sum with forward looking windows with 2 observations.

    >>> indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=2)
    >>> df.rolling(window=indexer, min_periods=1).sum()
         B
    0  1.0
    1  3.0
    2  2.0
    3  4.0
    4  4.0

    **min_periods**

    Rolling sum with a window length of 2 observations, but only needs a minimum of 1
    observation to calculate a value.

    >>> df.rolling(2, min_periods=1).sum()
         B
    0  0.0
    1  1.0
    2  3.0
    3  2.0
    4  4.0

    **center**

    Rolling sum with the result assigned to the center of the window index.

    >>> df.rolling(3, min_periods=1, center=True).sum()
         B
    0  1.0
    1  3.0
    2  3.0
    3  6.0
    4  4.0

    >>> df.rolling(3, min_periods=1, center=False).sum()
         B
    0  0.0
    1  1.0
    2  3.0
    3  3.0
    4  6.0

    **step**

    Rolling sum with a window length of 2 observations, minimum of 1 observation to
    calculate a value, and a step of 2.

    >>> df.rolling(2, min_periods=1, step=2).sum()
         B
    0  0.0
    2  3.0
    4  4.0

    **win_type**

    Rolling sum with a window length of 2, using the Scipy ``'gaussian'``
    window type. ``std`` is required in the aggregation function.

    >>> df.rolling(2, win_type='gaussian').sum(std=3)
              B
    0       NaN
    1  0.986207
    2  2.958621
    3       NaN
    4       NaN

    **on**

    Rolling sum with a window length of 2 days.

    >>> df = pd.DataFrame({
    ...     'A': [pd.to_datetime('2020-01-01'),
    ...           pd.to_datetime('2020-01-01'),
    ...           pd.to_datetime('2020-01-02'),],
    ...     'B': [1, 2, 3], },
    ...     index=pd.date_range('2020', periods=3))

    >>> df
                        A  B
    2020-01-01 2020-01-01  1
    2020-01-02 2020-01-01  2
    2020-01-03 2020-01-02  3

    >>> df.rolling('2D', on='A').sum()
                        A    B
    2020-01-01 2020-01-01  1.0
    2020-01-02 2020-01-01  3.0
    2020-01-03 2020-01-02  6.0
    �	rVrWrXrYr[rSrTrUr\c���t�|��t|jt�std|j����t
dd��}t||jd�|_|j�td|j����t|jt�rtd��t|j�r|jdkrtd��|jdk7rtd	��y)
NzInvalid win_type zscipy.signal.windowsz,Scipy is required to generate window weight.)�extraz6BaseIndexer subclasses not implemented with win_types.r�&window must be an integer 0 or greaterrnz+'single' is the only supported method type.)r]rcr`rYr>rarr��_scipy_weight_generatorrVr r�rr\)rd�signalr^s  �rerczWindow._validate|s����
�����$�-�-��-��0�����@�A�A�+�"�*X�
��(/�v�t�}�}�d�'K��$��'�'�/��0�����@�A�A��d�k�k�;�/�%�H��
��$�+�+�&�$�+�+��/��E�F�F��;�;�(�"�%�&S�T�T�#rgc�l�|dkDr.t|d�g}tj|t|��}|S)zT
        Center the result in the window for weighted rolling aggregations.
        rN)r�r�r��tuple)rdr��offset�lead_indexers    re�_center_windowzWindow._center_window�s7���A�:�!�&�$�/�0�L��W�W�V�E�,�$7�8�9�F��
rgc��������j�jfi|����jrt��dz
dznd�d����fd�}�j	|||�dd�j
�S)a+
        Rolling with weights statistical measure using supplied function.

        Designed to be used with passed-in Cython array-based functions.

        Parameters
        ----------
        func : callable function to apply
        name : str,
        numeric_only : bool, default False
            Whether to only operate on bool, int, and float columns
        numba_args : tuple
            unused
        **kwargs
            additional arguments for scipy windows if necessary

        Returns
        -------
        y : type of input
        rzr�rc���|jdk(r|j�S����fd�}tjd��5tj||��}ddd��j
r�j
��}S#1swY�)xYw)Nrc����tjtjg�z�}tj||f�}�|��j��j�St���Sr�)r�rgr�rerWr{)r�additional_nansrr�rdrVs  ����rerz5Window._apply.<locals>.homogeneous_func.<locals>.calc�sk���"$�(�(�B�F�F�8�f�+<�"=���N�N�A��#7�8�����(,�(8�(8�(D�D�$�$���KN�f�+��rgrr )r"r�r�r#�asarrayrXr�)r�rr�rr�rdrVs   ����rer�z'Window._apply.<locals>.homogeneous_func�sp����{�{�a���{�{�}�$�
�����*����D��L�1��+��{�{��,�,�V�V�<���M�+�*�s�B�BNr$)r�rVrXr{rrU)	rdrr�r�rr�r�r�rVs	``     @@rer&z
Window._apply�sv���:.��-�-��K�K�
�!�
��,0�;�;�#�f�+��/�a�'�A��	�	�0�%�%�&6��l�K��t�y�y�L�
�	
rgr:z�
        See Also
        --------
        pandas.DataFrame.aggregate : Similar DataFrame method.
        pandas.Series.aggregate : Similar Series method.
        at
        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.rolling(2, win_type="boxcar").agg("mean")
             A    B    C
        0  NaN  NaN  NaN
        1  1.5  4.5  7.5
        2  2.5  5.5  8.5
        zSeries/DataFrame���see_also�examples�klassr[c�T�t||||��j�}|�||�}|S)Nr4)rr7r9s     rer:zWindow.aggregate�s1��@&�d�D�t�F�K�O�O�Q���>��$�Z�F��
rg�
Parameters�Returns�See Also�Examplesa�        >>> ser = pd.Series([0, 1, 5, 2, 8])

        To get an instance of :class:`~pandas.core.window.rolling.Window` we need
        to pass the parameter `win_type`.

        >>> type(ser.rolling(2, win_type='gaussian'))
        <class 'pandas.core.window.rolling.Window'>

        In order to use the `SciPy` Gaussian window we need to provide the parameters
        `M` and `std`. The parameter `M` corresponds to 2 in our example.
        We pass the second parameter `std` as a parameter of the following method
        (`sum` in this case):

        >>> ser.rolling(2, win_type='gaussian').sum(std=3)
        0         NaN
        1    0.986207
        2    5.917243
        3    6.903450
        4    9.862071
        dtype: float64
        �rollingzweighted window sum�sum��
window_method�aggregation_description�
agg_methodc�N�tj}|j|fd|d�|��S)Nr��r�r�)�window_aggregations�roll_weighted_sumr&�rdr�r��window_funcs    rer�z
Window.sums=��N*�;�;���t�{�{��
��%�
��	
�	
rga�        >>> ser = pd.Series([0, 1, 5, 2, 8])

        To get an instance of :class:`~pandas.core.window.rolling.Window` we need
        to pass the parameter `win_type`.

        >>> type(ser.rolling(2, win_type='gaussian'))
        <class 'pandas.core.window.rolling.Window'>

        In order to use the `SciPy` Gaussian window we need to provide the parameters
        `M` and `std`. The parameter `M` corresponds to 2 in our example.
        We pass the second parameter `std` as a parameter of the following method:

        >>> ser.rolling(2, win_type='gaussian').mean(std=3)
        0    NaN
        1    0.5
        2    3.0
        3    3.5
        4    5.0
        dtype: float64
        zweighted window mean�meanc�N�tj}|j|fd|d�|��S)Nr�r�)r��roll_weighted_meanr&r�s    rer�zWindow.mean4s=��L*�<�<���t�{�{��
��%�
��	
�	
rga�        >>> ser = pd.Series([0, 1, 5, 2, 8])

        To get an instance of :class:`~pandas.core.window.rolling.Window` we need
        to pass the parameter `win_type`.

        >>> type(ser.rolling(2, win_type='gaussian'))
        <class 'pandas.core.window.rolling.Window'>

        In order to use the `SciPy` Gaussian window we need to provide the parameters
        `M` and `std`. The parameter `M` corresponds to 2 in our example.
        We pass the second parameter `std` as a parameter of the following method:

        >>> ser.rolling(2, win_type='gaussian').var(std=3)
        0     NaN
        1     0.5
        2     8.0
        3     4.5
        4    18.0
        dtype: float64
        zweighted window variance�varc��ttj|��}|jdd�|j|fd|d�|��S)N��ddofr�r�r�)rr��roll_weighted_var�popr&)rdr�r�r�r�s     rer�z
Window.varesD��L�1�C�C�$�O���
�
�6�4� ��t�{�{�;�X�U��X�QW�X�Xrga�        >>> ser = pd.Series([0, 1, 5, 2, 8])

        To get an instance of :class:`~pandas.core.window.rolling.Window` we need
        to pass the parameter `win_type`.

        >>> type(ser.rolling(2, win_type='gaussian'))
        <class 'pandas.core.window.rolling.Window'>

        In order to use the `SciPy` Gaussian window we need to provide the parameters
        `M` and `std`. The parameter `M` corresponds to 2 in our example.
        We pass the second parameter `std` as a parameter of the following method:

        >>> ser.rolling(2, win_type='gaussian').std(std=3)
        0         NaN
        1    0.707107
        2    2.828427
        3    2.121320
        4    4.242641
        dtype: float64
        z"weighted window standard deviation�stdc	�@�t|jd|d|d�|���S)Nr�)r�r�r�rI)r-r�)rdr�r�r�s    rer�z
Window.std�s,��L��D�H�H�P�$�U��P��P�
�	
rg)r�r%r�r�r?r%rH)rz,Callable[[np.ndarray, int, int], np.ndarray]r�r>r�rrrKrB�r�r�rzF�r�r�r�r)rvrMrNrOrMrcr�r&rr.rr:r7r3r/r0r1r4r5r�r�r�r�r�r�s@rer�r�ts,���y�v
�K�U�,�#�&(�<
�:�<
��<
��	<
�
$�<
�|	��[�!��
�
��
�
�$!�
�;�>�?�>��C����l�+����i�(���j�)���j�)��
�	
�0 � 5��I%�L

�M%�L

�	���l�+����i�(���j�)���j�)��
�	
�. � 6��G$�J

�K$�J

�	���l�+����i�(���j�)���j�)��
�	
�. � :��G$�JY�K$�JY�
	���l�+����i�(���j�)���j�)��
�	
�. � D��G$�J
�K$�J
rgr�c��eZdZddd�Z					d											dd�Z										dd�Z			d					dd�Z			d					dd�Z			d					dd�Z			d					dd�Z				d					dd	�Z
				d							dd
�Z				d							dd�Zddd�Z
ddd
�Zddd�Z		d					dd�Z				d 							d!d�Z				d"							d#d�Z				d"							d#d�Zy)$�RollingAndExpandingMixinc�J�tj}|j|d|��S)Nr�r�)r��roll_sumr&�rdr�r�s   rer�zRollingAndExpandingMixin.count�s"��)�2�2���{�{�;�W�<�{�P�PrgNc�~�|�d}|�i}t|�std��d}t|�rN|durtd��|}|jdk(rt	|fit||���}nHt
|fit||���}n1|dvr"|�td��|j||||�}ntd��|j|d	|�
�S)NrIz'raw parameter must be `True` or `False`Fz.raw must be `True` when using the numba enginern)�cythonNz+cython engine does not accept engine_kwargsz)engine must be either 'numba' or 'cython'r8)r�r)	rrar+r\r9r*r:�_generate_cython_apply_funcr&)	rdrr6�enginer.r5r�r�
apply_funcs	         rer8zRollingAndExpandingMixin.apply�s����<��D��>��F��s�|��F�G�G�&(�
��6�"��e�|� �!Q�R�R��J��{�{�h�&�6���-�m�V�D��
�7���-�m�V�D��
��'�
'��(� �!N�O�O��9�9�$���T�R�J��H�I�I��{�{���!��
�	
rgc�f����ddlm�ttj||||���|f���fd�	}|S)Nrr�)r5r�r6�functionc�H��|s�|�jd��}�||||�S)NF)r^r�)rO)r��beginr}rWr6rErdr�s     ���rer�zHRollingAndExpandingMixin._generate_cython_apply_func.<locals>.apply_func�s)������d�h�h�U�C���v�u�c�;�?�?rg)r�rErr��
roll_apply)rdr5r�r6r�r�rEr�s`     @@rer�z4RollingAndExpandingMixin._generate_cython_apply_func�s;���	"���*�*�����
��=@�	@��rgc�
�t|�rU|jdk(r.ttj�}|j|d||��Sddlm}|j||�Stj}|j|d|��S)NrmT�r6r�r.r)�sliding_sumr�r�)r+r\r8r��nansumr8�pandas.core._numba.kernelsr�r2r�r�r&)rdr�r�r.rr�r�s       rer�zRollingAndExpandingMixin.sums����6�"��{�{�g�%�>�r�y�y�I���z�z���!�"/�	"���C��(�(��m�D�D�)�2�2���{�{�;�U��{�N�Nrgc��t|�rW|jdk(r.ttj�}|j|d||��Sddlm}|j||d��Stj}|j|d|��S)	NrmTr�r��sliding_min_max��is_max�maxr�)r+r\r8r��nanmaxr8r�r�r2r��roll_maxr&�rdr�r�r.rr�r�s       rer�zRollingAndExpandingMixin.maxs����6�"��{�{�g�%�>�r�y�y�I���z�z���!�"/�	"���G��(�(��-�PT�(�U�U�)�2�2���{�{�;�U��{�N�Nrgc��t|�rW|jdk(r.ttj�}|j|d||��Sddlm}|j||d��Stj}|j|d|�	�S)
NrmTr�rr�Fr��minr�)r+r\r8r��nanminr8r�r�r2r��roll_minr&r�s       rer�zRollingAndExpandingMixin.min/s����6�"��{�{�g�%�>�r�y�y�I���z�z���!�"/�	"���G��(�(��-�PU�(�V�V�)�2�2���{�{�;�U��{�N�Nrgc�
�t|�rU|jdk(r.ttj�}|j|d||��Sddlm}|j||�Stj}|j|d|��S)NrmTr�r)�sliding_meanr�r�)r+r\r8r��nanmeanr8r�r�r2r��	roll_meanr&)rdr�r�r.rr�r�s       rer�zRollingAndExpandingMixin.meanEs����6�"��{�{�g�%�>�r�z�z�J���z�z���!�"/�	"���D��(�(��}�E�E�)�3�3���{�{�;�V�,�{�O�Orgc��t|�rN|jdk(rttj�}ntj}|j|d||��Stj}|j|d|��S)NrmTr��medianr�)	r+r\r8r��	nanmedianr8r��
roll_median_cr&)rdr�r�r.rr�s      rer�zRollingAndExpandingMixin.median[ss���6�"��{�{�g�%�>�r�|�|�L���|�|���:�:����+�	��
�*�7�7���{�{�;�X�L�{�Q�Qrgc�����t|�r=|jdk(rtd��ddlm}t|j
||����Stj���fd�}|j|d|��S)	Nrmz%std not supported with method='table'r��sliding_varr�c	�0��t�||||����S)Nr�)r-)r�r�r}rWr�r�s    ��re�
zsqrt_funcz0RollingAndExpandingMixin.std.<locals>.zsqrt_funcs�����V�U�C��4�P�Q�Qrgr�r�)
r+r\r�r�r�r-r2r��roll_varr&)rdr�r�r�r.r�r�r�s `     @rer�zRollingAndExpandingMixin.stdpsw����6�"��{�{�g�%�)�*Q�R�R�>���*�*�;�
�D�*�Q�R�R�)�2�2��	R��{�{���%��
�	
rgc���t|�r4|jdk(rtd��ddlm}|j|||��St
tj|��}|j|d|��S)Nrmz%var not supported with method='table'rr�r�r�r�)
r+r\r�r�r�r2rr�r�r&)rdr�r�r�r.r�r�s       rer�zRollingAndExpandingMixin.var�sq���6�"��{�{�g�%�)�*Q�R�R�>��$�$�[�-�d�$�K�K��1�:�:��F���{�{���%��
�	
rgc�J�tj}|j|d|��S)N�skewr�)r��	roll_skewr&r�s   rer�zRollingAndExpandingMixin.skew��,��)�3�3���{�{���%��
�	
rgc��|jd|�|j|��|j|��|z
jd�zS�N�sem�r���?�r�r�r��pow�rdr�r�s   rer�zRollingAndExpandingMixin.sem�sF���#�#�E�<�8��x�x�\�x�2��J�J�L�J�1�D�8�

�#�c�(��	rgc�J�tj}|j|d|��S)N�kurtr�)r��	roll_kurtr&r�s   rerzRollingAndExpandingMixin.kurt�r�rgc��|dk(rtj}n2|dk(rtj}nttj||��}|j|d|��S)Ng�?g)�quantile�
interpolationr	r�)r�r�r�r�
roll_quantiler&)rd�qr
r�r�s     rer	z!RollingAndExpandingMixin.quantile�sX��
��8�-�6�6�K�
�#�X�-�6�6�K�!�#�1�1��+��K��{�{�;�Z�l�{�S�Srgc�d�ttj|||��}|j|d|��S)N)r\�	ascending�
percentile�rankr�)rr��	roll_rankr&)rdr\r�pctr�r�s      rerzRollingAndExpandingMixin.rank�s7����)�)����	
���{�{�;�V�,�{�O�Orgc������j�td���jd|�ddlm����fd�}�j�j||||�S)Nzstep not implemented for cov�covrr�c�8���j|�}�j|�}�j�}�j��jn|j}|j	t|�|�j�j�j��\}}�j||t|��tjd��5tj||z|||�}tj||||�}	tj||||�}
tjt||z�j!tj"�||d�}||	|
zz
||�z
zz}ddd��
|j$|j&d��S#1swY�)xYw)Nr�rr rFr�)r�r�rWr�rsr{rXrTrUrr�r#r�r�r�rr�r�r^r�)r�y�x_array�y_arrayrrWr|r}�mean_x_y�mean_x�mean_y�	count_x_yr�rEr�rds             ���re�cov_funcz.RollingAndExpandingMixin.cov.<locals>.cov_func�s}����'�'��*�G��'�'��*�G�!�5�5�7�N��#�#�/�� � �#�/�/�
�
(�9�9��w�<�'��{�{��{�{��Y�Y�:��J�E�3�
�%�%�e�S�#�g�,�?�����*�.�8�8��g�%�u�c�;���-�6�6�w��s�K�X��,�6�6�w��s�K�X��/�8�8��'�G�+�,�3�3�B�J�J�?���Q��	�#�V�f�_�4��i�RV�FV�9W�X��+��&����a�f�f�5�I�I�+�*�s
�
BF�F�rUr�r�r�rErr�)rdrrr�r�rrEs`  `  @rerzRollingAndExpandingMixin.cov�sZ����9�9� �%�&D�E�E��#�#�E�<�8�!�	J�<�#�#�����x��<�
�	
rgc������j�td���jd|�ddlm����fd�}�j�j||||�S)Nzstep not implemented for corr�corrrr�c����j|�}�j|�}�j�}�j��jn|j}|j	t|�|�j�j�j��\}}�j||t|��tjd��5tj||z|||�}tj||||�}	tj||||�}
tjt||z�j!tj"�||d�}tj$||||��}tj$||||��}
||	|
zz
||�z
zz}||
zdz}||z}ddd��|j&|j(d��S#1swY�)xYw)Nr�rr rrFr�)r�r�rWr�rsr{rXrTrUrr�r#r�r�r�rr�r�r�r^r�)rrrrrrWr|r}rrrr�x_var�y_var�	numerator�denominatorr�rEr�rds                 ���re�	corr_funcz0RollingAndExpandingMixin.corr.<locals>.corr_funcs�����'�'��*�G��'�'��*�G�!�5�5�7�N��#�#�/�� � �#�/�/�
�
(�9�9��w�<�'��{�{��{�{��Y�Y�:��J�E�3�
�%�%�e�S�#�g�,�?�����*�.�8�8��g�%�u�c�;���-�6�6�w��s�K�X��,�6�6�w��s�K�X��/�8�8��'�G�+�,�3�3�B�J�J�?���Q��	�,�4�4��U�C��d���,�4�4��U�C��d���&����7���T�!1�2��	� %�u�}��4��"�[�0��'+�(�&����a�f�f�5�I�I�)+�*�s
�
CG�Gr)rdrrr�r�r&rEs`  `  @rer zRollingAndExpandingMixin.corrs[����9�9� �%�&E�F�F��#�#�F�L�9�!�&	J�P�#�#�����x��L�
�	
rgrBr��FNNNN�rrJr6rr��!Literal['cython', 'numba'] | Noner.rLr5ztuple[Any, ...] | Noner�zdict[str, Any] | None)
r5rKr�zdict[str, Any]r6zbool | np.bool_r�rJr?z?Callable[[np.ndarray, np.ndarray, np.ndarray, int], np.ndarray]�FNN�r�rr�r)r.rL�rzFNN�r�r�r�rr�r)r.rLr�r���linearF�r�floatr
rAr�r��averageTFF�r\rBrrrrr�r�NNrzF�rrGrr<r�r�r�r)rvrMrNr�r8r�r�r�r�r�r�r�r�r�r�rr	rrr rIrgrer�r��s���Q��48�04�'+�(,�)
� �)
��)
�2�	)
�
.�)
�%�
)
�&�)
�V������	�
%��
I�
�6#�48�04�	O��O�2�O�.�	O�0#�48�04�	O��O�2�O�.�	O�0#�48�04�	O��O�2�O�.�	O�0#�48�04�	P��P�2�P�.�	P�0#�48�04�	R��R�2�R�.�	R�.�"�48�04�
��
��
�2�	
�
.�
�4�"�48�04�
��
��
�2�	
�
.�
�(
��
�08�"�	T��T�-�T��	T�*%.���"�P�!�P��P��	P�
�P�$,0� $��"�-
�(�-
��-
��	-
�
�-
�b,0� $��"�7
�(�7
��7
��	7
�
�7
rgr�c��
��eZdZUgd�Zded<�fd�Zdgd�Zdhd�Zee	de
d�e
d	�d
d���fd
��ZeZee
ed�eed�eed�eed�e
d�j%ddd�ddd��didj�fd�
�Zee
ed�eed�eed�eed�e
d�ddd��					dk											dl�fd�
�Zee
ed�ee�ed�eed�eed�eed�e
d �j%ddd�dd!d!��			dm					dn�fd"�
�Zee
ed�ee�ed�eed�eed�eed�e
d#�dd$d%��	diddd&�					dn�fd'��Zee
ed�ee�ed�eed�eed�eed�e
d(�j%ddd�dd)d*��			dm					dn�fd+�
�Zee
ed�ee�ed�eed�eed�eed�e
d,�j%ddd�dd-d-��			dm					dn�fd.�
�Zee
ed�ee�ed�eed�eed�eed�e
d/�j%ddd�dd0d0��			dm					dn�fd1�
�Zee
ed�e
d2�j%ddd�eed3�ed�eed�d4eed�e
d5�j%ddd�ed�e
d6�j%ddd�dd7d8��				do							dp�fd9�
�Zee
ed�e
d2�j%ddd�eed3�ed�eed�d:eed�e
d;�j%ddd�ed�e
d<�j%ddd�dd=d>��				do							dp�fd?�
�Zee
ed�eed�eed�d@eed�e
dA�ed�e
dB�ddCdD��didj�fdE�
�Zee
ed�e
d2�j%ddd�eed�eed�eed�dFed�e
dG�j%ddd�ddHdI��dqdrdJ��Z ee
ed�eed�eed�dKeed�dLed�e
dM�j%ddd�ddNdO��didj�fdP�
�Z!ee
ed�e
dQ�j%ddd�eed�eed�eed�e
dR�j%ddd�ddSdS��
e"dSdT�U�		ds					dt�fdV�
��Z#ee
dWed�e
dX�j%ddd�eed�eed�eed�e
dY�j%ddd�ddZdZ��				du							dv�fd[�
�Z$ee
ed�e
d\�j%ddd�eed�eed�eed�e
d]�dd^d_��
				dw							dx�fd`�
�Z%ee
ed�e
d\�j%ddd�eed�eed�e
da�j%ddd�eed�e
db�j%ddd�ed�e
dc�j%ddd�dddde��				dw							dx�fdf�
�Z&�xZ'S)y�Rollingr�rLrMc���t�|��|jjsmt	|j
tttf�sHt	|j
jt��r[|j
jjdv�r8t	|jtttf��r|j!�	t#|j�}t	|j
t�rT|j(|j
j*j(|j
j*j,zz|_nS	t1|j
j�}t3|j(�j5|�j6|_|j8�d|_|j:�t=d��yt	|jt>�rytA|j�r|jdkrt'd��y#t$t&f$r}t'd|j�d��|�d}~wwxYw#t$$rd}Y��wxYw)	Nr�zpassed window z, is not compatible with a datetimelike index�nsrzz,step is not supported with frequency windowsrr�)!r]rcrRr�r`rOr$r(r'r�rr�rVr>rr� _validate_datetimelike_monotonicr
rora�nanos�freq�nr]rIr�as_unit�_valuerWrUr�r r)rdr=r��unitr^s    �rerczRolling._validateLs����
����
�H�H�N�N��$�(�(�]�N�K�$P�Q��4�8�8�>�>�:�6�4�8�8�>�>�;N�;N�RV�;V�����s�J�	�&B�C��1�1�3�
� ����-���$�(�(�K�0�%)�J�J��H�H�M�M�'�'�$�(�(�-�-�/�/�9�%��!� �(������8�D�%.�d�j�j�$9�$A�$A�$�$G�$N�$N��!����'�#$�� ��y�y�$�)�B���%�
����[�
1���D�K�K�(�D�K�K�!�O��E�F�F�-<��?�z�*�
� �$�T�[�[�M�2;�;�����
��!� ��D� �s*�
H�I�I�%H?�?I�I�Ic���|jjr|jd�|jjs)|jjs|jd�yyy)z�
        Validate self._on is monotonic (increasing or decreasing) and has
        no NaT values for frequency windows.
        �values must not have NaTzvalues must be monotonicN)rO�hasnans�_raise_monotonic_error�is_monotonic_increasing�is_monotonic_decreasingr�s rer;z(Rolling._validate_datetimelike_monotonic|sQ��
�8�8����'�'�(B�C����0�0�D�H�H�4T�4T��'�'�(B�C�5U�0rgc�f�|j}|�|jdk(rd}nd}t|�d|����)Nrr^�column� )rSr[ra)rd�msgrSs   rerEzRolling._raise_monotonic_error�s:��
�W�W��
�:��y�y�A�~������B�4�q����'�'rgr:z�
        See Also
        --------
        pandas.Series.rolling : Calling object with Series data.
        pandas.DataFrame.rolling : Calling object with DataFrame data.
        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.rolling(2).sum()
             A     B     C
        0  NaN   NaN   NaN
        1  3.0   9.0  15.0
        2  5.0  11.0  17.0

        >>> df.rolling(2).agg({"A": "sum", "B": "min"})
             A    B
        0  NaN  NaN
        1  3.0  4.0
        2  5.0  5.0
        zSeries/Dataframer�r�c�*��t�|�|g|��i|��Sr�)r]r:)rdrr5r�r^s    �rer:zRolling.aggregate�s ���L�w� ��7��7��7�7rgr�r�r�r�a�
        >>> s = pd.Series([2, 3, np.nan, 10])
        >>> s.rolling(2).count()
        0    NaN
        1    2.0
        2    1.0
        3    1.0
        dtype: float64
        >>> s.rolling(3).count()
        0    NaN
        1    NaN
        2    2.0
        3    2.0
        dtype: float64
        >>> s.rolling(4).count()
        0    NaN
        1    NaN
        2    NaN
        3    3.0
        dtype: float64
        �
rzr�zcount of non NaN observationsr�r�c�"��t�|�|�Sr�)r]r��rdr�r^s  �rer�z
Rolling.count�s���J�w�}�\�*�*rgz�        >>> ser = pd.Series([1, 6, 5, 4])
        >>> ser.rolling(2).apply(lambda s: s.sum() - s.min())
        0    NaN
        1    6.0
        2    6.0
        3    5.0
        dtype: float64
        zcustom aggregation functionr8Nc�.��t�|�||||||��S)N)r6r�r.r5r�)r]r8)rdrr6r�r.r5r�r^s       �rer8z
Rolling.apply�s.���B�w�}����'���
�
�	
rg�Notesa]
        >>> s = pd.Series([1, 2, 3, 4, 5])
        >>> s
        0    1
        1    2
        2    3
        3    4
        4    5
        dtype: int64

        >>> s.rolling(3).sum()
        0     NaN
        1     NaN
        2     6.0
        3     9.0
        4    12.0
        dtype: float64

        >>> s.rolling(3, center=True).sum()
        0     NaN
        1     6.0
        2     9.0
        3    12.0
        4     NaN
        dtype: float64

        For DataFrame, each sum is computed column-wise.

        >>> df = pd.DataFrame({{"A": s, "B": s ** 2}})
        >>> df
           A   B
        0  1   1
        1  2   4
        2  3   9
        3  4  16
        4  5  25

        >>> df.rolling(3).sum()
              A     B
        0   NaN   NaN
        1   NaN   NaN
        2   6.0  14.0
        3   9.0  29.0
        4  12.0  50.0
        r�c�(��t�|�|||��S�N)r�r�r.)r]r��rdr�r�r.r^s    �rer�zRolling.sum
s%���J�w�{�%��'��
�	
rgz�        >>> ser = pd.Series([1, 2, 3, 4])
        >>> ser.rolling(2).max()
        0    NaN
        1    2.0
        2    3.0
        3    4.0
        dtype: float64
        �maximumr�)r�r.c�(��t�|�|||��SrS)r]r�)rdr�r�r.r5r�r^s      �rer�zRolling.maxUs%���F�w�{�%��'��
�	
rgz�
        Performing a rolling minimum with a window size of 3.

        >>> s = pd.Series([4, 3, 5, 2, 6])
        >>> s.rolling(3).min()
        0    NaN
        1    NaN
        2    3.0
        3    2.0
        4    2.0
        dtype: float64
        �minimumr�c�(��t�|�|||��SrS)r]r�rTs    �rer�zRolling.min~s%���H�w�{�%��'��
�	
rga�
        The below examples will show rolling mean calculations with window sizes of
        two and three, respectively.

        >>> s = pd.Series([1, 2, 3, 4])
        >>> s.rolling(2).mean()
        0    NaN
        1    1.5
        2    2.5
        3    3.5
        dtype: float64

        >>> s.rolling(3).mean()
        0    NaN
        1    NaN
        2    2.0
        3    3.0
        dtype: float64
        r�c�(��t�|�|||��SrS)r]r�rTs    �rer�zRolling.mean�s%���V�w�|�%��'��
�	
rga
        Compute the rolling median of a series with a window size of 3.

        >>> s = pd.Series([0, 1, 2, 3, 4])
        >>> s.rolling(3).median()
        0    NaN
        1    NaN
        2    1.0
        3    2.0
        4    3.0
        dtype: float64
        r�c�(��t�|�|||��SrS)r]r�rTs    �rer�zRolling.median�s%���H�w�~�%��'��
�	
rgz�
        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.
z�
        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.

        a

        >>> s = pd.Series([5, 5, 6, 7, 5, 5, 5])
        >>> s.rolling(3).std()
        0         NaN
        1         NaN
        2    0.577350
        3    1.000000
        4    1.000000
        5    1.154701
        6    0.000000
        dtype: float64
        zstandard deviationr�c�*��t�|�||||��S�N)r�r�r�r.)r]r��rdr�r�r�r.r^s     �rer�zRolling.std	�(���h�w�{��%��'�	�
�	
rgz/numpy.var : Equivalent method for NumPy array.
z�
        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.rolling(3).var()
        0         NaN
        1         NaN
        2    0.333333
        3    1.000000
        4    1.000000
        5    1.333333
        6    0.000000
        dtype: float64
        �variancer�c�*��t�|�||||��Sr\)r]r�r]s     �rer�zRolling.var>	r^rgz:scipy.stats.skew : Third moment of a probability density.
zV
        A minimum of three periods is required for the rolling calculation.

        z�        >>> ser = pd.Series([1, 5, 2, 7, 15, 6])
        >>> ser.rolling(3).skew().round(6)
        0         NaN
        1         NaN
        2    1.293343
        3   -0.585583
        4    0.670284
        5    1.652317
        dtype: float64
        zunbiased skewnessr�c�$��t�|�|��S�Nr)r]r�rOs  �rer�zRolling.skewy	s���D�w�|��|�6�6rgz:A minimum of one period is required for the calculation.

z�
        >>> s = pd.Series([0, 1, 2, 3])
        >>> s.rolling(2, min_periods=1).sem()
        0         NaN
        1    0.707107
        2    0.707107
        3    0.707107
        dtype: float64
        zstandard error of meanr�c��|jd|�|j|��|j|�|z
jd�zSr�rrs   rer�zRolling.sem�	sG��F	
�#�#�E�<�8��x�x�\�x�2��J�J�|�$�t�+�

�#�c�(��	rgz/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[1:], bias=False):.6f}}")
        3.999946
        >>> s = pd.Series(arr)
        >>> s.rolling(4).kurt()
        0         NaN
        1         NaN
        2         NaN
        3   -1.200000
        4    3.999946
        dtype: float64
        z,Fisher's definition of kurtosis without biasrc�$��t�|�|��Srb)r]rrOs  �rerzRolling.kurt�	s���L�w�|��|�6�6rga�
        quantile : float
            Quantile to compute. 0 <= quantile <= 1.

            .. deprecated:: 2.1.0
                This will be renamed to 'q' in a future version.
        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.
        ae
        >>> s = pd.Series([1, 2, 3, 4])
        >>> s.rolling(2).quantile(.4, interpolation='lower')
        0    NaN
        1    1.0
        2    2.0
        3    3.0
        dtype: float64

        >>> s.rolling(2).quantile(.4, interpolation='midpoint')
        0    NaN
        1    1.5
        2    2.5
        3    3.5
        dtype: float64
        r	r)�old_arg_name�new_arg_namec�(��t�|�|||��S)N)rr
r�)r]r	)rdrr
r�r^s    �rer	zRolling.quantile�	s&���r�w���'�%� �
�	
rgz.. 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.rolling(3).rank()
        0    NaN
        1    NaN
        2    2.0
        3    2.0
        4    3.0
        5    1.5
        dtype: float64

        >>> s.rolling(3).rank(method="max")
        0    NaN
        1    NaN
        2    2.0
        3    2.0
        4    3.0
        5    2.0
        dtype: float64

        >>> s.rolling(3).rank(method="min")
        0    NaN
        1    NaN
        2    2.0
        3    2.0
        4    3.0
        5    1.0
        dtype: float64
        rc�*��t�|�||||��S)N)r\rrr�)r]r)rdr\rrr�r^s     �rerzRolling.rank,
s(���H�w�|����%�	�
�	
rga
        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.
        z�        >>> ser1 = pd.Series([1, 2, 3, 4])
        >>> ser2 = pd.Series([1, 4, 5, 8])
        >>> ser1.rolling(2).cov(ser2)
        0    NaN
        1    1.5
        2    0.5
        3    1.5
        dtype: float64
        zsample covariancerc�*��t�|�||||��S�N)rrr�r�)r]r�rdrrr�r�r^s     �rerzRolling.covw
s(���b�w�{����%�	�
�	
rgz�
        cov : Similar method to calculate covariance.
        numpy.corrcoef : NumPy Pearson's correlation calculation.
        ao
        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.

        ax
        The below example shows a rolling calculation with a window size of
        four matching the equivalent function call using :meth:`numpy.corrcoef`.

        >>> v1 = [3, 3, 3, 5, 8]
        >>> v2 = [3, 4, 4, 4, 8]
        >>> np.corrcoef(v1[:-1], v2[:-1])
        array([[1.        , 0.33333333],
               [0.33333333, 1.        ]])
        >>> np.corrcoef(v1[1:], v2[1:])
        array([[1.       , 0.9169493],
               [0.9169493, 1.       ]])
        >>> s1 = pd.Series(v1)
        >>> s2 = pd.Series(v2)
        >>> s1.rolling(4).corr(s2)
        0         NaN
        1         NaN
        2         NaN
        3    0.333333
        4    0.916949
        dtype: float64

        The below example shows a similar rolling calculation on a
        DataFrame using the pairwise option.

        >>> matrix = np.array([[51., 35.],
        ...                    [49., 30.],
        ...                    [47., 32.],
        ...                    [46., 31.],
        ...                    [50., 36.]])
        >>> np.corrcoef(matrix[:-1, 0], matrix[:-1, 1])
        array([[1.       , 0.6263001],
               [0.6263001, 1.       ]])
        >>> np.corrcoef(matrix[1:, 0], matrix[1:, 1])
        array([[1.        , 0.55536811],
               [0.55536811, 1.        ]])
        >>> df = pd.DataFrame(matrix, columns=['X', 'Y'])
        >>> df
              X     Y
        0  51.0  35.0
        1  49.0  30.0
        2  47.0  32.0
        3  46.0  31.0
        4  50.0  36.0
        >>> df.rolling(4).corr(pairwise=True)
                    X         Y
        0 X       NaN       NaN
          Y       NaN       NaN
        1 X       NaN       NaN
          Y       NaN       NaN
        2 X       NaN       NaN
          Y       NaN       NaN
        3 X  1.000000  0.626300
          Y  0.626300  1.000000
        4 X  1.000000  0.555368
          Y  0.555368  1.000000
        �correlationr c�*��t�|�||||��Srj)r]r rks     �rer zRolling.corr�
s(���|�w�|����%�	�
�	
rgrA)rKr>rBr�r'r(r*r+r,r-r�r�r.r0r2r4r5r6)(rvrMrNrMrPrcr;rErr.rr:r7r3r/r0r4r5�replacer�r7r8r6r2r�r�r�r�r�r�r�r�r�rrr	rrr r�r�s@rer8r8?sd���
�K��
�.G�`D�(�	��[�!��
�
��
�
�0!�
�G$�J8�K$�J8��C����l�+���i�(���j�)���j�)��
�	
�,�'�$��A�
�� ?��E#�H+�I#�H+�	���l�+���i�(���j�)���j�)��
�
	
� � =��-�6�48�04�'+�(,�
� �
��
�2�	
�
.�
�%�

�&�
�1�0
�$	���l�+��#�%��i�(���j�)���g�&���j�)��,
�.	
�\�'�$��A�
�� %��{>�B#�48�04�	

��

�2�

�.�	

�>�~

�	���l�+��#�%��i�(���j�)���g�&���j�)��
�
	
� � )��3�:#�
�59�04�
��
�2�	
�
.�
�7�6
�	���l�+��#�%��i�(���j�)���g�&���j�)��
�
	
��'�$��A�
�� )��9�@#�48�04�	

��

�2�

�.�	

�=�<

�	���l�+��#�%��i�(���j�)���g�&���j�)��
�	
�(�'�$��A�
�� &��G$�N#�48�04�	

��

�2�

�.�	

�K$�J

�	���l�+��#�%��i�(���j�)���g�&���j�)��
�
	
��'�$��A�
�� (��9�@#�48�04�	

��

�2�

�.�	

�=�<

�	���l�+��
�	
��'�$��A�
��#�E�*��i�(���j�)�:���g�&��
�	
��'�$��A�
��j�)��
�
	
��'�$��A�
�� 4��W,�^�"�48�04�
��
��
�2�	
�
.�
�[,�Z
�	���l�+��
�	
��'�$��A�
��#�E�*��i�(���j�)�:���g�&��
�	
��'�$��A�
��j�)��
�
	
��'�$��A�
�� *��W,�^�"�48�04�
��
��
�2�	
�
.�
�[,�Z
�	���l�+���i�(���j�)�E���g�&��
�	
�
	�j�)��

�	
� � 3��? �B7�C �B7�	���l�+��
�	
��'�$��A�
���i�(���j�)���g�&�F��j�)��
�
	
��'�$��A�
�� 8��? �B�C �B�	���l�+���i�(���j�)�:���g�&�H��j�)��
�	
�(�'�$��A�
�� N��G$�J7�K$�J7�	���l�+��
�	
�$�'�$��A�
���i�(���j�)���j�)��
�	
�"�'�$��A�
�� *��a1�d�*�3�?�08�"�	

��

�-�

��	

�@�e1�f

�	��&��l�+��

�	
��'�$��A�
���i�(���j�)���j�)��
�	
�<�'�$��A�
�� &��w<�~%.���"�
�!�
��
��	
�
�
�{<�z
�	���l�+��
�	
� �'�$��A�
���i�(���j�)���j�)��	
�	
� � 3��Q)�X,0� $��"�
�(�
��
��	
�
�
�U)�T
�	���l�+��
�	
� �'�$��A�
���i�(���j�)��
�	
�
�'�$��A�
���g�&��
�	
�,�'�$��A�
��j�)��8
�:	
�t�'�$��A�
�� -��kv�r,0� $��"�
�(�
��
��	
�
�
�ov�n
rgr8c�P�eZdZdZej
ej
zZdd�Zd�Zy)�RollingGroupbyz3
    Provide a rolling groupby implementation.
    c���d}|j}t|jt�rjt	|j�}|jj
j
�}t|t�sJ�|jdd�|j}n1|j�t}|j}nt}|j}t|||jj||��}|S)z�
        Return an indexer class that will compute the window start and end bounds

        Returns
        -------
        GroupbyIndexer
        Nr�)r�r��groupby_indicesr�indexer_kwargs)r�r`rVr rp�__dict__r��dictr�r]r#r!r"rUrd)rdrsr��rolling_indexerrVrs      rer�z"RollingGroupby._get_window_indexer?s���15���'�'���d�k�k�;�/�"�4�;�;�/�O�!�[�[�1�1�6�6�8�N��n�d�3�3�3����}�d�3��[�[�F�
�
�
�
*�3�O��&�&�F�0�O��[�[�F�'�#�� �M�M�1�1�*�)�
���rgc�d�|jjr|jd�|jjj�D]b}|jj
|�}|jr�+|jr�8|j�dn|j}td|�d|�d���y)zC
        Validate that each group in self._on is monotonic
        rCNr^zEach group within z' must be monotonic. Sort the values in z first.)rOrDrErUrdr�rrFrGrSra)rdrr�group_onrSs    rer;z/RollingGroupby._validate_datetimelike_monotonicbs���
�8�8����'�'�(B�C�!�]�]�2�2�9�9�;�M��x�x�}�}�]�3�H��0�0�H�4T�4T� $����W�T�W�W�� �(���-*�*,��W�6���
<rgN)r?r")	rvrMrNrOr8rMrTr�r;rIrgrerprp8s+����%�%�(9�(E�(E�E�K�!�Frgrp)yrO�
__future__rr��datetimer�	functoolsrrq�textwrapr�typingrrr	r
�numpyr��pandas._libs.tslibsrrr
� pandas._libs.window.aggregations�_libsrV�aggregationsr��pandas.compat._optionalr�
pandas.errorsr�pandas.util._decoratorsrr�pandas.core.dtypes.commonrrrrr�pandas.core.dtypes.dtypesr�pandas.core.dtypes.genericrr�pandas.core.dtypes.missingr�pandas.core._numbar�pandas.core.algorithmsr�pandas.core.applyr�pandas.core.arraysr�pandas.core.baser�pandas.core.common�core�commonrz�pandas.core.indexers.objectsr r!r"r#�pandas.core.indexes.apir$r%r&r'r(�pandas.core.reshape.concatr)�pandas.core.util.numba_r*r+�pandas.core.window.commonr,r-�pandas.core.window.docr.r/r0r1r2r3r4r5r6r7�pandas.core.window.numba_r8r9r:�collections.abcr;r<r=�pandas._typingr>r?r@rArBrCr�rDrE�pandas.core.genericrFrZrH�pandas.core.arrays.datetimelikerIrKrTr�r�r8rprIrgre�<module>r�sE���#�����������
?�>�>�#��
��1��-�'�,�2�-�+� � �����.��������������,�3�9�p��p�fF:�
�F:�RC	
�Z�C	
�LB
�z�B
�Js
�&�s
�l�.�.���:�&��:rg

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists