+
    Ŝi                   B   R t ^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIt^ RI	H
t
HtHtHtHtHtHtHt ^ RIt^ RIHtHtHt ^ RIHu Hu Ht ^ RIHt ^ RIH t  ^ R	I!H"t" ^ R
I#H$t$H%t%H&t&H't'H(t( ^ RI)H*t* ^ RI+H,t,H-t- ^ RI.H/t/ ^ RI0H1t1 ^ RI2H3t3 ^ RI4H5t5H6t6 ^ RI7H8t8 ^ RI9H:t: ^ RI;H<u H=t> ^ RI?H@t@HAtAHBtBHCtC ^ RIDHEtEHFtFHGtGHHtHHItI ^ RIJHKtK ^ RILHMtMHNtNHOtO ^ RIPHQtQHRtR ^ RISHTtTHUtUHVtV ]
'       d9   ^ RIWHXtX ^ RIWHYtYHZtZH[t[ ^ RI\H]t]H^t^H_t_H`t`HataHbtbHctcHdtd ^ RIeHftfHgtg ^ RIhHiti ^ RIjHktk ^ RIlHmtm  ! R  R!]:4      tn ! R" R#]n4      to]"! R$4       ! R% R&]n4      4       tp ! R' R(]n4      tq]"! R$4       ! R) R*]q4      4       tr]pP                   ]rn         ]"! R$4       ! R+ R,]o]r4      4       tsR# )-zc
Provide a generic structure to support window functions,
similar to how we have a Groupby object.
)annotationsN)	timedelta)partial)TYPE_CHECKINGAnyConcatenateLiteralSelfcastfinaloverload)
BaseOffset	Timedelta	to_offset)import_optional_dependency)	DataError)
set_module)ensure_float64is_bool
is_integeris_numeric_dtypeneeds_i8_conversion)
ArrowDtype)ABCDataFrame	ABCSeries)notna)executor)	factorize)ResamplerWindowApplyreconstruct_func)ExtensionArray)SelectionMixin)BaseIndexerFixedWindowIndexerGroupbyIndexerVariableWindowIndexer)DatetimeIndexIndex
MultiIndexPeriodIndexTimedeltaIndex)concat)get_jit_argumentsmaybe_use_numbaprepare_function_arguments)flex_binary_momentzsqrt)'generate_manual_numpy_nan_agg_with_axisgenerate_numba_apply_funcgenerate_numba_table_func)Callable)HashableIteratorSized)	ArrayLikeNDFrameTQuantileInterpolationPTimeUnitTWindowingRankTypenpt)	DataFrameSeries)NDFrameBaseGrouper)dtype_to_unitc                     ] tR t^tt$ Rt. tR]R&   ]! 4       tR]R&   R]R&   R8R	R/R
 R lllt	R R lt
R R ltR9R R lltR R ltR R ltR:R R lltR9R ltR R ltR tR R ltR R ltR  R! ltR" R# lt]R$ R% l4       tR& R' ltR( R) ltR9R* R+ lltR:R, R- lltR;R. R/ lltR0 R1 ltR<R2 R3 lltR9R4 R5 llt R9R6 lt!]!t"R7t#R# )=
BaseWindowz7Provides utilities for performing windowing operations.	list[str]_attributeszfrozenset[Hashable]
exclusionsr'   _onN	selectionc               <    V ^8  d   QhRRRRRRRRR	R
RRRRRRRR/	# )   objrB   min_periodsz
int | Nonecenterbool | Nonewin_type
str | Noneonzstr | Index | NoneclosedstepmethodstrreturnNone )formats   "c/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/pandas/core/window/rolling.py__annotate__BaseWindow.__annotate__{   sd     % %%  	%
 % % % % % % 
%    c
               	x   Wn         W`n        Wpn        Wn        W n        W0n        W@n        WPn        Wn        R V n	        V P                  f   V P                   P                  V n        M\        V P                  \        4      '       d   V P                  V n        M\        V P                   \        4      '       dR   V P                  V P                   P                  9   d-   \        V P                   V P                  ,          4      V n        M\!        RV P                   R24      hWn        V P%                  4        R # )Nzinvalid on specified as z3, must be a column (of DataFrame), an Index or None)rO   rU   rV   rW   windowrP   rQ   rS   rX   _win_freq_i8indexrK   
isinstancer'   r   columns
ValueError
_selection	_validate)selfrO   rc   rP   rQ   rS   rU   rV   rW   rX   rL   s   &&&&&&&&&&$r^   __init__BaseWindow.__init__{   s     	& (,77?xx~~DH''wwDH,//DGGtxx?O?O4OTXXdgg./DH*477) 4D D 
 $ra   c                   V ^8  d   QhRR/# rN   rZ   r[   r\   )r]   s   "r^   r_   r`      s     )6 )64 )6ra   c                	   V P                   e'   \        V P                   4      '       g   \        R4      hV P                  e   \	        V P                  4      '       g   \        R4      hV P                  ^ 8  d   \        R4      h\	        V P
                  4      '       dA   V P                  V P
                  8  d&   \        RV P                   RV P
                   24      hV P                  e   V P                  R9  d   \        R4      h\        V P                  \        \        34      '       g   \        R\        V 4       24      h\        V P
                  \        4      '       d   \        P                  ! V P
                  P                   4      P"                  P%                  4       p\        P                  ! \        4       P                   4      P"                  P%                  4       pW8w  d,   \        \        V P
                  4      P&                   R24      hV P(                  R9  d   \        R	4      hV P*                  eE   \	        V P*                  4      '       g   \        R
4      hV P*                  ^ 8  d   \        R4      hR # R # )Nzcenter must be a booleanzmin_periods must be an integerzmin_periods must be >= 0zmin_periods z must be <= window z3closed must be 'right', 'left', 'both' or 'neither'zinvalid type: z? does not implement the correct signature for get_window_boundsz!method must be 'table' or 'singlezstep must be an integerzstep must be >= 0)rightbothleftneither)tablesingle)rQ   r   rh   rP   r   rc   rV   rf   rO   r   r   	TypeErrortyper"   inspect	signatureget_window_bounds
parameterskeys__name__rX   rW   )rk   get_window_bounds_signatureexpected_signatures   &  r^   rj   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  !ra   c               (    V ^8  d   QhRRRRRRRR/# )rN   start
np.ndarrayendnum_valsintrZ   r[   r\   )r]   s   "r^   r_   r`      s,      &0<?	ra   c           	     	h   \        V4      \        V4      8w  d%   \        R \        V4       R\        V4       R24      h\        V4      Y0P                  ;'       g    ^,           ^,
          V P                  ;'       g    ^,          8w  d)   \        R\        V4       RV RV P                   R24      hR# )zstart (z) and end (z ) bounds must be the same lengthzstart and end bounds (z)) must be the same length as the object (z) divided by the step (z) if given and rounded upN)lenrh   rW   )rk   r   r   r   s   &&&&r^   _check_window_boundsBaseWindow._check_window_bounds   s     u:S!#e*[S
 ;   u:(iinn159tyy~~ANN(U 5""*+B499+ N*+  Ora   c               $    V ^8  d   QhRRRRRR/# )rN   re   r'   resultzSized | NonerZ   r\   )r]   s   "r^   r_   r`      s"     
 
% 
 
QV 
ra   c                l    Ve   \        V4      \        V4      8X  d   V# VRRV P                  1,          # )z:
Slices the index for a given result and the preset step.
N)r   rW   )rk   re   r   s   &&&r^   _slice_axis_for_stepBaseWindow._slice_axis_for_step   s9     ~VE
!: 	
 |$))|$	
ra   c               $    V ^8  d   QhRRRRRR/# )rN   namerY   numeric_onlyboolrZ   r[   r\   )r]   s   "r^   r_   r`      s!      3 d t ra   c                    V P                   P                  ^8X  dV   V'       dL   \        V P                   P                  4      '       g%   \	        \        V 4      P                   RV R24      hR# R# R# )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.
.z  does not implement numeric_onlyN)_selected_objndimr   dtypeNotImplementedErrorrx   r~   )rk   r   r   s   &&&r^   _validate_numeric_only!BaseWindow._validate_numeric_only   sj     ##q($T%7%7%=%=>>%:&&'q.NO  ?  )ra   c                    V ^8  d   QhRRRR/# )rN   rO   r9   rZ   r\   )r]   s   "r^   r_   r`      s      h 8 ra   c                0    VP                  R.R.R7      pV# )zSubset DataFrame to numeric columns.

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

Returns
-------
obj subset to numeric-only columns.
numberr   )includeexclude)select_dtypes)rk   rO   r   s   && r^   _make_numeric_onlyBaseWindow._make_numeric_only   s"     ""H:}"Mra   c               $    V ^8  d   QhRRRRRR/# rN   rO   r9   r   r   rZ   r\   )r]   s   "r^   r_   r`     s!     	 	 	 	 	ra   c                H   V P                   ej   \        V P                   \        4      '       gJ   VP                  ^8X  d9   VP	                  VP
                  P                  V P                   .RR7      R7      pVP                  ^8  d   V'       d   V P                  V4      pV# )1
Split data into blocks & return conformed data.
F)sort)rg   )rU   rf   r'   r   reindexrg   
differencer   )rk   rO   r   s   &&&r^   _create_dataBaseWindow._create_data  su    
 77z$''5'A'AchhRSm++ckk&<&<dggYU&<&S+TC88a<L))#.C
ra   c                    Vf   V P                   pV P                   Uu/ uF  qD\        W4      bK  	  ppV P                  W4      p\	        V 4      ! V3RV/VB pV# u upi )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
rL   )rO   rI   getattr_infer_selectionrx   )rk   keyr   subsetattrkwargsrL   new_wins   &&&&    r^   _gotitemBaseWindow._gotitem  sk     >XXF 9=8H8HI8H++8HI))#6	t*VCyCFC	 Js   Ac                   V ^8  d   QhRR/# )rN   r   rY   r\   )r]   s   "r^   r_   r`   +  s     
 
 
ra   c                	    WP                   9   d   \        P                  W4      # WP                  9   d	   W,          # \	        R \        V 4      P                   RV R 24      h)'z' object has no attribute ')_internal_names_setobject__getattribute__rO   AttributeErrorrx   r~   )rk   r   s   &&r^   __getattr__BaseWindow.__getattr__+  s\    +++**46688:T
##$$?vQG
 	
ra   c                	6    V P                   P                  4       # N)rO   _dir_additionsrk   s   &r^   r   BaseWindow._dir_additions5  s    xx&&((ra   c                   V ^8  d   QhRR/# )rN   rZ   rY   r\   )r]   s   "r^   r_   r`   8  s     
2 
2# 
2ra   c                   a  V 3R lS P                    4       pRP                  V4      p\        S 4      P                   RV R2# )z0
Provide a nice str repr of our rolling object.
c              3     <"   T F7  p\        SVR 4      f   K  V^ ,          R8w  g   K$  V R\        SV4       2x  K9  	  R # 5i)N_=)r   ).0	attr_namerk   s   & r^   	<genexpr>&BaseWindow.__repr__.<locals>.<genexpr><  sJ      
-	tY- 6>Glc>Q 6yk74345-s   AAA,z [])rI   joinrx   r~   )rk   
attrs_listattrss   f  r^   __repr__BaseWindow.__repr__8  sF    
!--


 $t*%%&bq11ra   c                   V ^8  d   QhRR/# )rN   rZ   r6   r\   )r]   s   "r^   r_   r`   D  s      ( ra   c              #  	  "   V P                   P                  V P                  4      pV P                  V4      pV P	                  4       pVP                  \        V4      V P                  V P                  V P                  V P                  R 7      w  r4V P                  W4\        V4      4       \        W4RR7       F%  w  rVVP                  \        WV4      ,          pVx  K'  	  R# 5i)
num_valuesrP   rQ   rV   rW   T)strictN)r   set_axisrK   r   _get_window_indexerr{   r   rP   rQ   rV   rW   r   zipilocslice)rk   rO   indexerr   r   ser   s   &       r^   __iter__BaseWindow.__iter__D  s       ))$((3$**,..3x((;;;; / 

 	!!%c#h740DAXXeAk*FL 1s   C#C%c                    V ^8  d   QhRRRR/# )rN   valuesr8   rZ   r   r\   )r]   s   "r^   r_   r`   V  s      9  ra   c                H   \        VP                  4      '       d0   \        R\        V 4      P                   RVP                   R24      h \        V\        4      '       d1   VP                  \        P                  \        P                  R7      pM\        V4      p \        P                  ! V4      pVP                  4       '       d'   \        P                   ! V\        P                  V4      pV#   \        \        3 d   p\        RTP                   24      ThRp?ii ; i)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   rx   r~   rf   r    to_numpynpfloat64nanr   rh   rw   isinfanywhere)rk   r   errinfs   &&  r^   _prep_valuesBaseWindow._prep_valuesV  s    v||,,%4:../ 0&:< 	S&.11bffE'/
 hhv7799XXc26662F I& 	S9&,,HIsR	Ss   AC2 C2 2D!DD!c               $    V ^8  d   QhRRRRRR/# )rN   r   r@   rO   rZ   r[   r\   )r]   s   "r^   r_   r`   n  s!     ) )	 )	 )d )ra   c                	z   ^ RI Hp V P                  Ee&   V P                  P	                  VP
                  4      '       g   V P                  P                  pV! V P                  V P                  P
                  VRR7      pWAP                  9   d   WQV&   R# WAP
                  P                  9   d   R# W@P                  P                  9   dg   V P                  P                  pVP                  pVP                  V4      pVP                  VRV 4      p	\        V	4      p
VP                  WV4       R# WQV&   R# R# R# )    rA   NFre   r   copy)pandasrA   rU   rK   equalsre   r   rO   rg   namesr   get_locintersectionr   insert)rk   r   rO   rA   r   	extra_colold_colsnew_colsold_locoverlapnew_locs   &&&        r^   _insert_on_columnBaseWindow._insert_on_columnn  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ra   c                   V ^8  d   QhRR/# )rN   rZ   znpt.NDArray[np.int64] | Noner\   )r]   s   "r^   r_   r`     s      : ra   c                	z   \        V P                  \        \        \        34      '       d   V P                  P
                  # \        V P                  P                  \        4      '       dP   V P                  P                  P                  R 9   d+   V P                  P                  \        P                  R7      # R# )mMr   N)rf   rK   r)   r&   r*   asi8r   r   kindr   r   int64r   s   &r^   _index_arrayBaseWindow._index_array  ss     dhhm^ LMM88== 
338K8Kt8S88$$288$44ra   c               $    V ^8  d   QhRRRRRR/# )rN   outr@   rO   rZ   r\   )r]   s   "r^   r_   r`     s!      9 9  ra   c                    VP                   ^,          ^ 8X  d$   VP                   ^,          ^ 8  d   \        R4      hVP                   ^,          ^ 8X  d   VP                  R4      # V P                  W4       V# )zValidate and finalize result.No numeric types to aggregater   )shaper   astyper  )rk   r  rO   s   &&&r^   _resolve_outputBaseWindow._resolve_output  s_    99Q<11!1;<<99Q<1::i((s(
ra   c                   V ^8  d   QhRR/# )rN   rZ   r"   r\   )r]   s   "r^   r_   r`     s     ; ;[ ;ra   c                    \        V P                  \        4      '       d   V P                  # V P                  e-   \	        V P
                  V P                  V P                  R7      # \        V P                  R7      # )zK
Return an indexer class that will compute the window start and end bounds
)index_arraywindow_sizerQ   )r  )rf   rc   r"   rd   r%   r  rQ   r#   r   s   &r^   r   BaseWindow._get_window_indexer  sb     dkk;//;;(( -- --{{ 
 "dkk::ra   c               $    V ^8  d   QhRRRRRR/# )rN   homogeneous_funcCallable[..., ArrayLike]r   rT   rZ   rA   r\   )r]   s   "r^   r_   r`     s)     D D 8D@JD	Dra   c                   V P                  V P                  4      pVR8X  d   \        V4      P                  \        4      p V P                  VP                  4      pT! T4      pT P                  TP                  T4      pTP                  YgTP                  R7      #   \        \        3 d   p\        R4      ThRp?ii ; i)z%
Series version of _apply_columnwise
countr  Nre   r   )r   r   r   r  r   r   _valuesrw   r   r   r   re   _constructorr   )rk   r  r   rO   r   r   r   re   s   &&&     r^   _apply_seriesBaseWindow._apply_series  s      2 237?*##C(C	F&&s{{3F "&)))#))V<#((CC ./ 	F;<#E	Fs   B C /B;;C c               (    V ^8  d   QhRRRRRRRR/# )	rN   r  r   r   rY   r   r   rZ   DataFrame | Seriesr\   )r]   s   "r^   r_   r`     s2     -- --2-- -- 	--
 
--ra   c                ^   V P                  W#4       V P                  P                  ^8X  d   V P                  W4      # V P	                  V P                  V4      pVR8X  d>   \        V4      P                  \        4      pVP                  P                  4       Vn        . p. p\        VP                  4       4       FA  w  rx V P                  V4      pT! T4      p
TP#                  T
4       TP#                  T4       KC  	  T P%                  VP&                  \)        V4      ^ 8  d
   V^ ,          MR4      p\+        V4      P-                  VVVP.                  P1                  V4      RR7      pV P3                  W4      #   \        \        3 d   p	\        RTP                    24      T	hRp	?	ii ; i)zT
Apply the given function to the DataFrame broken down into homogeneous
sub-frames.
r"  z#Cannot aggregate non-numeric type: NF)re   rg   verify_integrity)r   r   r   r&  r   r   r  r   _mgrconsolidate	enumerate_iter_column_arraysr   rw   r   r   r   appendr   re   r   rx   _from_arraysrg   taker  )rk   r  r   r   rO   taker
res_valuesiarrr   resre   dfs   &&&&         r^   _apply_columnwiseBaseWindow._apply_columnwise  s    	##D7""a'%%&6== 2 2LA7?*##C(Cxx++-CH
 7 7 9:FA'',
 #3'Cc"LLO ; ))IIJ!(;z!}
 #Y##KK$$U+"	 $ 
 ##B,,% 23 9#))Es   E==F,F''F,c               (    V ^8  d   QhRRRRRRRR/# )	rN   r  r   r   rT   r   r   rZ   r)  r\   )r]   s   "r^   r_   r`     s2     . .2. . 	.
 
.ra   c                   V P                   P                  ^8X  d   \        R4      hV P                  V P                   V4      pV P	                  VP                  4       4      pV! V4      pV P                  VP                  V4      pVP                  ^,          \        VP                  4      8X  d   VP                  MVP                  RRV P                  1,          pVP                  WgVR7      p	V P                  W4      # )zD
Apply the given function to the DataFrame across the entire object
z1method='table' not applicable for Series objects.Nre   rg   )r   r   rh   r   r   r   r   re   r  r   rg   rW   r%  r  )
rk   r  r   r   rO   r   r   re   rg   r  s
   &&&&      r^   _apply_tablewiseBaseWindow._apply_tablewise  s     ""a'PQQ 2 2LA""3<<>2!&)))#))V< ||A#ckk"22 KK\		\* 	
 vGD##C--ra   c               0    V ^8  d   QhRRRRRRRRR	R
RR/# rN   targetr)  otherDataFrame | Series | NonepairwiserR   funczFCallable[[DataFrame | Series, DataFrame | Series], DataFrame | Series]r   r   rZ   r\   )r]   s   "r^   r_   r`     sO     P P"P )P 	P
 UP P 
Pra   c                   V P                  W4      pVf   TpVf   RMTpMQ\        V\        \        34      '       g   \	        R4      hVP
                  ^8X  d   V'       d   V P                  V4      p\        WV\        V4      R7      # )M
Apply the given pairwise function given 2 pandas objects (DataFrame/Series)
Tz#other must be a DataFrame or Series)rE  )	r   rf   r   r   rh   r   r   r/   r   )rk   rB  rC  rE  rF  r   s   &&&&&&r^   _apply_pairwiseBaseWindow._apply_pairwise  sx     ""68=E'/tXHEL)#<==BCCZZ1_++E2E!&XOOra   c               (    V ^8  d   QhRRRRRRRR/# )	rN   rF  Callable[..., Any]r   rY   r   r   
numba_argstuple[Any, ...]r\   )r]   s   "r^   r_   r`     s8     ;O ;O ;O ;O 	;O
 $;Ora   c                   a aaaa S P                  4       oS P                  e   S P                  MSP                  oR VVVV V3R llpS P                  R8X  d   S P	                  WbV4      # S P                  WbV4      # )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                   V ^8  d   QhRR/# rN   r   r   r\   )r]   s   "r^   r_   'BaseWindow._apply.<locals>.__annotate__;  s     	 	Z 	ra   c                   < V P                   ^ 8X  d   V P                  4       # VVVVV3R lp\        P                  ! RR7      ;_uu_ 4        V! V 4      pRRR4       V#   + '       g   i     X# ; i)r   c                   < SP                  \        V 4      SSP                  SP                  SP                  R 7      w  rSP                  W\        V 4      4       S! WVS.SO5!  # )r   )r{   r   rQ   rV   rW   r   )xr   r   rF  rP   rM  rk   window_indexers   &  r^   calc9BaseWindow._apply.<locals>.homogeneous_func.<locals>.calcA  sc    +=="1v +;;;; > 
 ))%c!f=Ac;DDDra   ignoreallN)sizer   r   errstate)r   rW  r   rF  rP   rM  rk   rV  s   &  r^   r  +BaseWindow._apply.<locals>.homogeneous_func;  s_     {{a{{}$
E 
E **f + M +* Ms   	AA0	rv   )r   rP   r  rX   r9  r>  )	rk   rF  r   r   rM  r   r  rP   rV  s	   ff&&f, @@r^   _applyBaseWindow._apply  sz    4 113 + ++ 		 	. ;;("))*:,OO(()9NNra   c                    V ^8  d   QhRRRR/# )rN   rF  rL  engine_kwargsdict[str, bool] | Noner\   )r]   s   "r^   r_   r`   W  s     .2 .2 .2 ..2ra   c           	     	   V P                  4       pV P                  e   V P                  MVP                  pV P                  V P                  4      pV P                  VP                  4       4      pVP                  ^8X  d   VP                  R	^4      pVP                  \        V4      VV P                  V P                  V P                  R7      w  rV P                  W\        V4      4       \        P                   p
\        P"                  ! VV
3RR/\%        V4      B pV! VP&                  3RVRV	RV/VB P&                  pV P)                  VP*                  V4      pVP                  ^8X  d0   VP-                  4       pVP/                  WVP0                  R7      pV# V P)                  VP2                  VP&                  4      pVP/                  WVR7      pV P5                  W4      # )
Nr   is_grouped_kernelFr   r   rP   r#  r=  )r   rP   r  r   r   r   r   r   reshaper{   r   rQ   rV   rW   r   r   float_dtype_mappinggenerate_shared_aggregatorr,   r=   r   re   squeezer%  r   rg   r  )rk   rF  rb  func_kwargsrV  rP   rO   r   r   r   dtype_mapping
aggregatorr   re   r  rg   s   &&&,            r^   _numba_applyBaseWindow._numba_applyW  s    113 + ++ 	
  2 23""3<<>2;;!^^B*F#556{#;;;; 6 

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

 HH
!
'*
8C
GR

! 	 ))#))V<88q=^^%F""6SXX"FCJ//VXXFG""6"HC''11ra   c                	    \        V3/ VB w  rArV\        WW#R 7      P                  4       p\        V\        4      '       d$   V'       d   VP
                  RV3,          pWWn        Vf   V P                  VRW#R7      # V# )argsr   :NNNF)rawrr  r   )r   r   aggrf   r   r   rg   apply)rk   rF  rr  r   
relabelingrg   orderr   s   &&*,    r^   	aggregateBaseWindow.aggregate  sp    +;D+KF+K(
'%dtKOOQfl++
[[E*F$N>::dD:HHra   )rK   ri   rd   rQ   rV   rX   rP   rO   rU   rW   rS   rc   )NNFNNNNrv   r   F)NFFr\   )$r~   
__module____qualname____firstlineno____doc__rI   __annotations__	frozensetrJ   rl   rj   r   r   r   r   r   r   r   r   r   r   r   r  propertyr  r  r   r&  r9  r>  rI  r_  rn  rx  rt  __static_attributes__r\   ra   r^   rG   rG   t   s    AK&/kJ#1	J% % %N)6V
(	0
)
2$0)2  ;D(--^.0P.;Oz.2` Cra   rG   c                     a  ] tR tRt$ RtR]R&   R]R&   R.tR]R&   RR	/R
 V 3R llltRR V 3R llltR V 3R llt	RR V 3R lllt
RV 3R lltRtV ;t# )BaseWindowGroupbyi  z+
Provide the groupby windowing facilities.
rD   _grouperr   	_as_indexrH   rI   Tc               (    V ^8  d   QhRRRRRRRR/# )	rN   rO   r)  r  rD   r  r   rZ   r[   r\   )r]   s   "r^   r_   BaseWindowGroupby.__annotate__  s2     / // 	/
 / 
/ra   c               	  < ^ RI Hp \        W&4      '       g   \        R4      hW n        W0n        VP                  V P                  P                  RR7      pVP                  R4      e   \        R4      h\        SV `,  ! V.VO5/ VB  R# )r   rC   zMust pass a BaseGrouper object.rY  rg   errorsrW   Nz step not implemented for groupby)pandas.core.groupby.opsrD   rf   rh   r  r  dropr   getr   superrl   )rk   rO   r  r  rr  r   rD   	__class__s   &&$$*, r^   rl   BaseWindowGroupby.__init__  sy     	8(00>?? " hht}}228hD::f)%&HII.t.v.ra   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )rN   rF  rL  r   rY   r   r   rM  rN  rZ   r)  r\   )r]   s   "r^   r_   r    s<     ; ; ; ; 	;
 $; 
;ra   c           	     	F  < \         SV `  ! VVVV3/ VB pV P                  P                  p. VP                  Op\
        P
                  ! V P                  P                  4      p	W,           p
V P                  P                   Uu. uF/  pWP                  P                  P                  9  g   Ve   K-  VNK1  	  pp\        V4      \        V	4      8w  d   VP                  VRR7      pV P                  P                  p\
        P
                  ! V P                  P                  4      pV P                  P                  P                  4       pV'       d!   \        P                  ! \        V4      4      pM&\        P                   ! . \        P"                  R7      pV Uu. uF  pVP%                  V4      NK  	  ppVe   VP%                  V4      p\'        V\(        4      '       g   \(        P*                  ! V.4      pVP-                  \        VP                  4      4       VP-                  \        VP                  4      4       \)        WV
RR7      pVVn        V P.                  '       g.   VP1                  \        \3        \        V	4      4      4      R7      pV# u upi u upi )NrY  r  r  Fr   r+  )level)r  r_  rO   re   r   r   r  r   r  codeslevelsindicesr   r   concatenatelistarrayintpr2  rf   r(   from_arraysextendr  reset_indexrange)rk   rF  r   r   rM  r   r   grouped_object_indexgrouped_index_namegroupby_keysresult_index_namesr   drop_columnsr  r  group_indicesr   cidxresult_indexr  s   &&&&&,              r^   r_  BaseWindowGroupby._apply  s    	

 
  $xx~~:399:yy!4!45)> }}**
*((.....# C* 	 
 |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3JJc               0    V ^8  d   QhRRRRRRRRR	R
RR/# rA  r\   )r]   s   "r^   r_   r    sO     R R"R )R 	R
 UR R 
Rra   c                  <a VP                  V P                  P                  RR7      p\        SV `  VSW4V4      pSEe   \
        ;QJ dA    V3R lV P                  P                  P                  4        4       F  '       d   K   RM6	  RM2! V3R lV P                  P                  P                  4        4       4      '       Eg   \        V4      p\        V P                  P                  P                  4        Uu. uF-  pVP                  V4      P                  VP                  4      NK/  	  up4      pR V P                  P                  P                  4        4       p	. p
. p\        \        \!        V	RR/ 4       F]  p\"        P$                  ! \"        P&                  ! V4      V4      p\)        V4      w  rV
P+                  V4       VP+                  V4       K_  	  MV P                  P,                  p
V P                  P.                  pV P                  P                  P                  4       pV'       d!   \"        P0                  ! \        V4      4      pM&\"        P&                  ! . \"        P2                  R7      pVP4                  ^8X  d   ^pM\        VP6                  4      pV
 Uu. uF)  p\"        P$                  ! VP                  V4      V4      NK+  	  p
p\9        VP                  \:        4      '       d_   \        VP                  P,                  4      p\        VP                  P.                  4      p\        VP                  P                  4      pM5\)        VP                  4      w  ppV.pV.pVP                  P<                  .pV
V,           pVV,           pV P                  P                  V,           p\;        VVVRR	7      pVVn        V# u upi u upi )
rH  rY  r  c              3  R   <"   T F  p\        V4      \        S4      8H  x  K  	  R # 5ir   )r   )r   grouprC  s   & r^   r   4BaseWindowGroupby._apply_pairwise.<locals>.<genexpr>   s"      )
2PCJ#e*$2Ps   $'FTc              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5ir   )commaybe_make_list)r   pairs   & r^   r   r    s"      6Rd##D))6Rs   #%r   r  r  )r  r  r   r  rI  r[  r  r   r   r+   r2  r   re   r}   mapr  r   r   repeatr  r   r0  r  r  r  r  r   rg   rf   r(   r   )rk   rB  rC  rE  rF  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   &&f&&&                    r^   rI  !BaseWindowGroupby._apply_pairwise  s    T]]%8%8J(USS )
26--2G2G2N2N2P)
SSS )
26--2G2G2N2N2P)
 &
 &
 ![N '+mm&;&;&B&B&D&D
 KK
+33FLLA&DF6:mm6K6K6P6P6RH MN!$T3+F+F!G288M#:NK )& 1$$U+%%f-	 "H !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   <3O+/Oc               $    V ^8  d   QhRRRRRR/# r   r\   )r]   s   "r^   r_   r  E  s!     7 7 7 7 7ra   c                $  < VP                   '       gp   \        P                  ! \        V P                  P
                  P                  4       4      4      P                  \        P                  4      pVP                  V4      p\        SV `-  W4      # )r   )emptyr   r  r  r  r  r   r  r  r2  r  r   )rk   rO   r   groupby_orderr  s   &&& r^   r   BaseWindowGroupby._create_dataE  sf     yyyNN40E0E0L0L0N+OPWWM ((=)Cw#C66ra   c                	   < V P                   e&   V P                  P                  V P                  4      p\        SV `  WVR7      # )N)r   )rU   rO   	set_indexrK   r  r   )rk   r   r   r   r  s   &&&&r^   r   BaseWindowGroupby._gotitemS  s<     77XX''1Fw&99ra   )r  r  r{  rz  r   )r~   r|  r}  r~  r  r  rI   rl   r_  rI  r   r   r  __classcell__r  s   @r^   r  r    sa     O(\K)/
 / /.; ;zR Rh7 7: :ra   r  zpandas.api.typingc                     a  ] tR tRtRt. ROtR V 3R lltR R ltRR R lltRR	 lt	]	t
RR
 R lltRR R lltRR R lltRR R lltRtV ;t# )Windowi]  a  
Provide rolling window calculations.

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

    If an integer, the delta between the start and end of each window.
    The number of points in the window depends on the ``closed`` argument.

    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
    :ref:`this link<timeseries.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.

closed : str, default None
    Determines the inclusivity of points in the window

    If ``'right'``, uses the window (first, last] meaning the last point
    is included in the calculations.

    If ``'left'``, uses the window [first, last) meaning the first point
    is included in the calculations.

    If ``'both'``, uses the window [first, last] meaning all points in
    the window are included in the calculations.

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

    () and [] are referencing open and closed set
    notation respetively.

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

step : int, default None
    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'

    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
c                   V ^8  d   QhRR/# ro   r\   )r]   s   "r^   r_   Window.__annotate__e  s     U U4 Ura   c                	,  < \         SV `  4        \        V P                  \        4      '       g   \        R V P                   24      h\        RRR7      p\        WP                  R4      V n        V P                  f   \        R V P                   24      h\        V P                  \        4      '       d   \        R4      h\        V P                  4      '       d   V P                  ^ 8  d   \        R4      hV P                  R8w  d   \        R4      hR# )	zInvalid win_type zscipy.signal.windowsz,Scipy is required to generate window weight.)extraNz6BaseIndexer subclasses not implemented with win_types.&window must be an integer 0 or greaterrv   z+'single' is the only supported method type.)r  rj   rf   rS   rY   rh   r   r   _scipy_weight_generatorrc   r"   r   r   rX   )rk   signalr  s   & r^   rj   Window._validatee  s    $----0@AA+"*X
 (/v}}d'K$''/0@AAdkk;//%H  $++&&$++/EFF;;("%&STT #ra   c               $    V ^8  d   QhRRRRRR/# )rN   r   r   offsetr   rZ   r\   )r]   s   "r^   r_   r  {  s!      Z   ra   c                z    V^ 8  d4   \        VR4      .p\        P                  ! V\        V4      ,          4      pV# )zD
Center the result in the window for weighted rolling aggregations.
N)r   r   r   tuple)rk   r   r  lead_indexers   &&& r^   _center_windowWindow._center_window{  s7     A:!&$/0LWWVE,$789Fra   c               (    V ^8  d   QhRRRRRRRR/# )	rN   rF  z,Callable[[np.ndarray, int, int], np.ndarray]r   rY   r   r   rM  rN  r\   )r]   s   "r^   r_   r    s2     <
 <
:<
 <
 	<

 $<
ra   c                  a aaa S P                   ! S P                  3/ VB oS P                  '       d   \        S4      ^,
          ^,          M^ oR VVV V3R llpS P	                  WbV4      RRS P
                  1,          # )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
c                   V ^8  d   QhRR/# rQ  r\   )r]   s   "r^   r_   #Window._apply.<locals>.__annotate__  s     	 	Z 	ra   c                R  < V P                   ^ 8X  d   V P                  4       # VVVV3R lp\        P                  ! RR7      ;_uu_ 4        \        P                  ! V! V 4      4      pRRR4       SP
                  '       d   SP                  XS4      pX#   + '       g   i     L6; i)r   c                   < \         P                  ! S\         P                  4      p\         P                  ! W34      p S! T SSP                  e   SP                  4      # \        S4      4      # r   )r   fullr   r  rP   r   )rU  additional_nansrF  r  rk   rc   s   & r^   rW  5Window._apply.<locals>.homogeneous_func.<locals>.calc  sd    "$''&"&&"9NNA#78(,(8(8(DD$$  KNf+ ra   rY  rZ  N)r\  r   r   r]  asarrayrQ   r  )r   rW  r   rF  r  rk   rc   s   &  r^   r  'Window._apply.<locals>.homogeneous_func  sz     {{a{{}$  **DL1 + {{{,,VV<M +*s   BB&	N)r  rc   rQ   r   r9  rW   )	rk   rF  r   r   rM  r   r  r  rc   s	   ff&&&, @@r^   r_  Window._apply  st    : --KK
!
 ,0;;;#f+/a'A	 	0 %%&6lKtyyL
 	
ra   c                T    \        WW#R7      P                  4       pVf	   V! V 4      pV# )a  
Aggregate using one or more operations over the specified axis.

Parameters
----------
func : function, str, list or dict
    Function to use for aggregating the data. If a function, must either
    work when passed a Series/DataFrame or
    when passed to Series/DataFrame.apply.

    Accepted combinations are:

    - function
    - string function name
    - list of functions and/or function names, e.g. ``[np.sum, 'mean']``
    - dict of axis labels -> functions, function names or list of such.

*args
    Positional arguments to pass to `func`.
**kwargs
    Keyword arguments to pass to `func`.

Returns
-------
scalar, Series or DataFrame

    The return can be:

    * scalar : when Series.agg is called with single function
    * Series : when DataFrame.agg is called with a single function
    * DataFrame : when DataFrame.agg is called with several functions

See Also
--------
DataFrame.aggregate : Similar DataFrame method.
Series.aggregate : Similar Series method.

Notes
-----
The aggregation operations are always performed over an axis, either the
index (default) or the column axis. This behavior is different from
`numpy` aggregation functions (`mean`, `median`, `prod`, `sum`, `std`,
`var`), where the default is to compute the aggregation of the flattened
array, e.g., ``numpy.mean(arr_2d)`` as opposed to
``numpy.mean(arr_2d, axis=0)``.

`agg` is an alias for `aggregate`. Use the alias.

Functions that mutate the passed object can produce unexpected
behavior or errors and are not supported. See :ref:`gotchas.udf-mutation`
for more details.

A passed user-defined-function will be passed a Series for evaluation.

If ``func`` defines an index relabeling, ``axis`` must be ``0`` or ``index``.

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
rq  )r   rt  )rk   rF  rr  r   r   s   &&*, r^   rx  Window.aggregate  s-    P &dtKOOQ>$ZFra   c                   V ^8  d   QhRR/# rN   r   r   r\   )r]   s   "r^   r_   r    s     8
 8
 8
ra   c                P    \         P                  pV P                  ! V3RRRV/VB # )a  
Calculate the rolling weighted window sum.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

**kwargs
    Keyword arguments to configure the ``SciPy`` weighted window type.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.sum : Aggregating sum for Series.
DataFrame.sum : Aggregating sum for DataFrame.

Examples
--------
>>> 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.api.typing.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
r   sumr   )window_aggregationsroll_weighted_sumr_  rk   r   r   window_funcs   &&, r^   r  
Window.sum  sB    ^ *;; {{

 &
 	
 	
ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r  M  s     7
 7
 7
ra   c                P    \         P                  pV P                  ! V3RRRV/VB # )at  
Calculate the rolling weighted window mean.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

**kwargs
    Keyword arguments to configure the ``SciPy`` weighted window type.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.mean : Aggregating mean for Series.
DataFrame.mean : Aggregating mean for DataFrame.

Examples
--------
>>> 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.api.typing.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
r   meanr   )r  roll_weighted_meanr_  r  s   &&, r^   r  Window.meanM  sB    \ *<< {{

 &
 	
 	
ra   c                    V ^8  d   QhRRRR/# rN   ddofr   r   r   r\   )r]   s   "r^   r_   r    s     3Y 3Y 3Yt 3Yra   c                    \        \        P                  VR7      pVP                  RR4       V P                  ! V3RRRV/VB # )a  
Calculate the rolling weighted window variance.

Parameters
----------
ddof : int, default 1
    Delta Degrees of Freedom.  The divisor used in calculations
    is ``N - ddof``, where ``N`` represents the number of elements.
numeric_only : bool, default False
    Include only float, int, boolean columns.

**kwargs
    Keyword arguments to configure the ``SciPy`` weighted window type.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.var : Aggregating var for Series.
DataFrame.var : Aggregating var for DataFrame.

Examples
--------
>>> 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.api.typing.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
r  r   Nvarr   )r   r  roll_weighted_varpopr_  )rk   r  r   r   r  s   &&&, r^   r  
Window.var  sE    b 1CC$O

64 {{;XUXXQWXXra   c                    V ^8  d   QhRRRR/# r  r\   )r]   s   "r^   r_   r    s     3
 3
 3
t 3
ra   c                D    \        V P                  ! RRVRRRV/VB 4      # )a0  
Calculate the rolling weighted window standard deviation.

Parameters
----------
ddof : int, default 1
    Delta Degrees of Freedom.  The divisor used in calculations
    is ``N - ddof``, where ``N`` represents the number of elements.
numeric_only : bool, default False
    Include only float, int, boolean columns.

**kwargs
    Keyword arguments to configure the ``SciPy`` weighted window type.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.std : Aggregating std for Series.
DataFrame.std : Aggregating std for DataFrame.

Examples
--------
>>> 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.api.typing.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
r  r   stdr   r\   )r0   r  )rk   r  r   r   s   &&&,r^   r  
Window.std  s0    b HHP$PUPPP
 	
ra   )r  rc   rP   rQ   rS   rU   rV   rW   rX   r{  r   rz     F)r~   r|  r}  r~  r  rI   rj   r  r_  rx  rt  r  r  r  r  r  r  r  s   @r^   r  r  ]  sS    yv	KU U,<
|M^ C8
t7
r3Yj3
 3
ra   r  c                     ] tR tRtR2R R lltR3R R lltR R lt]R	 R
 l4       t]R R l4       tR R ltR4R R llt	R4R R llt
R4R R lltR4R R lltR4R R lltR5R R lltR5R R lltR2R R lltR6R R  lltR2R! R" lltR2R# R$ lltR2R% R& lltR7R' R( lltR8R) R* lltR2R+ R, lltR9R- R. lltR9R/ R0 lltR1tR# ):RollingAndExpandingMixini  c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   %RollingAndExpandingMixin.__annotate__  s     Q Q$ Qra   c                	J    \         P                  pV P                  VR VR7      # )r"  r   r   )r  roll_sumr_  rk   r   r  s   && r^   r"  RollingAndExpandingMixin.count  s"    )22{{;W<{PPra   Nc               0    V ^8  d   QhRRRRRRRRR	R
RR/# rN   rF  rL  rs  r   engine!Literal['cython', 'numba'] | Nonerb  rc  rr  ztuple[Any, ...] | Noner   zdict[str, Any] | Noner\   )r]   s   "r^   r_   r    sF     +
 +
 +
 +
 2	+

 .+
 %+
 &+
ra   c                	   Vf   R
pVf   / p\        V4      '       g   \        R4      hR
p\        V4      '       d_   VRJ d   \        R4      h\        WV^R7      w  rvV P                  R8X  d   \        V3/ \        V4      B pMJ\        V3/ \        V4      B pM4VR9   d#   Ve   \        R4      hV P                  WVW!4      pM\        R4      hV P                  VRVR	7      # )Nz'raw parameter must be `True` or `False`Fz.raw must be `True` when using the numba engine)num_required_argsrv   z+cython engine does not accept engine_kwargsz)engine must be either 'numba' or 'cython'ru  )r   rM  r\   )cythonN)
r   rh   r-   r.   rX   r2   r,   r3   _generate_cython_apply_funcr_  )	rk   rF  rs  r  rb  rr  r   rM  
apply_funcs	   &&&&&&&  r^   ru  RollingAndExpandingMixin.apply  s    <D>Fs||FGG&(
6""e| !QRR!;Fa"J {{h&6-m<
 7-m<
 ''( !NOO99$RJHII{{!  
 	
ra   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )rN   rr  rN  r   zdict[str, Any]rs  zbool | np.bool_functionrL  rZ   z?Callable[[np.ndarray, np.ndarray, np.ndarray, int], np.ndarray]r\   )r]   s   "r^   r_   r  #  s=        	
 % 
Ira   c                	|   a aa ^ RI Ho \        \        P                  VV\        V4      VR7      oV3VV V3R llpV# )r   r   )rr  r   rs  r   c                P   < V'       g   S! V SP                   R R7      p S! WW#4      # )F)re   r   )rK   )r   beginr   rP   rs  rA   rk   r  s   &&&&&r^   r  HRollingAndExpandingMixin._generate_cython_apply_func.<locals>.apply_func4  s%    dhhUCvc??ra   )r   rA   r   r  
roll_applyr   )rk   rr  r   rs  r   r  rA   r  s   f&&&& @@r^   r  4RollingAndExpandingMixin._generate_cython_apply_func#  sE     	"**S	
 =@ 	@ 	@ ra   c               (    V ^8  d   QhRRRRRRRR/# 	rN   rF  z!Callable[Concatenate[Self, P], T]rr  zP.argsr   zP.kwargsrZ   r=   r\   )r]   s   "r^   r_   r  =  2      /  	
 
ra   c                	    R # r   r\   rk   rF  rr  r   s   &&*,r^   pipeRollingAndExpandingMixin.pipe<       ra   c               (    V ^8  d   QhRRRRRRRR/# rN   rF  ztuple[Callable[..., T], str]rr  r   r   rZ   r=   r\   )r]   s   "r^   r_   r  E  2      *  	
 
ra   c                	    R # r   r\   r+  s   &&*,r^   r,  r-  D  r.  ra   c               (    V ^8  d   QhRRRRRRRR/# rN   rF  z@Callable[Concatenate[Self, P], T] | tuple[Callable[..., T], str]rr  r   r   rZ   r=   r\   )r]   s   "r^   r_   r  L  s2     5 5N5 5 	5
 
5ra   c                	6    \         P                  ! W.VO5/ VB # r   )r  r,  r+  s   &&*,r^   r,  r-  L  s     xx4T4V44ra   c               $    V ^8  d   QhRRRRRR/# rN   r   r   r  r  rb  rc  r\   )r]   s   "r^   r_   r  T  -     O OO 2O .	Ora   c                	   \        V4      '       dW   V P                  R 8X  d/   \        \        P                  4      pV P                  VRVVR7      # ^ RIHp V P                  WS4      # \        P                  pV P                  VRVR7      # )ru   Trs  r  rb  )sliding_sumr  r  )r-   rX   r1   r   nansumru  pandas.core._numba.kernelsr;  rn  r  r  r_  )rk   r   r  rb  rF  r;  r  s   &&&&   r^   r  RollingAndExpandingMixin.sumT  s     6""{{g%>ryyIzz!"/	 "   C((DD)22{{;U{NNra   c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r  j  r8  ra   c                	   \        V4      '       dY   V P                  R 8X  d/   \        \        P                  4      pV P                  VRVVR7      # ^ RIHp V P                  WSRR7      # \        P                  pV P                  VRVR7      # )ru   Tr:  sliding_min_maxis_maxmaxr  )r-   rX   r1   r   nanmaxru  r=  rB  rn  r  roll_maxr_  rk   r   r  rb  rF  rB  r  s   &&&&   r^   rE  RollingAndExpandingMixin.maxj  s     6""{{g%>ryyIzz!"/	 "   G((PT(UU)22{{;U{NNra   c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r    r8  ra   c                	   \        V4      '       dY   V P                  R 8X  d/   \        \        P                  4      pV P                  VRVVR7      # ^ RIHp V P                  WSRR7      # \        P                  pV P                  VRVR7      # )ru   Tr:  rA  FrC  minr  )r-   rX   r1   r   nanminru  r=  rB  rn  r  roll_minr_  rH  s   &&&&   r^   rL  RollingAndExpandingMixin.min  s     6""{{g%>ryyIzz!"/	 "   G((PU(VV)22{{;U{NNra   c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r    s-     P PP 2P .	Pra   c                	   \        V4      '       dW   V P                  R 8X  d/   \        \        P                  4      pV P                  VRVVR7      # ^ RIHp V P                  WS4      # \        P                  pV P                  VRVR7      # )ru   Tr:  )sliding_meanr  r  )r-   rX   r1   r   nanmeanru  r=  rR  rn  r  	roll_meanr_  )rk   r   r  rb  rF  rR  r  s   &&&&   r^   r  RollingAndExpandingMixin.mean  s     6""{{g%>rzzJzz!"/	 "   D((EE)33{{;V,{OOra   c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r    s-     R RR 2R .	Rra   c                	   \        V4      '       dQ   V P                  R 8X  d   \        \        P                  4      pM\        P                  pV P                  VRVVR7      # \        P                  pV P                  VRVR7      # )ru   Tr:  medianr  )	r-   rX   r1   r   	nanmedianru  r  roll_median_cr_  )rk   r   r  rb  rF  r  s   &&&&  r^   rX  RollingAndExpandingMixin.median  sv     6""{{g%>r||L||::+	    *77{{;XL{QQra   c               (    V ^8  d   QhRRRRRRRR/# 	rN   r  r   r   r   r  r  rb  rc  r\   )r]   s   "r^   r_   r    s2     
 

 
 2	

 .
ra   c                	   aa \        V4      '       d?   V P                  R 8X  d   \        R4      h^ RIHp \        V P                  WTSR7      4      # \        P                  oVV3R lpV P                  VRVR7      # )ru   z%std not supported with method='table'sliding_varr   c           
     ,   < \        S! WW#SR 7      4      # )r   )r0   )r   r#  r   rP   r  r  s   &&&&r^   
zsqrt_func0RollingAndExpandingMixin.std.<locals>.zsqrt_func  s    VC4PQQra   r  r  )
r-   rX   r   r=  r`  r0   rn  r  roll_varr_  )rk   r  r   r  rb  r`  rb  r  s   &f&&&  @r^   r  RollingAndExpandingMixin.std  sx     6""{{g%)*QRR>**;D*QRR)22	R {{%  
 	
ra   c               (    V ^8  d   QhRRRRRRRR/# r]  r\   )r]   s   "r^   r_   r    s2     
 

 
 2	

 .
ra   c                	    \        V4      '       d6   V P                  R 8X  d   \        R4      h^ RIHp V P                  WTVR7      # \        \        P                  VR7      pV P                  VRVR7      # )ru   z%var not supported with method='table'r_  r   r  r  )
r-   rX   r   r=  r`  rn  r   r  rd  r_  )rk   r  r   r  rb  r`  r  s   &&&&&  r^   r  RollingAndExpandingMixin.var  sr     6""{{g%)*QRR>$$[d$KK1::F{{%  
 	
ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r         
 
 
ra   c                	J    \         P                  pV P                  VR VR7      # )skewr  )r  	roll_skewr_  r  s   && r^   rl  RollingAndExpandingMixin.skew  ,    )33{{%  
 	
ra   c                    V ^8  d   QhRRRR/# r  r\   )r]   s   "r^   r_   r    s       t ra   c                	    V P                  R V4       V P                  W!R7      V P                  VR7      P                  R4      ,          # )semr   r  r         ?r   r  r"  powrk   r  r   s   &&&r^   rr  RollingAndExpandingMixin.sem  sA    ##E<8xx\x=JJLJ1
#c( 	ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r    rj  ra   c                	J    \         P                  pV P                  VR VR7      # )kurtr  )r  	roll_kurtr_  r  s   && r^   r|  RollingAndExpandingMixin.kurt  ro  ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r    s     
 
$ 
ra   c                	J    \         P                  pV P                  VR VR7      # )firstr  )r  
roll_firstr_  r  s   && r^   r  RollingAndExpandingMixin.first  s,    )44{{%  
 	
ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r    rj  ra   c                	J    \         P                  pV P                  VR VR7      # )lastr  )r  	roll_lastr_  r  s   && r^   r  RollingAndExpandingMixin.last  ro  ra   c               $    V ^8  d   QhRRRRRR/# rN   qfloatinterpolationr:   r   r   r\   )r]   s   "r^   r_   r    s-     T TT -T 	Tra   c                	    VR 8X  d   \         P                  pM4VR8X  d   \         P                  pM\        \         P                  VVR7      pV P                  VRVR7      # )g      ?g        )quantiler  r  r  )r  rG  rN  r   roll_quantiler_  )rk   r  r  r   r  s   &&&& r^   r  !RollingAndExpandingMixin.quantile  sX     8-66K#X-66K!#11+K {{;Zl{SSra   c               (    V ^8  d   QhRRRRRRRR/# rN   rX   r>   	ascendingr   pctr   r\   )r]   s   "r^   r_   r  '  s8     P P!P P 	P
 Pra   c                	d    \        \        P                  VVVR 7      pV P                  VRVR7      # ))rX   r  
percentilerankr  )r   r  	roll_rankr_  )rk   rX   r  r  r   r  s   &&&&& r^   r  RollingAndExpandingMixin.rank'  s7     ))	
 {{;V,{OOra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r  7  s     S SSra   c                	\    \        \        P                  4      pV P                  VR VR7      # )nuniquer  )r   r  roll_nuniquer_  r  s   && r^   r   RollingAndExpandingMixin.nunique7  s.     ,,
 {{;Y\{RRra   c               (    V ^8  d   QhRRRRRRRR/# 	rN   rC  rD  rE  rR   r  r   r   r   r\   )r]   s   "r^   r_   r  A  s2     -
 -
(-
 -
 	-

 -
ra   c                	   a aa S P                   e   \        R4      hS P                  RV4       ^ RIHo VVV 3R lpS P                  S P                  WWT4      # )Nzstep not implemented for covcovr   c                  < SP                  V 4      pSP                  V4      pSP                  4       pSP                  e   SP                  MVP                  pVP	                  \        V4      VSP                  SP                  SP                  R7      w  rgSP                  Wg\        V4      4       \        P                  ! RR7      ;_uu_ 4        \        P                  ! W#,          WgV4      p\        P                  ! W&Wu4      p	\        P                  ! W6Wu4      p
\        P                  ! \        W#,           4      P!                  \        P"                  4      Wg^ 4      pWV
,          ,
          WS,
          ,          ,          pR R R 4       S! XV P$                  V P&                  RR7      #   + '       g   i     L0; i)Nr   rY  rZ  Fr   )r   r   rP   r  r{   r   rQ   rV   rW   r   r   r]  r  rT  r  r   r  r   re   r   )rU  yx_arrayy_arrayrV  rP   r   r   mean_x_ymean_xmean_y	count_x_yr   rA   r  rk   s   &&           r^   cov_func.RollingAndExpandingMixin.cov.<locals>.cov_funcN  sh   ''*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   B4F//F?	rW   r   r   r   rA   rI  r   )rk   rC  rE  r  r   r  rA   s   f&&f& @r^   r  RollingAndExpandingMixin.covA  sV     99 %&DEE##E<8!	J< ##
 	
ra   c               (    V ^8  d   QhRRRRRRRR/# r  r\   )r]   s   "r^   r_   r  p  s2     7
 7
(7
 7
 	7

 7
ra   c                	   a aa S P                   e   \        R4      hS P                  RV4       ^ RIHo VVV 3R lpS P                  S P                  WWT4      # )Nzstep not implemented for corrcorrr   c           	       < SP                  V 4      pSP                  V4      pSP                  4       pSP                  e   SP                  MVP                  pVP	                  \        V4      VSP                  SP                  SP                  R7      w  rgSP                  Wg\        V4      4       \        P                  ! RR7      ;_uu_ 4        \        P                  ! W#,          WgV4      p\        P                  ! W&Wu4      p	\        P                  ! W6Wu4      p
\        P                  ! \        W#,           4      P!                  \        P"                  4      Wg^ 4      p\        P$                  ! W&WuS4      p\        P$                  ! W6WuS4      pWV
,          ,
          WS,
          ,          ,          pW,          R,          pW,          pR R R 4       S! XV P&                  V P(                  RR7      #   + '       g   i     L0; i)Nr   rY  rZ  ru  Fr   )r   r   rP   r  r{   r   rQ   rV   rW   r   r   r]  r  rT  r  r   r  r   rd  re   r   )rU  r  r  r  rV  rP   r   r   r  r  r  r  x_vary_var	numeratordenominatorr   rA   r  rk   s   &&               r^   	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;G66H	r  )rk   rC  rE  r  r   r  rA   s   f&&f& @r^   r  RollingAndExpandingMixin.corrp  sW     99 %&EFF##FL9!&	JP ##
 	
ra   r\   rz  FNNNNFNNr  FNNr
  linearFaverageTFFNNr  F)r~   r|  r}  r~  r"  ru  r  r   r,  r  rE  rL  r  rX  r  r  rl  rr  r|  r  r  r  r  r  r  r  r  r\   ra   r^   r  r    s    Q+
Z2    5O,O,O,P,R*
0
(



T&P S-
^7
 7
ra   r  c                  ^  a  ] tR tRt$ . R;OtR]R&   R V 3R lltR R ltR R	 ltR<V 3R llt	]	t
R=R V 3R llltR>R V 3R lllt]R R l4       t]R R l4       t]R V 3R ll4       tR?R V 3R llltR=RR
RR
/R V 3R lllltR?R V 3R llltR?R V 3R llltR?R  V 3R! llltR@R" V 3R# llltR@R$ V 3R% llltR=R& V 3R' llltRAR( R) lltR=R* V 3R+ llltR=R, V 3R- llltR=R. V 3R/ llltRBR0 V 3R1 llltRCR2 V 3R3 llltR=R4 V 3R5 llltRDR6 V 3R7 llltRDR8 V 3R9 lllt R:t!V ;t"# )ERollingi  rH   rI   c                   V ^8  d   QhRR/# ro   r\   )r]   s   "r^   r_   Rolling.__annotate__  s     /G /G4 /Gra   c                	N  < \         SV `  4        V P                  P                  '       g}   \	        V P
                  \        \        \        34      '       gR   \	        V P
                  P                  \        4      '       Ed   V P
                  P                  P                  R 9   Ed^   \	        V P                  \        \        \        34      '       Ed2   V P!                  4         \#        V P                  4      p\	        T P
                  \        4      '       d]   TP(                  T P
                  P*                  P(                  T P
                  P*                  P,                  ,          ,          T n        M_ \1        T P
                  P                  4      p\3        RT4      p\5        TP(                  4      P7                  T4      P8                  T n        T P:                  f   ^T n        T P<                  e   \?        R4      hR# \	        V P                  \@        4      '       d   R# \C        V P                  4      '       d   V P                  ^ 8  d   \'        R4      hR#   \$        \&        3 d    p\'        RT P                   R24      ThRp?ii ; i  \$         d    Rp ELi ; i)r
  zpassed window z, is not compatible with a datetimelike indexNnsr<   z,step is not supported with frequency windowsr  )"r  rj   rO   r  rf   rK   r&   r*   r)   r   r   r  rc   rY   r   r    _validate_datetimelike_monotonicr   rw   rh   nanosfreqnrd   rE   r
   r   as_unit_valuerP   rW   r   r"   r   )rk   r  r   unitr  s   &   r^   rj   Rolling._validate  s    HHNNN$((]NK$PQQ488>>:66488>>;N;NRV;VsJ	&BCC113 - $((K00 %)JJHHMM''$((--//9%! (8D J-$-djj$9$A$A$$G$N$N! '#$ yy$)B  %
 [11DKK((DKK!OEFF -<A z*  $T[[M 2; ;  !  D s*   %I  7J  J1JJJ$#J$c                   V ^8  d   QhRR/# ro   r\   )r]   s   "r^   r_   r    s     D D$ Dra   c                    V P                   P                  '       d   V P                  R4       V P                   P                  '       g2   V P                   P                  '       g   V P                  R4       R# R# R# )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)rK   hasnans_raise_monotonic_erroris_monotonic_increasingis_monotonic_decreasingr   s   &r^   r  (Rolling._validate_datetimelike_monotonic  sZ    
 88''(BC000DHH4T4T4T''(BC 5U0ra   c                   V ^8  d   QhRR/# )rN   msgrY   r\   )r]   s   "r^   r_   r    s     ( (# (ra   c                	F    V P                   pVf   Rp\        V RV 24      h)Nre    )rU   rh   )rk   r  rU   s   && r^   r  Rolling._raise_monotonic_error  s*    WW:BB4q''ra   Nc                ,   < \         SV `  ! V.VO5/ VB # )a  
Aggregate using one or more operations over the specified axis.

Parameters
----------
func : function, str, list or dict
    Function to use for aggregating the data. If a function, must either
    work when passed a Series/Dataframe or
    when passed to Series/Dataframe.apply.

    Accepted combinations are:

    - function
    - string function name
    - list of functions and/or function names, e.g. ``[np.sum, 'mean']``
    - dict of axis labels -> functions, function names or list of such.

*args
    Positional arguments to pass to `func`.
**kwargs
    Keyword arguments to pass to `func`.

Returns
-------
scalar, Series or DataFrame

    The return can be:

    * scalar : when Series.agg is called with single function
    * Series : when DataFrame.agg is called with a single function
    * DataFrame : when DataFrame.agg is called with several functions

See Also
--------
Series.rolling : Calling object with Series data.
DataFrame.rolling : Calling object with DataFrame data.

Notes
-----
The aggregation operations are always performed over an axis, either the
index (default) or the column axis. This behavior is different from
`numpy` aggregation functions (`mean`, `median`, `prod`, `sum`, `std`,
`var`), where the default is to compute the aggregation of the flattened
array, e.g., ``numpy.mean(arr_2d)`` as opposed to
``numpy.mean(arr_2d, axis=0)``.

`agg` is an alias for `aggregate`. Use the alias.

Functions that mutate the passed object can produce unexpected
behavior or errors and are not supported. See :ref:`gotchas.udf-mutation`
for more details.

A passed user-defined-function will be passed a Series for evaluation.

If ``func`` defines an index relabeling, ``axis`` must be ``0`` or ``index``.

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
)r  rx  rk   rF  rr  r   r  s   &&*,r^   rx  Rolling.aggregate  s     \ w 7777ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r  J  s     ++ ++$ ++ra   c                "   < \         SV `  V4      # )a	  
Calculate the rolling count of non NaN observations.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.count : Aggregating count for Series.
DataFrame.count : Aggregating count for DataFrame.

Examples
--------
>>> 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"  rk   r   r  s   &&r^   r"  Rolling.countJ  s    V w}\**ra   c               0    V ^8  d   QhRRRRRRRRR	R
RR/# r  r\   )r]   s   "r^   r_   r  w  sN     P
 P
 P
 P
 2	P

 .P
 %P
 &P
ra   c           	     .   < \         SV `  VVVVVVR7      # )a  
Calculate the rolling custom aggregation function.

Parameters
----------
func : function
    Must produce a single value from an ndarray input if ``raw=True``
    or a single value from a Series if ``raw=False``. Can also accept a
    Numba JIT function with ``engine='numba'`` specified.

raw : bool, default False
    * ``False`` : passes each row or column as a Series to the
      function.
    * ``True`` : the passed function will receive ndarray
      objects instead.

    If you are just applying a NumPy reduction function this will
    achieve much better performance.

engine : str, default None
    * ``'cython'`` : Runs rolling apply through C-extensions from cython.
    * ``'numba'`` : Runs rolling apply through JIT compiled code from numba.
      Only available when ``raw`` is set to ``True``.
    * ``None`` : Defaults to ``'cython'`` or
      globally setting ``compute.use_numba``.

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``.

    The default ``engine_kwargs`` for the ``'numba'`` engine is
    ``{'nopython': True, 'nogil': False, 'parallel': False}`` and will be
    applied to both the ``func`` and the ``apply`` rolling aggregation.

args : tuple, default None
    Positional arguments to be passed into func.

kwargs : dict, default None
    Keyword arguments to be passed into func.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.apply : Aggregating apply for Series.
DataFrame.apply : Aggregating apply for DataFrame.

Examples
--------
>>> 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
)rs  r  rb  rr  r   )r  ru  )rk   rF  rs  r  rb  rr  r   r  s   &&&&&&&r^   ru  Rolling.applyw  s.    R w}'  
 	
ra   c               (    V ^8  d   QhRRRRRRRR/# r(  r\   )r]   s   "r^   r_   r    r)  ra   c                	    R # r   r\   r+  s   &&*,r^   r,  Rolling.pipe  r.  ra   c               (    V ^8  d   QhRRRRRRRR/# r0  r\   )r]   s   "r^   r_   r    r1  ra   c                	    R # r   r\   r+  s   &&*,r^   r,  r    r.  ra   c               (    V ^8  d   QhRRRRRRRR/# r4  r\   )r]   s   "r^   r_   r    s8     T3 T3NT3 T3 	T3
 
T3ra   c                ,   < \         SV `  ! V.VO5/ VB # )a  
Apply a ``func`` with arguments to this Rolling object and return its result.

Use `.pipe` when you want to improve readability by chaining together
functions that expect
Series, DataFrames, GroupBy, Rolling, Expanding or Resampler
objects.
Instead of writing

>>> h = lambda x, arg2, arg3: x + 1 - arg2 * arg3
>>> g = lambda x, arg1: x * 5 / arg1
>>> f = lambda x: x**4
>>> df = pd.DataFrame(
...     {"A": [1, 2, 3, 4]}, index=pd.date_range("2012-08-02", periods=4)
... )
>>> h(g(f(df.rolling("2D")), arg1=1), arg2=2, arg3=3)  # doctest: +SKIP

You can write

>>> (
...     df.rolling("2D").pipe(f).pipe(g, arg1=1).pipe(h, arg2=2, arg3=3)
... )  # doctest: +SKIP

which is much more readable.

Parameters
----------
func : callable or tuple of (callable, str)
    Function to apply to this Rolling object or, alternatively,
    a `(callable, data_keyword)` tuple where `data_keyword` is a
    string indicating the keyword of `callable` that expects the
    Rolling object.
*args : iterable, optional
    Positional arguments passed into `func`.
**kwargs : dict, optional
        A dictionary of keyword arguments passed into `func`.

Returns
-------
Rolling
    The original object with the function `func` applied.

See Also
--------
Series.pipe : Apply a function with arguments to a series.
DataFrame.pipe: Apply a function with arguments to a dataframe.
apply : Apply function to each group instead of to the
    full Rolling object.

Notes
-----
See more `here
<https://pandas.pydata.org/pandas-docs/stable/user_guide/groupby.html#piping-function-calls>`__.

Examples
--------

>>> df = pd.DataFrame(
...     {"A": [1, 2, 3, 4]}, index=pd.date_range("2012-08-02", periods=4)
... )
>>> df
            A
2012-08-02  1
2012-08-03  2
2012-08-04  3
2012-08-05  4

To get the difference between each rolling
2-day window's maximum and minimum
value in one pass, you can do

>>> df.rolling("2D").pipe(lambda x: x.max() - x.min())
            A
2012-08-02  0.0
2012-08-03  1.0
2012-08-04  1.0
2012-08-05  1.0
)r  r,  r  s   &&*,r^   r,  r    s    j w|D242622ra   c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r  0	  s-     _
 _
_
 2_
 .	_
ra   c                (   < \         SV `  VVVR7      # )a4  
Calculate the rolling sum.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or
      globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{'nopython': True, 'nogil': False, 'parallel': False}``.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.sum : Aggregating sum for Series.
DataFrame.sum : Aggregating sum for DataFrame.

Notes
-----
See :ref:`window.numba_engine` and :ref:`enhancingperf.numba`
for extended documentation and performance considerations
for the Numba engine.

Examples
--------
>>> 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   r  rb  )r  r  rk   r   r  rb  r  s   &&&&r^   r  Rolling.sum0	  s%    v w{%'  
 	
ra   r  rb  c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r  	  s-     E
 E
E
 2	E

 .E
ra   c               (   < \         SV `  VVVR7      # )a2  
Calculate the rolling maximum.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

*args : iterable, optional
    Positional arguments passed into ``func``.

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or
      globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``.

    The default ``engine_kwargs`` for the ``'numba'`` engine is
    ``{'nopython': True, 'nogil': False, 'parallel': False}``.

**kwargs : mapping, optional
    A dictionary of keyword arguments passed into ``func``.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.max : Aggregating max for Series.
DataFrame.max : Aggregating max for DataFrame.

Notes
-----
See :ref:`window.numba_engine` and :ref:`enhancingperf.numba`
for extended documentation and performance considerations
for the Numba engine.

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4])
>>> ser.rolling(2).max()
0    NaN
1    2.0
2    3.0
3    4.0
dtype: float64
r  )r  rE  )rk   r   r  rb  rr  r   r  s   &&$$*,r^   rE  Rolling.max	  s%    B w{%'  
 	
ra   c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r  	  -     @
 @
@
 2@
 .	@
ra   c                (   < \         SV `  VVVR7      # )a  
Calculate the rolling minimum.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or
      globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``.

    The default ``engine_kwargs`` for the ``'numba'`` engine is
    ``{'nopython': True, 'nogil': False, 'parallel': False}``.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.min : Aggregating min for Series.
DataFrame.min : Aggregating min for DataFrame.

Notes
-----
See :ref:`window.numba_engine` and :ref:`enhancingperf.numba`
for extended documentation and performance considerations
for the Numba engine.

Examples
--------
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
r  )r  rL  r  s   &&&&r^   rL  Rolling.min	  s%    x w{%'  
 	
ra   c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r  
  s-     G
 G
G
 2G
 .	G
ra   c                (   < \         SV `  VVVR7      # )aA  
Calculate the rolling mean.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or
      globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``.

    The default ``engine_kwargs`` for the ``'numba'`` engine is
    ``{'nopython': True, 'nogil': False, 'parallel': False}``.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.mean : Aggregating mean for Series.
DataFrame.mean : Aggregating mean for DataFrame.

Notes
-----
See :ref:`window.numba_engine` and :ref:`enhancingperf.numba`
for extended documentation and performance considerations
for the Numba engine.

Examples
--------
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  )r  r  r  s   &&&&r^   r  Rolling.mean
  s%    F w|%'  
 	
ra   c               $    V ^8  d   QhRRRRRR/# r7  r\   )r]   s   "r^   r_   r  c
  r  ra   c                (   < \         SV `  VVVR7      # )a  
Calculate the rolling median.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or
      globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``.

    The default ``engine_kwargs`` for the ``'numba'`` engine is
    ``{'nopython': True, 'nogil': False, 'parallel': False}``.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.median : Aggregating median for Series.
DataFrame.median : Aggregating median for DataFrame.

Notes
-----
See :ref:`window.numba_engine` and :ref:`enhancingperf.numba`
for extended documentation and performance considerations
for the Numba engine.

Examples
--------
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  )r  rX  r  s   &&&&r^   rX  Rolling.medianc
  s%    x w~%'  
 	
ra   c               (    V ^8  d   QhRRRRRRRR/# r]  r\   )r]   s   "r^   r_   r  
  8     H
 H
H
 H
 2	H

 .H
ra   c                *   < \         SV `  VVVVR7      # )a  
Calculate the rolling standard deviation.

Parameters
----------
ddof : int, default 1
    Delta Degrees of Freedom.  The divisor used in calculations
    is ``N - ddof``, where ``N`` represents the number of elements.

numeric_only : bool, default False
    Include only float, int, boolean columns.

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or
      globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``.

    The default ``engine_kwargs`` for the ``'numba'`` engine is
    ``{'nopython': True, 'nogil': False, 'parallel': False}``.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
numpy.std : Equivalent method for NumPy array.
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.std : Aggregating std for Series.
DataFrame.std : Aggregating std for DataFrame.

Notes
-----
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.

Examples
--------
>>> 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
r  r   r  rb  )r  r  rk   r  r   r  rb  r  s   &&&&&r^   r  Rolling.std
  (    F w{%'	  
 	
ra   c               (    V ^8  d   QhRRRRRRRR/# r]  r\   )r]   s   "r^   r_   r  
  r  ra   c                *   < \         SV `  VVVVR7      # )a  
Calculate the rolling variance.

Parameters
----------
ddof : int, default 1
    Delta Degrees of Freedom.  The divisor used in calculations
    is ``N - ddof``, where ``N`` represents the number of elements.

numeric_only : bool, default False
    Include only float, int, boolean columns.

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or
      globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``.

    The default ``engine_kwargs`` for the ``'numba'`` engine is
    ``{'nopython': True, 'nogil': False, 'parallel': False}``.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
numpy.var : Equivalent method for NumPy array.
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.var : Aggregating var for Series.
DataFrame.var : Aggregating var for DataFrame.

Notes
-----
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.

Examples
--------
>>> 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
r  )r  r  r  s   &&&&&r^   r  Rolling.var
  r  ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r  9  s     '7 '7 '7ra   c                $   < \         SV `  VR7      # )a*  
Calculate the rolling unbiased skewness.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
scipy.stats.skew : Third moment of a probability density.
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.skew : Aggregating skew for Series.
DataFrame.skew : Aggregating skew for DataFrame.

Notes
-----

A minimum of three periods is required for the rolling calculation.

Examples
--------
>>> 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
rt  )r  rl  r  s   &&r^   rl  Rolling.skew9  s    N w||66ra   c                    V ^8  d   QhRRRR/# r  r\   )r]   s   "r^   r_   r  b  s     + + +t +ra   c                    V P                  RV4       V P                  W!R7      V P                  V4      P                  R4      ,          # )aJ  
Calculate the rolling standard error of mean.

Parameters
----------
ddof : int, default 1
    Delta Degrees of Freedom.  The divisor used in calculations
    is ``N - ddof``, where ``N`` represents the number of elements.

numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.sem : Aggregating sem for Series.
DataFrame.sem : Aggregating sem for DataFrame.

Notes
-----
A minimum of one period is required for the calculation.

Examples
--------
>>> s = pd.Series([0, 1, 2, 3])
>>> s.rolling(2, min_periods=1).sem()
0    NaN
1    0.5
2    0.5
3    0.5
dtype: float64
rr  rs  ru  rv  rx  s   &&&r^   rr  Rolling.semb  sB    P 	##E<8xx\x=JJ|$
#c( 	ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r    s     .7 .7 .7ra   c                $   < \         SV `  VR7      # )aQ  
Calculate the rolling Fisher's definition of kurtosis without bias.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
scipy.stats.kurtosis : Reference SciPy method.
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.kurt : Aggregating kurt for Series.
DataFrame.kurt : Aggregating kurt for DataFrame.

Notes
-----
A minimum of four periods is required for the calculation.

Examples
--------
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
rt  )r  r|  r  s   &&r^   r|  Rolling.kurt  s    \ w||66ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r    s     !8 !8$ !8ra   c                $   < \         SV `  VR7      # )a  
Calculate the rolling First (left-most) element of the window.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
GroupBy.first : Similar method for GroupBy objects.
Rolling.last : Method to get the last element in each window.

Examples
--------
The example below will show a rolling calculation with a window size of
three.

>>> s = pd.Series(range(5))
>>> s.rolling(3).first()
0         NaN
1         NaN
2         0.0
3         1.0
4         2.0
dtype: float64
rt  )r  r  r  s   &&r^   r  Rolling.first  s    B w},}77ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r    s     !7 !7 !7ra   c                $   < \         SV `  VR7      # )a  
Calculate the rolling Last (right-most) element of the window.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
GroupBy.last : Similar method for GroupBy objects.
Rolling.first : Method to get the first element in each window.

Examples
--------
The example below will show a rolling calculation with a window size of
three.

>>> s = pd.Series(range(5))
>>> s.rolling(3).last()
0         NaN
1         NaN
2         2.0
3         3.0
4         4.0
dtype: float64
rt  )r  r  r  s   &&r^   r  Rolling.last  s    B w||66ra   c               $    V ^8  d   QhRRRRRR/# r  r\   )r]   s   "r^   r_   r    s(     =
 =
=
 -=
 	=
ra   c                (   < \         SV `  VVVR7      # )a  
Calculate the rolling quantile.

Parameters
----------
q : float
    Quantile to compute. 0 <= quantile <= 1.

interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
    This optional parameter specifies the interpolation method to use,
    when the desired quantile lies between two data points `i` and `j`:

        * linear: `i + (j - i) * fraction`, where `fraction` is the
          fractional part of the index surrounded by `i` and `j`.
        * lower: `i`.
        * higher: `j`.
        * nearest: `i` or `j` whichever is nearest.
        * midpoint: (`i` + `j`) / 2.

numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.quantile : Aggregating quantile for Series.
DataFrame.quantile : Aggregating quantile for DataFrame.

Examples
--------
>>> s = pd.Series([1, 2, 3, 4])
>>> s.rolling(2).quantile(0.4, interpolation="lower")
0    NaN
1    1.0
2    2.0
3    3.0
dtype: float64

>>> s.rolling(2).quantile(0.4, interpolation="midpoint")
0    NaN
1    1.5
2    2.5
3    3.5
dtype: float64
)r  r  r   )r  r  )rk   r  r  r   r  s   &&&&r^   r  Rolling.quantile  s&    r w'%   
 	
ra   c               (    V ^8  d   QhRRRRRRRR/# r  r\   )r]   s   "r^   r_   r  D  s8     L
 L
!L
 L
 	L

 L
ra   c                *   < \         SV `  VVVVR7      # )a  
Calculate the rolling rank.

Parameters
----------
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.

numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.rank : Aggregating rank for Series.
DataFrame.rank : Aggregating rank for DataFrame.

Examples
--------
>>> 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
)rX   r  r  r   )r  r  )rk   rX   r  r  r   r  s   &&&&&r^   r  Rolling.rankD  s(    N w|%	  
 	
ra   c                   V ^8  d   QhRR/# r  r\   )r]   s   "r^   r_   r    s     *
 *
*
ra   c                $   < \         SV `  VR7      # )a  
Calculate the rolling nunique.

.. versionadded:: 3.0.0

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.nunique : Aggregating nunique for Series.
DataFrame.nunique : Aggregating nunique for DataFrame.

Examples
--------
>>> s = pd.Series([1, 4, 2, np.nan, 3, 3, 4, 5])
>>> s.rolling(3).nunique()
0    NaN
1    NaN
2    3.0
3    NaN
4    NaN
5    NaN
6    2.0
7    3.0
dtype: float64
rt  )r  r  r  s   &&r^   r  Rolling.nunique  s    P w%  
 	
ra   c               (    V ^8  d   QhRRRRRRRR/# r  r\   )r]   s   "r^   r_   r    s2     ;
 ;
(;
 ;
 	;

 ;
ra   c                *   < \         SV `  VVVVR7      # )a  
Calculate the rolling sample covariance.

Parameters
----------
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.

numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.cov : Aggregating cov for Series.
DataFrame.cov : Aggregating cov for DataFrame.

Examples
--------
>>> 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
rC  rE  r  r   )r  r  rk   rC  rE  r  r   r  s   &&&&&r^   r  Rolling.cov  s(    l w{%	  
 	
ra   c               (    V ^8  d   QhRRRRRRRR/# r  r\   )r]   s   "r^   r_   r    s8     @
 @
(@
 @
 	@

 @
ra   c                *   < \         SV `  VVVVR7      # )an  
Calculate the rolling correlation.

Parameters
----------
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.

numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
cov : Similar method to calculate covariance.
numpy.corrcoef : NumPy Pearson's correlation calculation.
Series.rolling : Calling rolling with Series data.
DataFrame.rolling : Calling rolling with DataFrames.
Series.corr : Aggregating corr for Series.
DataFrame.corr : Aggregating corr for DataFrame.

Notes
-----
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.

Examples
--------
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.0, 35.0], [49.0, 30.0], [47.0, 32.0], [46.0, 31.0], [50.0, 36.0]]
... )
>>> 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
r%  )r  r  r&  s   &&&&&r^   r  Rolling.corr  s(    v w|%	  
 	
ra   )rd   rP   r	  r   rz  r  r  r  r
  r  r  r  )#r~   r|  r}  r~  rI   r  rj   r  r  rx  rt  r"  ru  r   r,  r   r  rE  rL  r  rX  r  r  rl  rr  r|  r  r  r  r  r  r  r  r  r  r  s   @r^   r  r    sq   	K 	/G /GbD(N8` C++ ++ZP
 P
d     T3 T3l_
 _
BE
 59	E

 15E
 E
N@
 @
DG
 G
R@
 @
DH
 H
TH
 H
T'7 '7R+Z.7 .7`!8 !8F!7 !7F=
 =
~L
 L
\*
 *
X;
 ;
z@
 @
 @
ra   r  c                  l    ] tR tRtRt]P                  ]P                  ,           tR R ltR R lt	Rt
R# )	RollingGroupbyi  z+
Provide a rolling groupby implementation.
c                   V ^8  d   QhRR/# )rN   rZ   r$   r\   )r]   s   "r^   r_   RollingGroupby.__annotate__  s     ! !^ !ra   c                   RpV P                   p\        V P                  \        4      '       dq   \	        V P                  4      pV P                  P
                  P                  4       p\        V\        4      '       g   Q hVP                  RR4       V P                  pM3V P                  e   \        pV P                  pM\        pV P                  p\        VVV P                  P                  VVR7      pV# )zk
Return an indexer class that will compute the window start and end bounds

Returns
-------
GroupbyIndexer
Nr  )r  r  groupby_indicesrV  indexer_kwargs)r  rf   rc   r"   rx   __dict__r   dictr  rd   r%   r#   r$   r  r  )rk   r1  r  rolling_indexerrc   rV  s   &     r^   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*)
 ra   c                   V ^8  d   QhRR/# ro   r\   )r]   s   "r^   r_   r.    s      $ ra   c                   V P                   P                  '       d   V P                  R4       V P                  P                  P                  4        Fr  pV P                   P                  V4      pVP                  '       d   K2  VP                  '       d   KF  V P                  f   RMV P                  p\        RV RV R24      h	  R# )z3
Validate that each group in self._on is monotonic
r  Nre   zEach group within z' must be monotonic. Sort the values in z first.)rK   r  r  r  r  r   r2  r  r  rU   rh   )rk   r  group_onrU   s   &   r^   r  /RollingGroupby._validate_datetimelike_monotonic  s    
 88''(BC!]]2299;Mxx}}]3H000H4T4T4T $WTWW ( -**,W6  <ra   r\   N)r~   r|  r}  r~  r  r  rI   r  r   r  r  r\   ra   r^   r,  r,    s0     %%(9(E(EEK!F ra   r,  )tr  
__future__r   r   datetimer   	functoolsr   ry   typingr   r   r   r   r	   r
   r   r   numpyr   pandas._libs.tslibsr   r   r    pandas._libs.window.aggregations_libsrc   aggregationsr  pandas.compat._optionalr   pandas.errorsr   pandas.util._decoratorsr   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   r   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-   r.   pandas.core.window.commonr/   r0   pandas.core.window.numba_r1   r2   r3   collections.abcr4   r5   r6   r7   pandas._typingr8   r9   r:   r;   r<   r=   r>   r?   r   r@   rA   pandas.core.genericrB   r  rD   pandas.core.arrays.datetimelikerE   rG   r  r  r  r  r,  r\   ra   r^   <module>r\     s  
 #    	 	 	  
 ? > > # .  1 - ' , . +       . 
  ( 	 	 	 ,3 9] ]@F:
 F:R  P

Z P

 !P

fv
z v
r  P
& P
 !P
f. ..  :& : !:ra   