
    Mhu                      S r SSKJr  SSKrSSKJr  SSKJr  SSKrSSK	J
r
  SSKJrJrJrJr  SSKrSSKJrJrJr  SSKJs  Js  Jr  SS	KJr  SS
KJr  SSKJ r J!r!  SSK"J#r#J$r$J%r%J&r&J'r'  SSK(J)r)  SSK*J+r+J,r,  SSK-J.r.  SSK/J0r0  SSK1J2r2  SSK3J4r4  SSK5J6r6  SSK7J8r8  SSK9J:s  J;r<  SSK=J>r>J?r?J@r@JArA  SSKBJCrCJDrDJErEJFrFJGrG  SSKHJIrI  SSKJJKrKJLrL  SSKMJNrNJOrO  SSKPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZ  SSK[J\r\J]r]J^r^  \(       a.  SSK_J`r`JaraJbrb  SSKcJdrdJereJfrfJgrgJhrhJiri  SSKjJkrkJlrl  SSKmJnrn  SS KoJprp  SS!KqJrrr   " S" S#\85      rs " S$ S%\s5      rt " S& S'\s5      ru " S( S)\s5      rv " S* S+\v5      rw\uR                   \wl          " S, S-\t\w5      rxg).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                     \ rS rSr% Sr/ rS\S'   \" 5       rS\S'   S\S'            S$S	S
.                   S%S jjjr	S&S jr
        S'S jrS(S)S jjrS*S jrS+S jrS,S-S jjrS(S jrS.S jrS rS/S jrS0S jrS1S jrS2S jr\S3S j5       rS4S jrS5S jr S(     S6S jjr S,       S7S jjr  S8       S9S jjr            S:S jr  S;       S<S  jjr S(   S=S! jjr S" r!\!r"S#r#g	)>
BaseWindowx   z7Provides utilities for performing windowing operations.	list[str]_attributeszfrozenset[Hashable]
exclusionsr%   _onN)	selectionc                  Xl         Xpl        Xl        Xl        X l        X0l        X@l        XPl        Ub  UR                  U5      OS U l	        Xl
        S U l        U R                  cH  U R                  S:X  a  U R                   R                  U l        OU R                   R                  U l        O[        U R                  [         5      (       a  U R                  U l        O[        U R                   ["        5      (       aL  U R                  U R                   R                  ;   a(  [!        U R                   U R                     5      U l        O[%        SU R                   S35      eXl        U R)                  5         g )Nr   zinvalid 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indexrP   columns
isinstancer%   r   
ValueError
_selection	_validate)selfrS   rW   rX   rY   rZ   r\   rT   rU   rV   r]   rQ   s               L/var/www/html/env/lib/python3.13/site-packages/pandas/core/window/rolling.py__init__BaseWindow.__init__   s    	& 262BC((.	(,77?yyA~88>>  88++''wwDH,//DGGtxx?O?O4OTXXdgg./DH*477) 4D D 
 $    c                   U R                   b%  [        U R                   5      (       d  [        S5      eU R                  b  [	        U R                  5      (       d  [        S5      eU R                  S:  a  [        S5      e[	        U R
                  5      (       a?  U R                  U R
                  :  a%  [        SU R                   SU R
                   35      eU R                  b  U R                  S;  a  [        S5      e[        U R                  [        [        45      (       d  [        S	[        U 5       35      e[        U R
                  [        5      (       a  [        R                  " U R
                  R                   5      R"                  R%                  5       n[        R                  " [        5       R                   5      R"                  R%                  5       nX:w  a+  [        [        U R
                  5      R&                   S
35      eU R(                  S;  a  [        S5      eU R*                  bA  [	        U R*                  5      (       d  [        S5      eU R*                  S:  a  [        S5      eg g )Nzcenter must be a booleanzmin_periods must be an integerr   zmin_periods must be >= 0zmin_periods z must be <= window )rightbothleftneitherz3closed must be 'right', 'left', 'both' or 'neither'zinvalid type: z? does not implement the correct signature for get_window_bounds)tablesinglez!method must be 'table' or 'singlezstep must be an integerzstep must be >= 0)rY   r   rb   rX   r   rW   rU   ra   rS   r   r   	TypeErrortyper    inspect	signatureget_window_bounds
parameterskeys__name__r]   rV   )re   get_window_bounds_signatureexpected_signatures      rf   rd   BaseWindow._validate   s   ;;"74;;+?+?788'd..// !ABB!# !;<<$++&&4+;+;dkk+I "4#3#3"44G}U  ;;"t{{ ;
 (
 RSS$((Y$=>>nT$ZL9::dkk;// +2*;*;--+j ( ")!2!2//"j  +@ DKK(112 3B C  ;;11@AA99 dii(( !:;;yy1} !455  !ri   c           	     F   [        U5      [        U5      :w  a$  [        S[        U5       S[        U5       S35      e[        U5      X0R                  =(       d    S-   S-
  U R                  =(       d    S-  :w  a(  [        S[        U5       SU SU R                   S35      eg )	Nzstart (z) and end (z ) bounds must be the same length   zstart and end bounds (z)) must be the same length as the object (z) divided by the step (z) if given and rounded up)lenrb   rV   )re   startendnum_valss       rf   _check_window_boundsBaseWindow._check_window_bounds   s     u:S!#e*[S
 ;   u:(iin159tyy~ANN(U 5""*+B499+ N*+  Ori   c                `    Ub  [        U5      [        U5      :X  a  U$ USSU R                  2   $ )z:
Slices the index for a given result and the preset step.
N)r~   rV   )re   r_   results      rf   _slice_axis_for_stepBaseWindow._slice_axis_for_step   s9     ~VE
!: 	
 |$))|$	
ri   c                    U R                   R                  S:X  aQ  U(       aI  [        U R                   R                  5      (       d$  [	        [        U 5      R                   SU S35      eggg)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.
r}   .z  does not implement numeric_onlyN)_selected_objndimr   dtypeNotImplementedErrorrr   rx   )re   namenumeric_onlys      rf   _validate_numeric_only!BaseWindow._validate_numeric_only   sj     ##q($T%7%7%=%=>>%:&&'q.NO  ?  )ri   c                *    UR                  S/S/S9nU$ )zSubset DataFrame to numeric columns.

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

Returns
-------
obj subset to numeric-only columns.
numberr   )includeexclude)select_dtypes)re   rS   r   s      rf   _make_numeric_onlyBaseWindow._make_numeric_only  s"     ""H:}"Mri   c                   U R                   bc  [        U R                   [        5      (       dD  UR                  S:X  a4  UR	                  UR
                  R                  U R                   /5      SS9nUR                  S:  a(  U(       d  U R                  S:X  a  U R                  U5      nU R                  S:X  a/  UR                  SSS9nUR                  R                  5       Ul
        U$ )1
Split data into blocks & return conformed data.
   F)r`   copyr}   float64)r   )rT   ra   r%   r   reindexr`   
differencer\   r   astype_mgrconsolidate)re   rS   r   s      rf   _create_dataBaseWindow._create_data  s    
 77z$''5'A'AchhRSm++ckk&<&<dggY&Ge+TC88a<\TYY!^ ))#.C99>**YU*3Cxx++-CH
ri   c                    Uc  U R                   nU R                   Vs0 s H  oD[        X5      _M     nnU R                  X5      n[	        U 5      " U4SU0UD6nU$ s  snf )z
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
rQ   )rS   rN   getattr_infer_selectionrr   )re   keyr   subsetattrkwargsrQ   new_wins           rf   _gotitemBaseWindow._gotitem#  sk     >XXF 9=8H8HI8H++8HI))#6	t*VCyCFC	 Js   Ac                    XR                   ;   a  [        R                  X5      $ XR                  ;   a  X   $ [	        S[        U 5      R                   SU S35      e)N'z' object has no attribute ')_internal_names_setobject__getattribute__rS   AttributeErrorrr   rx   )re   r   s     rf   __getattr__BaseWindow.__getattr__;  s\    +++**46688:T
##$$?vQG
 	
ri   c                6    U R                   R                  5       $ N)rS   _dir_additionsre   s    rf   r   BaseWindow._dir_additionsE  s    xx&&((ri   c                   ^  U 4S jT R                    5       nSR                  U5      n[        T 5      R                   SU S3$ )z0
Provide a nice str repr of our rolling object.
c              3  |   >#    U  H1  n[        TUS 5      c  M  US   S:w  d  M  U S[        TU5       3v   M3     g 7f)Nr   _=)r   ).0	attr_namere   s     rf   	<genexpr>&BaseWindow.__repr__.<locals>.<genexpr>L  sJ      
-	tY- 6>Glc>Q 6yk74345-s   <<<,z [])rN   joinrr   rx   )re   
attrs_listattrss   `  rf   __repr__BaseWindow.__repr__H  sF    
!--


 $t*%%&bq11ri   c              #    #    U R                   R                  U R                  5      nU R                  U5      nU R	                  5       nUR                  [        U5      U R                  U R                  U R                  U R                  S9u  p4U R                  X4[        U5      5        [        X45       H!  u  pVUR                  [        XV5         nUv   M#     g 7fN
num_valuesrX   rY   rU   rV   )r   set_axisrP   r   _get_window_indexerru   r~   rX   rY   rU   rV   r   zipilocslice)re   rS   indexerr   r   ser   s           rf   __iter__BaseWindow.__iter__T  s       ))$((3$**,..3x((;;;; / 

 	!!%c#h7ODAXXeAk*FL $s   CCc                :   [        UR                  5      (       a/  [        S[        U 5      R                   SUR                   S35      e [        U[        5      (       a-  UR                  [        R                  [        R                  S9nO[        U5      n [        R                  " U5      nUR                  5       (       a&  [        R                   " U[        R                  U5      nU$ ! [        [        4 a  n[        SUR                   35      UeSnAff = f)z1Convert input to numpy arrays for Cython routineszops for z for this dtype z are not implemented)na_valuezcannot handle this type -> N)r   r   r   rr   rx   ra   r   to_numpynpr   nanr   rb   rq   isinfanywhere)re   valueserrinfs       rf   _prep_valuesBaseWindow._prep_valuesf  s    v||,,%4:../ 0&:< 	S&.11bffE'/
 hhv7799XXc26662F I& 	S9&,,HIsR	Ss   AC, C, ,D<DDc                ^   SSK Jn  U R                  Gb  U R                  R	                  UR
                  5      (       d  U R                  R                  nU" U R                  U R                  R
                  USS9nXAR                  ;   a  XQU'   g XAR
                  R                  ;   a  g X@R                  R                  ;   ae  U R                  R                  nUR                  nUR                  U5      nUR                  US U 5      n	[        U	5      n
UR                  XU5        g XQU'   g g g )Nr   rE   Fr_   r   r   )pandasrE   rT   rP   equalsr_   r   rS   r`   namesr   get_locintersectionr~   insert)re   r   rS   rE   r   	extra_colold_colsnew_colsold_locoverlapnew_locs              rf   _insert_on_columnBaseWindow._insert_on_column~  s     	"77txxsyy'A'A88==Dtxxtxx~~DuUI~~%(t+++++333--55!>>"**40"//'0BCg,gY7  )t% (Bri   c                l   [        U R                  [        [        [        45      (       a  U R                  R
                  $ [        U R                  R                  [        5      (       aK  U R                  R                  R                  S;   a'  U R                  R                  [        R                  S9$ g )NmMr   )ra   rP   r'   r$   r(   asi8r   r   kindr   r   int64r   s    rf   _index_arrayBaseWindow._index_array  ss     dhhm^ LMM88== 
338K8Kt8S88$$288$44ri   c                    UR                   S   S:X  a  UR                   S   S:  a  [        S5      eUR                   S   S:X  a  UR                  S5      $ U R                  X5        U$ )zValidate and finalize result.r}   r   No numeric types to aggregater   )shaper   r   r   )re   outrS   s      rf   _resolve_outputBaseWindow._resolve_output  s_    99Q<11!1;<<99Q<1::i((s(
ri   c                    [        U R                  [        5      (       a  U R                  $ U R                  b)  [	        U R
                  U R                  U R                  S9$ [        U R                  S9$ )zK
Return an indexer class that will compute the window start and end bounds
)index_arraywindow_sizerY   )r  )ra   rW   r    r^   r#   r   rY   r!   r   s    rf   r   BaseWindow._get_window_indexer  sb     dkk;//;;(( -- --{{ 
 "dkk::ri   c                |   U R                  U R                  5      nUS:X  a  [        U5      R                  [        5      n U R                  UR                  5      nU" U5      nU R                  UR                  U5      nUR                  XgUR                  S9$ ! [        [        4 a  n[        S5      UeSnAff = f)z%
Series version of _apply_columnwise
countr   Nr_   r   )r   r   r   r   intr   _valuesrq   r   r   r   r_   _constructorr   )re   homogeneous_funcr   rS   r   r   r   r_   s           rf   _apply_seriesBaseWindow._apply_series  s      2 237?*##C(C	F&&s{{3F "&)))#))V<#((CC ./ 	F;<#E	Fs   B B;*B66B;c                   U R                  X#5        U R                  R                  S:X  a  U R                  X5      $ U R	                  U R                  U5      nUS:X  a=  [        U5      R                  [        5      nUR                  R                  5       Ul        U R                  S:X  a  UR                  n/ n/ n[        UR                  5       5       HA  u  px U R                  U5      nU" U5      n
UR'                  U
5        UR'                  U5        MC     U R)                  UR*                  [-        U5      S:  a  US   OS5      n[/        U5      R1                  UUUR2                  R5                  U5      SS9nU R                  S:X  a  UR                  nU R7                  X5      $ ! [        [         4 a  n	[#        SUR$                   35      U	eSn	A	ff = f)zT
Apply the given function to the DataFrame broken down into homogeneous
sub-frames.
r}   r
  z#Cannot aggregate non-numeric type: Nr   F)r_   r`   verify_integrity)r   r   r   r  r   r   r   r  r   r   r\   T	enumerate_iter_column_arraysr   rq   r   r   r   appendr   r_   r~   rr   _from_arraysr`   taker  )re   r  r   r   rS   taker
res_valuesiarrr   resr_   dfs                rf   _apply_columnwiseBaseWindow._apply_columnwise  s    	##D7""a'%%&6== 2 2LA7?*##C(Cxx++-CH99>%%C
 7 7 9:FA'',
 #3'Cc"LLO ; ))IIJ!(;z!}
 #Y##KK$$U+"	 $ 
 99>B##B,,+ 23 9#))Es   F++G;GGc                `   U R                   R                  S:X  a  [        S5      eU R                  U R                   U5      nU R	                  UR                  5       5      nU R                  S:X  a  UR                  OUnU" U5      nU R                  S:X  a  UR                  OUnU R                  UR                  U5      nUR                  S   [        UR                  5      :X  a  UR                  OUR                  SSU R                  2   nUR                  XgUS9n	U R                  X5      $ )zD
Apply the given function to the DataFrame across the entire object
r}   z1method='table' not applicable for Series objects.Nr_   r`   )r   r   rb   r   r   r   r\   r  r   r_   r  r~   r`   rV   r  r  )
re   r  r   r   rS   r   r   r_   r`   r  s
             rf   _apply_tablewiseBaseWindow._apply_tablewise  s    ""a'PQQ 2 2LA""3<<>2!YY!^!&)!YY!^))#))V< ||A#ckk"22 KK\		\* 	
 vGD##C--ri   c                   U R                  X5      nUc
  UnUc  SOUnON[        U[        [        45      (       d  [	        S5      eUR
                  S:X  a  U(       a  U R                  U5      n[        XU[        U5      S9$ )M
Apply the given pairwise function given 2 pandas objects (DataFrame/Series)
Tz#other must be a DataFrame or Seriesr   )pairwise)	r   ra   r   r   rb   r   r   r,   bool)re   targetotherr(  funcr   s         rf   _apply_pairwiseBaseWindow._apply_pairwise  sx     ""68=E'/tXHEL)#<==BCCZZ1_++E2E!&XOOri   c                   ^ ^^^^ T R                  5       mT R                  b  T R                  OTR                  mSUUUU U4S jjnT R                  S:X  a  T R	                  XbU5      $ T R                  XbU5      $ )an  
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                   > U R                   S:X  a  U R                  5       $ UUUUU4S jn[        R                  " SS9   U" U 5      nS S S 5        U$ ! , (       d  f       W$ = f)Nr   c                   > TR                  [        U 5      TTR                  TR                  TR                  S9u  pTR                  X[        U 5      5        T" XUT/TQ76 $ r   )ru   r~   rY   rU   rV   r   )xr   r   r,  rX   
numba_argsre   window_indexers      rf   calc9BaseWindow._apply.<locals>.homogeneous_func.<locals>.calcY  sc    +=="1v +;;;; > 
 ))%c!f=Ac;DDDri   ignoreall)sizer   r   errstate)r   r5  r   r,  rX   r3  re   r4  s      rf   r  +BaseWindow._apply.<locals>.homogeneous_funcS  s\     {{a{{}$
E 
E *f + M +* Ms    	A
A"rp   r   
np.ndarray)r   rX   r  r]   r   r$  )	re   r,  r   r   r3  r   r  rX   r4  s	   ``  `  @@rf   _applyBaseWindow._apply2  sz    4 113 + ++ 		 	. ;;("))*:,OO(()9NNri   c                *   U R                  5       nU R                  b  U R                  OUR                  nU R                  U R                  5      nU R
                  S:X  a  UR                  nU R                  UR                  5       5      nUR                  S:X  a  UR                  SS5      nUR                  [        U5      UU R                  U R                  U R                  S9u  pU R!                  X[        U5      5        ["        R$                  n
["        R&                  " UU
4SS0[)        U5      D6nU" UR                  4XUS.UD6R                  nU R
                  S:X  a  UR                  OUnU R+                  UR,                  U5      nUR                  S:X  a,  UR/                  5       nUR1                  XUR2                  S9nU$ U R+                  UR4                  UR                  5      nUR1                  XUS9nU R7                  X5      $ )	Nr}   r   is_grouped_kernelF)r   r   rX   r  r#  )r   rX   r  r   r   r\   r  r   r   r   reshaperu   r~   rY   rU   rV   r   r   float_dtype_mappinggenerate_shared_aggregatorr*   r   r_   squeezer  r   r`   r  )re   r,  engine_kwargsfunc_kwargsr4  rX   rS   r   r   r   dtype_mapping
aggregatorr   r_   r  r`   s                   rf   _numba_applyBaseWindow._numba_applyo  s    113 + ++ 	
  2 2399>%%C""3<<>2;;!^^B*F#556{#;;;; 6 

 	!!%c&k:
 !4488
 $
  .	

 HH
!
GR

! 	 "YY!^))#))V<88q=^^%F""6SXX"FCJ//VXXFG""6"HC''11ri   c                ^    [        XX#S9R                  5       nUc  U R                  USX#S9$ U$ )Nargsr   F)rawrP  r   )r   aggapplyre   r,  rP  r   r   s        rf   	aggregateBaseWindow.aggregate  s6    %dtKOOQ>::dD:HHri   )rP   rc   r^   r\   rY   rU   r]   rX   rS   rT   rV   rZ   rW   )	NNFNr   NNNrp   )rS   rF   rX   
int | NonerY   bool | NonerZ   
str | Noner\   r?   rT   zstr | Index | NonerU   rY  rV   rW  r]   strreturnNoner[  r\  )r   r>  r   r>  r   r  r[  r\  r   )r_   r%   r   zSized | Noner[  r%   )r   rZ  r   r)  r[  r\  )rS   r@   r[  r@   FrS   r@   r   r)  r[  r@   )r   rZ  )r[  rZ  )r[  r<   )r   r>   r[  r>  )r   rD   rS   rD   r[  r\  )r[  znpt.NDArray[np.int64] | None)r  rD   rS   rD   r[  rD   )r[  r    )r  Callable[..., ArrayLike]r   rY  r[  rE   )r  r`  r   rZ  r   r)  r[  DataFrame | Series)NF)r  r`  r   rY  r   r)  r[  ra  r*  ra  r+  DataFrame | Series | Noner(  rX  r,  zFCallable[[DataFrame | Series, DataFrame | Series], DataFrame | Series]r   r)  r[  ra  F )r,  Callable[..., Any]r   rZ  r   r)  r3  tuple[Any, ...])r,  rf  rH  dict[str, bool] | None)$rx   
__module____qualname____firstlineno____doc__rN   __annotations__	frozensetrO   rg   rd   r   r   r   r   r   r   r   r   r   r   r   r   propertyr   r  r   r  r   r$  r-  r?  rL  rU  rR  __static_attributes__re  ri   rf   rK   rK   x   se   AK&/kJ#1	J
 "&##!%!+ ++  	+
 + + + + + + + 
+Z)6V&0<?	
("0
)
2$0)2  ; NRD 8D@JD	D0 #	3-23- 3- 	3-
 
3-p  "	.2. . 	.
 
.4P"P )P 	P
 UP P 
P6 #&(;O ;O ;O 	;O
 $;O@ 1512 12 .12f Cri   rK   c                     ^  \ rS rSr% SrS\S'   S\S'   S/rS\S'   S	S
.       SU 4S jjjr  S         SU 4S jjjr            SU 4S jjr	SSU 4S jjjr
SU 4S jjrSrU =r$ )BaseWindowGroupbyi  z+
Provide the groupby windowing facilities.
rH   _grouperr)  	_as_indexrM   rN   T)rt  c               
  > SSK Jn  [        X&5      (       d  [        S5      eX l        X0l        UR                  U R                  R                  SS9nUR                  S5      b  [        S5      e[        TU ],  " U/UQ70 UD6  g )Nr   rG   zMust pass a BaseGrouper object.r7  r`   errorsrV   z step not implemented for groupby)pandas.core.groupby.opsrH   ra   rb   rs  rt  dropr   getr   superrg   )re   rS   rs  rt  rP  r   rH   	__class__s          rf   rg   BaseWindowGroupby.__init__  sy     	8(00>?? " hht}}228hD::f)%&HII.t.v.ri   c           	       > [         TU ]  " UUUU40 UD6nU R                  R                  n/ UR                  Qn[
        R
                  " U R                  R                  5      n	X-   n
U R                  R                   Vs/ s H-  nXR                  R                  R                  ;  d  Ub  M+  UPM/     nn[        U5      [        U	5      :w  a  UR                  USS9nU R                  R                  n[
        R
                  " U R                  R                  5      nU R                  R                  R                  5       nU(       a   [        R                  " [        U5      5      nO#[        R                   " / [        R"                  S9nU Vs/ s H  nUR%                  U5      PM     nnUb  UR%                  U5      n['        U[(        5      (       d  [(        R*                  " U/5      nUR-                  [        UR                  5      5        UR-                  [        UR                  5      5        [)        XU
SS9nUUl        U R.                  (       d*  UR1                  [        [3        [        U	5      5      5      S9nU$ s  snf s  snf )Nr7  rv  r   Fr   r  )level)r{  r?  rS   r_   r   r   rs  r~   ry  codeslevelsindicesr   r   concatenatelistarrayintpr  ra   r&   from_arraysextendrt  reset_indexrange)re   r,  r   r   r3  r   r   grouped_object_indexgrouped_index_namegroupby_keysresult_index_namesr   drop_columnsr  r  group_indicesr   cidxresult_indexr|  s                       rf   r?  BaseWindowGroupby._apply  s    	

 
  $xx~~:399:yy!4!45)> }}**
*((.....# * 	 
 |L 11[[h[GF##4==//0--446nnT-%89Ghhr1G*/0%Q%0  +&++G4Cc:.. ,,cU3LLcii)MM$szz*+!!3e
 $~~''d5\9J3K.L'MFI
$ 1s    *J.JJ	c                  >^ UR                  U R                  R                  SS9n[        TU ]  UTX4U5      nTGbU  [        U4S jU R                  R                  R                  5        5       5      (       Gd  [        U5      n[        U R                  R                  R                  5        Vs/ s H-  nUR                  U5      R                  UR                  5      PM/     sn5      nS U R                  R                  R                  5        5       n	/ n
/ n[        [        [!        U	6 5       H]  n["        R$                  " ["        R&                  " U5      U5      n[)        U5      u  pU
R+                  U5        UR+                  U5        M_     OU R                  R,                  n
U R                  R.                  nU R                  R                  R                  5       nU(       a   ["        R0                  " [        U5      5      nO#["        R&                  " / ["        R2                  S9nUR4                  S:X  a  SnO[        UR6                  5      nU
 Vs/ s H)  n["        R$                  " UR                  U5      U5      PM+     n
n[9        UR                  [:        5      (       a^  [        UR                  R,                  5      n[        UR                  R.                  5      n[        UR                  R                  5      nO5[)        UR                  5      u  nnU/nU/nUR                  R<                  /nU
U-   nUU-   nU R                  R                  U-   n[;        UUUSS9nUUl        U$ s  snf s  snf )	r'  r7  rv  c              3  R   >#    U  H  n[        U5      [        T5      :H  v   M     g 7fr   )r~   )r   groupr+  s     rf   r   4BaseWindowGroupby._apply_pairwise.<locals>.<genexpr>  s"      )
2PCJ#e*$2Ps   $'c              3  N   #    U  H  n[         R                  " U5      v   M     g 7fr   )commaybe_make_list)r   pairs     rf   r   r  &  s"      6Rd##D))6Rs   #%r   r}   Fr  )ry  rs  r   r{  r-  r9  r  r   r~   r)   r  r   r_   rw   mapr  r   r   repeatr  r   r  r  r  r  r  r   r`   ra   r&   r   )re   r*  r+  r(  r,  r   r   old_result_len
gb_indicesgb_pairsgroupby_codesgroupby_levelsgb_level_pairlabelsr  r  r  r   	repeat_byr  result_codesresult_levelsresult_names	idx_codes
idx_levelsr  r|  s     `                       rf   r-  !BaseWindowGroupby._apply_pairwise  s    T]]%8%8J(US )
26--2G2G2N2N2P)
 &
 &
 ![N '+mm&;&;&B&B&D&D
 KK
+33FLLA&DF6:mm6K6K6P6P6RH MN!$T3>!:288M#:NK )& 1$$U+%%f-	 "; !MM//M "]]11N MM1188:M..m)<=((2RWW5{{a	/	?L?L!		!&&/95}   fllJ// 2 23L !4!45M 2 23L$-fll$;!Iz%;L'LM"LL--.L %|3&6}}**\9!<|e
 $uFs   04M40M9c                "  > UR                   (       do  [        R                  " [        U R                  R
                  R                  5       5      5      R                  [        R                  5      nUR                  U5      n[        TU ]-  X5      $ )r   )emptyr   r  r  rs  r  r   r   r   r  r{  r   )re   rS   r   groupby_orderr|  s       rf   r   BaseWindowGroupby._create_data\  sd     yyNN40E0E0L0L0N+OPWWM ((=)Cw#C66ri   c                   > U R                   b%  U R                  R                  U R                  5      n[        TU ]  XUS9$ )N)r   )rT   rS   	set_indexrP   r{  r   )re   r   r   r   r|  s       rf   r   BaseWindowGroupby._gotitemj  s<     77XX''1Fw&99ri   )rt  rs  )rS   ra  rs  rH   rt  r)  r[  r\  rd  )
r,  rf  r   rZ  r   r)  r3  rg  r[  ra  rb  r^  r_  r   )rx   ri  rj  rk  rl  rm  rN   rg   r?  r-  r   r   rp  __classcell__r|  s   @rf   rr  rr    s     O(\K) // 	/
 / 
/ /6 #&(; ; ; 	;
 $; 
; ;zR"R )R 	R
 UR R 
Rh7 7: :ri   rr  c                  p  ^  \ rS rSrSr/ SQrU 4S jrS%S jr  S&       S'S jjr\	" \
S   \" S5      \" S	5      S
SS9S 5       r\r\	" \\" S5      \\\" S5      \\" S5      \\" S5      \" S5      SSSS9S(S)S jj5       r\	" \\" S5      \\\" S5      \\" S5      \\" S5      \" S5      SSSS9S(S)S jj5       r\	" \\" S5      \\\" S5      \\" S5      \\" S5      \" S5      SSSS9S*S+S jj5       r\	" \\" S5      \\\" S5      \\" S5      \\" S5      \" S 5      SS!S"S9S*S+S# jj5       rS$rU =r$ ),Windowit  a  
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
	rW   rX   rY   rZ   r\   rT   rU   rV   r]   c                  > [         TU ]  5         [        U R                  [        5      (       d  [        SU R                   35      e[        SSS9n[        XR                  S 5      U l        U R                  c  [        SU R                   35      e[        U R                  [        5      (       a  [        S5      e[        U R                  5      (       a  U R                  S:  a  [        S5      eU R                  S:w  a  [        S	5      eg )
NzInvalid win_type zscipy.signal.windowsz,Scipy is required to generate window weight.)extraz6BaseIndexer subclasses not implemented with win_types.r   &window must be an integer 0 or greaterrp   z+'single' is the only supported method type.)r{  rd   ra   rZ   rZ  rb   r   r   _scipy_weight_generatorrW   r    r   r   r]   )re   signalr|  s     rf   rd   Window._validate|  s    $----0@AA+"*X
 (/v}}d'K$''/0@AAdkk;//%H  $++&&$++/EFF;;("%&STT #ri   c                p    US:  a/  [        US5      /n[        R                  " U[        U5         5      nU$ )zD
Center the result in the window for weighted rolling aggregations.
r   N)r   r   r   tuple)re   r   offsetlead_indexers       rf   _center_windowWindow._center_window  s7     A:!&$/0LWWVE,$789Fri   c                   ^ ^^^ T R                   " T R                  40 UD6mT R                  (       a  [        T5      S-
  S-  OSmSUUU U4S jjnT R	                  XbU5      SST R
                  2   $ )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
r}   r   r   c                4  > U R                   S:X  a  U R                  5       $ UUUU4S jn[        R                  " SS9   [        R                  " U" U 5      5      nS S S 5        TR
                  (       a  TR                  WT5      nW$ ! , (       d  f       N3= f)Nr   c                   > [         R                  " [         R                  /T-  5      n[         R                  " X45      n T" U TTR                  b  TR                  5      $ [        T5      5      $ r   )r   r  r   r  rX   r~   )r2  additional_nansr,  r  re   rW   s     rf   r5  5Window._apply.<locals>.homogeneous_func.<locals>.calc  si    "$((BFF8f+<"=NNA#78(,(8(8(DD$$  KNf+ ri   r7  r8  )r:  r   r   r;  asarrayrY   r  )r   r5  r   r,  r  re   rW   s      rf   r  'Window._apply.<locals>.homogeneous_func  su     {{a{{}$  *DL1 + {{,,VV<M +*s   B		
BNr=  )r  rW   rY   r~   r   rV   )	re   r,  r   r   r3  r   r  r  rW   s	   ``     @@rf   r?  Window._apply  sr    : --KK
!
 ,0;;#f+/a'A	 	0 %%&6lKtyyL
 	
ri   rU  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
        zSeries/DataFrame see_alsoexamplesklassr\   c                L    [        XX#S9R                  5       nUc  U" U 5      nU$ )NrO  )r   rR  rT  s        rf   rU  Window.aggregate  s-    @ &dtKOOQ>$ZFri   
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
        rollingzweighted window sumsumwindow_methodaggregation_description
agg_methodc                N    [         R                  nU R                  " U4SUS.UD6$ )Nr  r   r   )window_aggregationsroll_weighted_sumr?  re   r   r   window_funcs       rf   r  
Window.sum  s;    N *;; {{
%
 	
 	
ri   a          >>> 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
        zweighted window meanmeanc                N    [         R                  nU R                  " U4SUS.UD6$ )Nr  r  )r  roll_weighted_meanr?  r  s       rf   r  Window.mean4  s;    L *<< {{
%
 	
 	
ri   a          >>> 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
        zweighted window variancevarc                    [        [        R                  US9nUR                  SS 5        U R                  " U4SUS.UD6$ )Nddofr   r  r  )r   r  roll_weighted_varpopr?  )re   r  r   r   r  s        rf   r  
Window.vare  sB    L 1CC$O

64 {{;XUXQWXXri   a          >>> 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           	     @    [        U R                  " SUSUS.UD65      $ )Nr  )r  r   r   re  )r-   r  )re   r  r   r   s       rf   r  
Window.std  s*    L HHP$UPP
 	
ri   )r  )r   r>  r  r  r[  r>  rd  )r,  z,Callable[[np.ndarray, int, int], np.ndarray]r   rZ  r   r)  r3  rg  r^  r   r)  r}   Fr  r  r   r)  )rx   ri  rj  rk  rl  rN   rd   r  r?  r   r.   r   rU  rR  r3   r/   r0   r1   r4   r5   r  r  r  r  rp  r  r  s   @rf   r  r  t  s,   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$JYK$JY
 	l+i(j)j)	
.   DG$J
K$J
ri   r  c                     \ rS rSrSSS jjr     S           SS jjr          SS jr   S     SS jjr   S     SS jjr   S     SS jjr	   S     SS	 jjr
   S     SS
 jjr    S       SS jjr    S       SS jjrSSS jjrSSS jjrSSS jjr  S      S!S jjr    S"       S#S jjr    S$       S%S jjr    S$       S%S jjrSrg)&RollingAndExpandingMixini  c                D    [         R                  nU R                  USUS9$ )Nr
  r  )r  roll_sumr?  re   r   r  s      rf   r
  RollingAndExpandingMixin.count  s"    )22{{;W<{PPri   Nc                   Uc  SnUc  0 n[        U5      (       d  [        S5      eSn[        U5      (       aN  USL a  [        S5      eUnU R                  S:X  a  [	        U40 [        XF5      D6nOH[        U40 [        XF5      D6nO2US;   a!  Ub  [        S5      eU R                  XVX!5      nO[        S5      eU R                  US	US
9$ )Nre  z'raw parameter must be `True` or `False`Fz.raw must be `True` when using the numba enginerp   )cythonNz+cython engine does not accept engine_kwargsz)engine must be either 'numba' or 'cython'rS  )r   r3  )	r   rb   r+   r]   r9   r*   r:   _generate_cython_apply_funcr?  )	re   r,  rQ  enginerH  rP  r   r3  
apply_funcs	            rf   rS  RollingAndExpandingMixin.apply  s     <D>Fs||FGG&(
6""e| !QRRJ{{h&6-mD
 7-mD
 ''( !NOO99$RJHII{{!  
 	
ri   c                d   ^ ^^ SSK Jm  [        [        R                  UUUUS9mU4UU U4S jjnU$ )Nr   r   )rP  r   rQ  functionc                H   > U(       d  T" U TR                   SS9n T" XX#5      $ )NF)r_   r   )rP   )r   beginr   rX   rQ  rE   re   r  s        rf   r  HRollingAndExpandingMixin._generate_cython_apply_func.<locals>.apply_func  s%    dhhUCvc??ri   )r   rE   r   r  
roll_apply)re   rP  r   rQ  r  r  rE   r  s   `     @@rf   r  4RollingAndExpandingMixin._generate_cython_apply_func  sA     	"**
 =@ 	@ 	@ ri   c                   [        U5      (       aR  U R                  S:X  a+  [        [        R                  5      nU R                  USUUS9$ SSKJn  U R                  XS5      $ [        R                  nU R                  USUS9$ )Nro   TrQ  r   rH  r   )sliding_sumr  r  )r+   r]   r8   r   nansumrS  pandas.core._numba.kernelsr  rL  r  r  r?  )re   r   r   rH  r,  r  r  s          rf   r  RollingAndExpandingMixin.sum  s     6""{{g%>ryyIzz!"/	 "   C((DD)22{{;U{NNri   c                   [        U5      (       aQ  U R                  S:X  a+  [        [        R                  5      nU R                  USUUS9$ SSKJn  U R                  XSSS9$ [        R                  nU R                  USUS9$ )	Nro   Tr  r   sliding_min_maxis_maxmaxr  )r+   r]   r8   r   nanmaxrS  r  r  rL  r  roll_maxr?  re   r   r   rH  r,  r  r  s          rf   r  RollingAndExpandingMixin.max  s     6""{{g%>ryyIzz!"/	 "   G((PT(UU)22{{;U{NNri   c                   [        U5      (       aQ  U R                  S:X  a+  [        [        R                  5      nU R                  USUUS9$ SSKJn  U R                  XSSS9$ [        R                  nU R                  USUS	9$ )
Nro   Tr  r   r  Fr  minr  )r+   r]   r8   r   nanminrS  r  r  rL  r  roll_minr?  r  s          rf   r  RollingAndExpandingMixin.min/  s     6""{{g%>ryyIzz!"/	 "   G((PU(VV)22{{;U{NNri   c                   [        U5      (       aR  U R                  S:X  a+  [        [        R                  5      nU R                  USUUS9$ SSKJn  U R                  XS5      $ [        R                  nU R                  USUS9$ )Nro   Tr  r   )sliding_meanr  r  )r+   r]   r8   r   nanmeanrS  r  r   rL  r  	roll_meanr?  )re   r   r   rH  r,  r   r  s          rf   r  RollingAndExpandingMixin.meanE  s     6""{{g%>rzzJzz!"/	 "   D((EE)33{{;V,{OOri   c                    [        U5      (       aL  U R                  S:X  a  [        [        R                  5      nO[        R                  nU R                  USUUS9$ [        R                  nU R                  USUS9$ )Nro   Tr  medianr  )	r+   r]   r8   r   	nanmedianrS  r  roll_median_cr?  )re   r   r   rH  r,  r  s         rf   r%  RollingAndExpandingMixin.median[  sv     6""{{g%>r||L||::+	    *77{{;XL{QQri   c                   ^^ [        U5      (       a:  U R                  S:X  a  [        S5      eSSKJn  [        U R                  XTTS95      $ [        R                  mUU4S jnU R                  USUS9$ )	Nro   z%std not supported with method='table'r   sliding_varr  c           
     &   > [        T" XX#TS95      $ )Nr  )r-   )r   r  r   rX   r  r  s       rf   
zsqrt_func0RollingAndExpandingMixin.std.<locals>.zsqrt_func  s    VC4PQQri   r  r  )
r+   r]   r   r  r+  r-   rL  r  roll_varr?  )re   r  r   r   rH  r+  r-  r  s    `     @rf   r  RollingAndExpandingMixin.stdp  sx     6""{{g%)*QRR>**;D*QRR)22	R {{%  
 	
ri   c                    [        U5      (       a1  U R                  S:X  a  [        S5      eSSKJn  U R                  XTUS9$ [        [        R                  US9nU R                  USUS9$ )Nro   z%var not supported with method='table'r   r*  r  r  r  )
r+   r]   r   r  r+  rL  r   r  r/  r?  )re   r  r   r   rH  r+  r  s          rf   r  RollingAndExpandingMixin.var  sr     6""{{g%)*QRR>$$[d$KK1::F{{%  
 	
ri   c                D    [         R                  nU R                  USUS9$ )Nskewr  )r  	roll_skewr?  r  s      rf   r4  RollingAndExpandingMixin.skew  ,    )33{{%  
 	
ri   c                    U R                  SU5        U R                  US9U R                  US9U-
  R                  S5      -  $ Nsemr         ?r   r  r
  powre   r  r   s      rf   r:  RollingAndExpandingMixin.sem  sF    ##E<8xx\x2JJLJ1D8
#c( 	ri   c                D    [         R                  nU R                  USUS9$ )Nkurtr  )r  	roll_kurtr?  r  s      rf   rB  RollingAndExpandingMixin.kurt  r7  ri   c                    US:X  a  [         R                  nO0US:X  a  [         R                  nO[        [         R                  UUS9nU R                  USUS9$ )Ng      ?g        )quantileinterpolationrF  r  )r  r  r  r   roll_quantiler?  )re   qrG  r   r  s        rf   rF  !RollingAndExpandingMixin.quantile  sX     8-66K#X-66K!#11+K {{;Zl{SSri   c                X    [        [        R                  UUUS9nU R                  USUS9$ )N)r]   	ascending
percentilerankr  )r   r  	roll_rankr?  )re   r]   rL  pctr   r  s         rf   rN  RollingAndExpandingMixin.rank  s7     ))	
 {{;V,{OOri   c                   ^ ^^ T R                   b  [        S5      eT R                  SU5        SSKJm  UUU 4S jnT R                  T R                  XXT5      $ )Nzstep not implemented for covcovr   r   c                $  > TR                  U 5      nTR                  U5      nTR                  5       nTR                  b  TR                  OUR                  nUR	                  [        U5      UTR                  TR                  TR                  S9u  pgTR                  Xg[        U5      5        [        R                  " SS9   [        R                  " X#-  XgU5      n[        R                  " X&Xu5      n	[        R                  " X6Xu5      n
[        R                  " [        X#-   5      R!                  [        R"                  5      XgS5      nXU
-  -
  XT-
  -  -  nS S S 5        T" WU R$                  U R&                  SS9$ ! , (       d  f       N+= f)Nr   r7  r8  r   Fr   )r   r   rX   r  ru   r~   rY   rU   rV   r   r   r;  r  r"  r  r   r   r   r_   r   )r2  yx_arrayy_arrayr4  rX   r   r   mean_x_ymean_xmean_y	count_x_yr   rE   r  re   s                rf   cov_func.RollingAndExpandingMixin.cov.<locals>.cov_func  se   ''*G''*G!557N ##/   #// 
 (99w<'{{{{YY : JE %%e#g,?*.88%u; -66wsX,66wsX/88'+,33BJJ?Q	 #f_4RVFV9WX + &aff5II +*s   BF
FrV   r   r   r   rE   r-  r   )re   r+  r(  r  r   r\  rE   s   `  `  @rf   rS  RollingAndExpandingMixin.cov  sV     99 %&DEE##E<8!	J< ##
 	
ri   c                   ^ ^^ T R                   b  [        S5      eT R                  SU5        SSKJm  UUU 4S jnT R                  T R                  XXT5      $ )Nzstep not implemented for corrcorrr   r   c                  > TR                  U 5      nTR                  U5      nTR                  5       nTR                  b  TR                  OUR                  nUR	                  [        U5      UTR                  TR                  TR                  S9u  pgTR                  Xg[        U5      5        [        R                  " SS9   [        R                  " X#-  XgU5      n[        R                  " X&Xu5      n	[        R                  " X6Xu5      n
[        R                  " [        X#-   5      R!                  [        R"                  5      XgS5      n[        R$                  " X&XuT5      n[        R$                  " X6XuT5      nXU
-  -
  XT-
  -  -  nX-  S-  nX-  nS S S 5        T" WU R&                  U R(                  SS9$ ! , (       d  f       N+= f)Nr   r7  r8  r   r<  Fr   )r   r   rX   r  ru   r~   rY   rU   rV   r   r   r;  r  r"  r  r   r   r   r/  r_   r   )r2  rU  rV  rW  r4  rX   r   r   rX  rY  rZ  r[  x_vary_var	numeratordenominatorr   rE   r  re   s                    rf   	corr_func0RollingAndExpandingMixin.corr.<locals>.corr_func  s   ''*G''*G!557N ##/   #// 
 (99w<'{{{{YY : JE %%e#g,?*.88%u; -66wsX,66wsX/88'+,33BJJ?Q	 ,44Cd ,44Cd &7T!12	  %}4"0' +( &aff5II) +*s   CF<<
G
r^  )re   r+  r(  r  r   rg  rE   s   `  `  @rf   ra  RollingAndExpandingMixin.corr  sW     99 %&EFF##FL9!&	JP ##
 	
ri   re  r^  r  FNNNNr,  rf  rQ  r)  r   !Literal['cython', 'numba'] | NonerH  rh  rP  ztuple[Any, ...] | Noner   zdict[str, Any] | None)
rP  rg  r   zdict[str, Any]rQ  zbool | np.bool_r  rf  r[  z?Callable[[np.ndarray, np.ndarray, np.ndarray, int], np.ndarray]FNNr   r)  r   rl  rH  rh  r}   FNNr  r  r   r)  r   rl  rH  rh  r  r  linearFrI  floatrG  rA   r   r)  averageTFFr]   rB   rL  r)  rP  r)  r   r)  NNr}   Fr+  rc  r(  rX  r  r  r   r)  )rx   ri  rj  rk  r
  rS  r  r  r  r  r  r%  r  r  r4  r:  rB  rF  rN  rS  ra  rp  re  ri   rf   r  r    s   Q 4804'+(,)
 )
 )
 2	)

 .)
 %)
 &)
V  	
 % 
I6 #4804	OO 2O .	O0 #4804	OO 2O .	O0 #4804	OO 2O .	O0 #4804	PP 2P .	P0 #4804	RR 2R .	R. "4804

 
 2	

 .
4 "4804

 
 2	

 .
(

 08"	TT -T 	T* %."P!P P 	P
 P$ ,0 $"-
(-
 -
 	-

 -
b ,0 $"7
(7
 7
 	7

 7
 7
ri   r  c                    ^  \ rS rSr% / SQrS\S'   U 4S jrSiS jrSjS jr\	" \
S   \" S	5      \" S
5      SSS9U 4S j5       r\r\	" \\" S5      \\" S5      \\" S5      \\" S5      \" S5      R'                  SSS5      SSSS9SkSlU 4S jjj5       r\	" \\" S5      \\" S5      \\" S5      \\" S5      \" S5      SSSS9     Sm           SnU 4S jjj5       r\	" \\" S5      \\" 5       \" S5      \\" S5      \\" S 5      \\" S5      \" S!5      R'                  SSS5      SS"S"S9   So     SpU 4S# jjj5       r\	" \\" S5      \\" 5       \" S5      \\" S5      \\" S 5      \\" S5      \" S$5      SS%S&S9 SkSSS'.     SpU 4S( jjjj5       r\	" \\" S5      \\" 5       \" S5      \\" S5      \\" S 5      \\" S5      \" S)5      R'                  SSS5      SS*S+S9   So     SpU 4S, jjj5       r\	" \\" S5      \\" 5       \" S5      \\" S5      \\" S 5      \\" S5      \" S-5      R'                  SSS5      SS.S.S9   So     SpU 4S/ jjj5       r\	" \\" S5      \\" 5       \" S5      \\" S5      \\" S 5      \\" S5      \" S05      R'                  SSS5      SS1S1S9   So     SpU 4S2 jjj5       r\	" \\" S5      \" S35      R'                  SSS5      \\" S45      \" S5      \\" S5      S5\\" S 5      \" S65      R'                  SSS5      \" S5      \" S75      R'                  SSS5      SS8S9S9    Sq       SrU 4S: jjj5       r\	" \\" S5      \" S35      R'                  SSS5      \\" S45      \" S5      \\" S5      S;\\" S 5      \" S<5      R'                  SSS5      \" S5      \" S=5      R'                  SSS5      SS>S?S9    Sq       SrU 4S@ jjj5       r\	" \\" S5      \\" S5      \\" S5      SA\\" S 5      \" SB5      \" S5      \" SC5      SSDSES9SkSlU 4SF jjj5       r \	" \\" S5      \" S35      R'                  SSS5      \\" S5      \\" S5      \\" S 5      SG\" S5      \" SH5      R'                  SSS5      SSISJS9SsStSK jj5       r!\	" \\" S5      \\" S5      \\" S5      SL\\" S 5      SM\" S5      \" SN5      R'                  SSS5      SSOSPS9SkSlU 4SQ jjj5       r"\	" \\" S5      \" SR5      R'                  SSS5      \\" S5      \\" S5      \\" S5      \" SS5      R'                  SSS5      SSTSTS9\#" STSUSV9  Su     SvU 4SW jjj5       5       r$\	" \SX\" S5      \" SY5      R'                  SSS5      \\" S5      \\" S5      \\" S5      \" SZ5      R'                  SSS5      SS[S[S9    Sw       SxU 4S\ jjj5       r%\	" \\" S5      \" S]5      R'                  SSS5      \\" S5      \\" S5      \\" S5      \" S^5      SS_S`S9    Sy       SzU 4Sa jjj5       r&\	" \\" S5      \" S]5      R'                  SSS5      \\" S5      \\" S5      \" Sb5      R'                  SSS5      \\" S 5      \" Sc5      R'                  SSS5      \" S5      \" Sd5      R'                  SSS5      SSeSfS9    Sy       SzU 4Sg jjj5       r'Shr(U =r)$ ){Rollingi?  r  rM   rN   c                  > [         TU ]  5         U R                  R                  (       dy  [	        U R
                  [        [        [        45      (       dO  [	        U R
                  R                  [        5      (       Gai  U R
                  R                  R                  S;   GaD  [	        U R                  [        [        [        45      (       Ga  U R!                  5          [#        U R                  5      n[	        U R
                  [        5      (       aT  UR(                  U R
                  R*                  R(                  U R
                  R*                  R,                  -  -  U l        OS [1        U R
                  R                  5      n[3        UR(                  5      R5                  U5      R6                  U l        U R8                  c  SU l        U R:                  b  [=        S5      eg [	        U R                  [>        5      (       a  g [A        U R                  5      (       a  U R                  S:  a  ['        S5      eg ! [$        [&        4 a  n['        SU R                   S35      UeS nAff = f! [$         a    Sn Nf = f)	Nr   zpassed window z, is not compatible with a datetimelike indexnsr}   z,step is not supported with frequency windowsr   r  )!r{  rd   rS   r  ra   rP   r$   r(   r'   r   r   r   rW   rZ  r   r    _validate_datetimelike_monotonicr   rq   rb   nanosfreqnr^   rI   r   as_unit_valuerX   rV   r   r    r   )re   r  r   unitr|  s       rf   rd   Rolling._validateL  s    HHNN$((]NK$PQQ488>>:66488>>;N;NRV;VsJ	&BCC113 - $((K00 %)JJHHMM''$((--//9%! (8D %.djj$9$A$A$$G$N$N! '#$ yy$)B  %
 [11DKK((DKK!OEFF -<? z*  $T[[M 2; ;  !  D s*    H> )I0 >I-I((I-0I?>I?c                    U R                   R                  (       a  U R                  S5        U R                   R                  (       d.  U R                   R                  (       d  U R                  S5        ggg)zh
Validate self._on is monotonic (increasing or decreasing) and has
no NaT values for frequency windows.
values must not have NaTzvalues must be monotonicN)rP   hasnans_raise_monotonic_erroris_monotonic_increasingis_monotonic_decreasingr   s    rf   r~  (Rolling._validate_datetimelike_monotonic|  sQ    
 88''(BC00DHH4T4T''(BC 5U0ri   c                j    U R                   nUc  U R                  S:X  a  SnOSn[        U SU 35      e)Nr   r_   column )rT   r\   rb   )re   msgrT   s      rf   r  Rolling._raise_monotonic_error  s:    WW:yyA~B4q''ri   rU  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
        zSeries/Dataframer  r  c                ,   > [         TU ]  " U/UQ70 UD6$ r   )r{  rU  )re   r,  rP  r   r|  s       rf   rU  Rolling.aggregate  s     L w 7777ri   r  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
        
r}   r  zcount of non NaN observationsr
  r  c                "   > [         TU ]  U5      $ r   )r{  r
  re   r   r|  s     rf   r
  Rolling.count  s    J w}\**ri   z        >>> 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
        zcustom aggregation functionrS  Nc           	     (   > [         TU ]  UUUUUUS9$ )N)rQ  r   rH  rP  r   )r{  rS  )re   r,  rQ  r   rH  rP  r   r|  s          rf   rS  Rolling.apply  s.    B w}'  
 	
ri   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U ]  UUUS9$ N)r   r   rH  )r{  r  re   r   r   rH  r|  s       rf   r  Rolling.sum
  s%    J w{%'  
 	
ri   z        >>> 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   rH  c               "   > [         TU ]  UUUS9$ r  )r{  r  )re   r   r   rH  rP  r   r|  s         rf   r  Rolling.maxU  s%    F w{%'  
 	
ri   z
        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U ]  UUUS9$ r  )r{  r  r  s       rf   r  Rolling.min~  s%    H w{%'  
 	
ri   a  
        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U ]  UUUS9$ r  )r{  r  r  s       rf   r  Rolling.mean  s%    V w|%'  
 	
ri   a  
        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U ]  UUUS9$ r  )r{  r%  r  s       rf   r%  Rolling.median  s%    H w~%'  
 	
ri   z
        ddof : int, default 1
            Delta Degrees of Freedom.  The divisor used in calculations
            is ``N - ddof``, where ``N`` represents the number of elements.
        z1.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
        zstandard deviationr  c                $   > [         TU ]  UUUUS9$ N)r  r   r   rH  )r{  r  re   r  r   r   rH  r|  s        rf   r  Rolling.std	  (    h w{%'	  
 	
ri   z/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U ]  UUUUS9$ r  )r{  r  r  s        rf   r  Rolling.var>	  r  ri   z: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
        zunbiased skewnessr4  c                   > [         TU ]  US9$ Nr;  )r{  r4  r  s     rf   r4  Rolling.skewy	  s    D w||66ri   z: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
        zstandard error of meanr:  c                    U R                  SU5        U R                  US9U R                  U5      U-
  R                  S5      -  $ r9  r=  r?  s      rf   r:  Rolling.sem	  sG    F 	##E<8xx\x2JJ|$t+
#c( 	ri   z/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 biasrB  c                   > [         TU ]  US9$ r  )r{  rB  r  s     rf   rB  Rolling.kurt	  s    L w||66ri   a  
        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
        rF  rI  )old_arg_namenew_arg_namec                "   > [         TU ]  UUUS9$ )N)rI  rG  r   )r{  rF  )re   rI  rG  r   r|  s       rf   rF  Rolling.quantile	  s&    r w'%   
 	
ri   z.. 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
        rN  c                $   > [         TU ]  UUUUS9$ )N)r]   rL  rP  r   )r{  rN  )re   r]   rL  rP  r   r|  s        rf   rN  Rolling.rank,
  s(    H w|%	  
 	
ri   a   
        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
        zsample covariancerS  c                $   > [         TU ]  UUUUS9$ N)r+  r(  r  r   )r{  rS  re   r+  r(  r  r   r|  s        rf   rS  Rolling.covw
  s(    b w{%	  
 	
ri   z
        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
        correlationra  c                $   > [         TU ]  UUUUS9$ r  )r{  ra  r  s        rf   ra  Rolling.corr
  s(    | w|%	  
 	
ri   )r^   rX   r]  )r  rZ  r^  r  rj  rk  rm  rn  ro  rp  r  r  rq  rs  ru  rw  rx  ry  )*rx   ri  rj  rk  rN   rm  rd   r~  r  r   r.   r   rU  rR  r3   r/   r0   r4   r5   replacer
  r7   rS  r6   r2   r  r  r  r  r%  r  r  r4  r:  rB  r   rF  rN  rS  ra  rp  r  r  s   @rf   r{  r{  ?  sx   
K 
.G`D( 	[!
 
0 !G$J8K$J8 Cl+i(j)j)	
, '$A
 ?E#H+ +I#H+ 	l+i(j)j)
	
   =-6 4804'+(,
 
 
 2	

 .
 %
 &
10
$ 	l+#%i(j)g&j),.	
\ '$A
 %{>B #4804	



 2

 .	

>~

 	l+#%i(j)g&j)
	
   )3: #
 5904

 2	

 .
 
76
 	l+#%i(j)g&j)	
 '$A
 )9@ #4804	



 2

 .	

=<

 	l+#%i(j)g&j)	
( '$A
 &G$N #4804	



 2

 .	

K$J

 	l+#%i(j)g&j)	
 '$A
 (9@ #4804	



 2

 .	

=<

 	l+	
 '$A
#E*i(j):g&	
 '$A
j)	
 '$A
 4W,^ "4804

 
 2	

 .
[,Z
 	l+	
 '$A
#E*i(j):g&	
 '$A
j)	
 '$A
 *W,^ "4804

 
 2	

 .
[,Z
 	l+i(j)Eg&	

 	j)
	
   3? B7 7C B7 	l+	
 '$A
i(j)g&Fj)
	
 '$A
 8? BC B 	l+i(j):g&Hj)	
( '$A
 NG$J7 7K$J7 	l+	
$ '$A
i(j)j)	
" '$A
 *a1d *3? 08"	



 -

 	

 @e1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
 -kvr ,0 $"
(
 
 	

 
ovn
ri   r{  c                  Z    \ rS rSrSr\R                  \R                  -   rSS jrS r	Sr
g)RollingGroupbyi8  z+
Provide a rolling groupby implementation.
c                   SnU R                   n[        U R                  [        5      (       ao  [	        U R                  5      nU R                  R
                  R                  5       n[        U[        5      (       d   eUR                  SS5        U R                  nO2U R                  b  [        nU R                  nO[        nU R                  n[        UUU R                  R                  UUS9nU$ )zk
Return an indexer class that will compute the window start and end bounds

Returns
-------
GroupbyIndexer
Nr  )r  r  groupby_indicesr4  indexer_kwargs)r   ra   rW   r    rr   __dict__r   dictr  r^   r#   r!   r"   rs  r  )re   r  r  rolling_indexerrW   r4  s         rf   r   "RollingGroupby._get_window_indexer?  s     15''dkk;//"4;;/O![[11668Nnd3333}d3[[F*3O &&F0O[[F'# MM11*)
 ri   c                   U R                   R                  (       a  U R                  S5        U R                  R                  R                  5        Ho  nU R                   R                  U5      nUR                  (       a  M1  UR                  (       a  MD  U R                  c  SOU R                  n[        SU SU S35      e   g)z3
Validate that each group in self._on is monotonic
r  Nr_   zEach group within z' must be monotonic. Sort the values in z first.)rP   r  r  rs  r  r   r  r  r  rT   rb   )re   r  group_onrT   s       rf   r~  /RollingGroupby._validate_datetimelike_monotonicb  s    
 88''(BC!]]2299;Mxx}}]3H000H4T4T4T $WTWW ( -**,W6  <ri   re  N)r[  r"   )rx   ri  rj  rk  rl  r{  rN   rr  r   r~  rp  re  ri   rf   r  r  8  s+     %%(9(E(EEK!Fri   r  )yrl  
__future__r   r   datetimer   	functoolsr   rs   textwrapr   typingr   r   r	   r
   numpyr   pandas._libs.tslibsr   r   r    pandas._libs.window.aggregations_libsrW   aggregationsr  pandas.compat._optionalr   pandas.errorsr   pandas.util._decoratorsr   r   pandas.core.dtypes.commonr   r   r   r   r   pandas.core.dtypes.dtypesr   pandas.core.dtypes.genericr   r   pandas.core.dtypes.missingr   pandas.core._numbar   pandas.core.algorithmsr   pandas.core.applyr   pandas.core.arraysr   pandas.core.baser   pandas.core.commoncorecommonr  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/   r0   r1   r2   r3   r4   r5   r6   r7   pandas.core.window.numba_r8   r9   r:   collections.abcr;   r<   r=   pandas._typingr>   r?   r@   rA   rB   rC   r   rD   rE   pandas.core.genericrF   rx  rH   pandas.core.arrays.datetimelikerI   rK   rr  r  r  r{  r  re  ri   rf   <module>r     sE   #        
 ? > > #
  1 - ' , 2 - +       .       ,3 9p pfF:
 F:RC	
Z C	
LB
z B
Js
& s
l ..:& :ri   