
    Mh(                        S SK Jr  S SKrS SKrS SKJrJrJr  S SKrS SK	r
S SKJr  S SKJrJrJrJr  S SKJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S S	K J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(  S S
K)J*r*J+r+J,r,  \" SSS9r-\-SLr.Sq/SKSLS jjr0\0" \" S5      5         " S S5      r1 " S S5      r2SMS jr3SNS jr4 SO   SPS jjr5        SQS jr6   SR           SSS jjr7STS jr8SUS jr9SVSWS jjr:SXS jr;SYS jr<SXS  jr=SSSS!.         SZS" jjr>SSSS!.         SZS# jjr?\1" S$5      \;\=SSS SS%.           S[S& jj5       5       5       r@          S\S' jrA\2" 5       \;SSSS!.         S]S( jj5       5       rB\2" 5       SSSS!.S^S) jj5       rC      S_S* jrD\
R                  " \
R                  5      4           S`S+ jjrG\2" S,S-9SSS,SS..     SaS/ jj5       rH\1" S$S05      \2" S,S-9SSS,SS..       SbS1 jj5       5       rI\1" S$S05      SSS,SS..           ScS2 jj5       rJS3 rK\K" S4S5S69rL\K" S7S8S69rMSSSS!.         SdS9 jjrNSSSS!.         SdS: jjrO\1" S$S05      \=SSSS!.         S]S; jj5       5       rP\1" S$S05      \=SSSS!.         S]S< jj5       5       rQ\1" S$S05      \=SSS SS%.           S[S= jj5       5       rR          SeS> jrS\
R                  " \
R                  5      4         SfS? jjrT Sg           ShS@ jjrU        SiSA jrVSB rW\1" S$S05      SCSSD.         SjSE jj5       rX    SkSF jrY\1" S$S05      SS,SG.         SlSH jj5       rZSI r[SmSJ jr\g)n    )annotationsN)AnyCallablecast)
get_option)NaTNaTTypeiNaTlib)		ArrayLikeAxisIntCorrelationMethodDtypeDtypeObjFScalarShapenpt)import_optional_dependency)find_stack_level)
is_complexis_floatis_float_dtype
is_integeris_numeric_dtypeis_object_dtypeneeds_i8_conversionpandas_dtype)isnana_value_for_dtypenotna
bottleneckwarn)errorsFTc                     [         (       a  U qg g N)_BOTTLENECK_INSTALLED_USE_BOTTLENECK)vs    D/var/www/html/env/lib/python3.13/site-packages/pandas/core/nanops.pyset_use_bottleneckr+   9   s          zcompute.use_bottleneckc                  @   ^  \ rS rSrSU 4S jjrSS jrSS jrSrU =r$ )	disallowC   c                P   > [         TU ]  5         [        S U 5       5      U l        g )Nc              3  L   #    U  H  n[        U5      R                  v   M     g 7fr&   )r   type).0dtypes     r*   	<genexpr>$disallow.__init__.<locals>.<genexpr>F   s     I&L/44&s   "$)super__init__tupledtypes)selfr:   	__class__s     r*   r8   disallow.__init__D   s     I&IIr,   c                |    [        US5      =(       a*    [        UR                  R                  U R                  5      $ )Nr4   )hasattr
issubclassr4   r2   r:   )r;   objs     r*   checkdisallow.checkH   s'    sG$PCIINNDKK)PPr,   c                f   ^ ^ [         R                  " T5      UU 4S j5       n[        [        U5      $ )Nc                 L  > [         R                  " XR                  5       5      n[        U4S jU 5       5      (       a+  TR                  R                  SS5      n[        SU S35      e T" U 0 UD6$ ! [         a%  n[        U S   5      (       a  [        U5      Uee S nAff = f)Nc              3  F   >#    U  H  nTR                  U5      v   M     g 7fr&   )rB   )r3   rA   r;   s     r*   r5   0disallow.__call__.<locals>._f.<locals>.<genexpr>O   s     7hs4::c??hs   !nan zreduction operation 'z' not allowed for this dtyper   )		itertoolschainvaluesany__name__replace	TypeError
ValueErrorr   )argskwargsobj_iterf_nameefr;   s        r*   _fdisallow.__call__.<locals>._fL   s     t]]_=H7h777++E26+F83OP 	$)&)) 
 #47++#A,A-s   ,A4 4
B#> BB#	functoolswrapsr   r   )r;   rW   rX   s   `` r*   __call__disallow.__call__K   s,    			 
	$ Ar{r,   )r:   )r:   r   returnNoner_   bool)rW   r   r_   r   )	rN   
__module____qualname____firstlineno__r8   rB   r]   __static_attributes____classcell__)r<   s   @r*   r.   r.   C   s    JQ r,   r.   c                  ,    \ rS rSrSSS jjrSS jrSrg)	bottleneck_switchb   Nc                    Xl         X l        g r&   )namerS   )r;   rl   rS   s      r*   r8   bottleneck_switch.__init__c   s    	r,   c                  ^ ^^^ T R                   =(       d    TR                  m [        [        T5      m[        R                  " T5      S SS.     SUUUU 4S jjj5       n[        [        U5      $ ! [        [
        4 a    S m NRf = f)NTaxisskipnac                 > [        T
R                  5      S:  a.  T
R                  R                  5        H  u  pEXC;  d  M  XSU'   M     U R                  S:X  a  UR	                  S5      c  [        X5      $ [        (       a}  U(       av  [        U R                  T	5      (       a[  UR	                  SS 5      c:  UR                  SS 5        T" U 4SU0UD6n[        U5      (       a  T" U 4XS.UD6nU$ T" U 4XS.UD6n U$ T" U 4XS.UD6nU$ )Nr   	min_countmaskrp   ro   )lenrS   itemssizeget_na_for_min_countr(   _bn_ok_dtyper4   pop	_has_infs)rL   rp   rq   kwdskr)   resultaltbn_funcbn_namer;   s          r*   rW   %bottleneck_switch.__call__.<locals>.fo   s    4;;!# KK--/DA}"#Q 0 {{aDHH[$9$A )666l6<<.Q.Q88FD)1 HHVT*$V?$?$?F !((!$V!N$!N!N M	 !JdJTJF M VF$FFMr,   )rL   
np.ndarrayrp   AxisInt | Nonerq   rb   )
rl   rN   getattrbnAttributeError	NameErrorr[   r\   r   r   )r;   r   rW   r   r   s   `` @@r*   r]   bottleneck_switch.__call__g   s    ))+s||	b'*G 
	 $(	%	%	 !%	 	%	 %	 
%	N AqzW 	* 	G	s   A3 3BB)rS   rl   r&   )r_   r`   )r   r   r_   r   )rN   rc   rd   re   r8   r]   rf    r,   r*   ri   ri   b   s    0r,   ri   c                B    U [         :w  a  [        U 5      (       d  US;  $ g)N)nansumnanprodnanmeanF)objectr   )r4   rl   s     r*   rz   rz      s%    2599 ;;;r,   c                    [        U [        R                  5      (       a5  U R                  S;   a%  [        R
                  " U R                  S5      5      $  [        R                  " U 5      R                  5       $ ! [        [        4 a     gf = f)N)f8f4KF)
isinstancenpndarrayr4   r   has_infsravelisinfrM   rP   NotImplementedError)r   s    r*   r|   r|      sn    &"**%%<<<' <<S 122xx##%%*+ s   #A: :BBc                    Ub  U$ [        U 5      (       a:  Uc  [        R                  $ US:X  a  [        R                  $ [        R                  * $ US:X  a  [        R
                  $ [        $ )z9return the correct fill value for the dtype of the values+inf)_na_ok_dtyper   rH   infr   i8maxr
   )r4   
fill_valuefill_value_typs      r*   _get_fill_valuer      s]     E!66M'vvwV#99Kr,   c                    UcG  U R                   R                  S;   a  gU(       d  U R                   R                  S;   a  [        U 5      nU$ )a^  
Compute a mask if and only if necessary.

This function will compute a mask iff it is necessary. Otherwise,
return the provided mask (potentially None) when a mask does not need to be
computed.

A mask is never necessary if the values array is of boolean or integer
dtypes, as these are incapable of storing NaNs. If passing a NaN-capable
dtype that is interpretable as either boolean or integer data (eg,
timedelta64), a mask must be provided.

If the skipna parameter is False, a new mask will not be computed.

The mask is computed using isna() by default. Setting invert=True selects
notna() as the masking function.

Parameters
----------
values : ndarray
    input array to potentially compute mask for
skipna : bool
    boolean for whether NaNs should be skipped
mask : Optional[ndarray]
    nan-mask if known

Returns
-------
Optional[np.ndarray[bool]]
NbiumM)r4   kindr   )rL   rq   rt   s      r*   _maybe_get_maskr      sA    B |<<%V\\&&$.<DKr,   c                   [        XU5      nU R                  nSnU R                  R                  S;   a'  [        R                  " U R                  S5      5      n SnU(       a~  Ub{  [        XRUS9nUbn  UR                  5       (       aY  U(       d  [        U5      (       a*  U R                  5       n [        R                  " XU5        X4$ [        R                  " U) X5      n X4$ )a<  
Utility to get the values view, mask, dtype, dtype_max, and fill_value.

If both mask and fill_value/fill_value_typ are not None and skipna is True,
the values array will be copied.

For input arrays of boolean or integer dtypes, copies will only occur if a
precomputed mask, a fill_value/fill_value_typ, and skipna=True are
provided.

Parameters
----------
values : ndarray
    input array to potentially compute mask for
skipna : bool
    boolean for whether NaNs should be skipped
fill_value : Any
    value to fill NaNs with
fill_value_typ : str
    Set to '+inf' or '-inf' to handle dtype-specific infinities
mask : Optional[np.ndarray[bool]]
    nan-mask if known

Returns
-------
values : ndarray
    Potential copy of input value array
mask : Optional[ndarray[bool]]
    Mask for values, if deemed necessary to compute
Fr   i8T)r   r   )r   r4   r   r   asarrayviewr   rM   r   copyputmaskwhere)rL   rq   r   r   rt   r4   datetimelikes          r*   _get_valuesr      s    R 640DLLEL||D  FKK-.4# %

 !xxzz<#6#6#[[]FJJvZ8
 <  XXteV@F<r,   c                J   U nU R                   S;   a&  [        R                  " [        R                  5      nU$ U R                   S:X  a&  [        R                  " [        R                  5      nU$ U R                   S:X  a$  [        R                  " [        R
                  5      nU$ )NbiurW   )r   r   r4   int64uint64float64)r4   	dtype_maxs     r*   _get_dtype_maxr   D  s{    IzzTHHRXX&	
 	 
s	HHRYY'	  
s	HHRZZ(	r,   c                v    [        U 5      (       a  g[        U R                  [        R                  5      (       + $ )NF)r   r@   r2   r   integerr4   s    r*   r   r   P  s(    5!!%**bjj111r,   c                   U [         L a   U $ UR                  S:X  a  Uc  [        n[        U [        R
                  5      (       d  [        U5      (       a   S5       eX:X  a  [        R                  n [        U 5      (       a'  [        R                  " SS5      R                  U5      n O%[        R                  " U 5      R                  U5      n U R                  USS9n U $ U R                  U5      n  U $ UR                  S:X  a  [        U [        R
                  5      (       d  X:X  d  [        R                  " U 5      (       a'  [        R                  " S5      R                  U5      n U $ [        R                  " U 5      [        R                   :  a  [#        S5      e[        R                  " U 5      R                  USS9n  U $ U R                  S	5      R                  U5      n U $ )
zwrap our results if neededMzExpected non-null fill_valuer   nsFr   mzoverflow in timedelta operationm8[ns])r   r   r
   r   r   r   r   rH   
datetime64astyper   r   isnantimedelta64fabsr   r   rQ   )r   r4   r   s      r*   _wrap_resultsr   V  s   }F MC 
s	J&"**--J''G)GG'#F||ud3::5A&)..u5]]5u]5F& M! ]]5)F  M 
s	&"**--#rxx'7'7.55e< M 399, !BCC &)00U0C
 M ]]8,11%8FMr,   c                   ^  [         R                  " T 5      SSSS.       SU 4S jjj5       n[        [        U5      $ )z
If we have datetime64 or timedelta64 values, ensure we have a correct
mask before calling the wrapped function, then cast back afterwards.
NTrp   rq   rt   c                  > U nU R                   R                  S;   nU(       a  Uc  [        U 5      nT" U 4XUS.UD6nU(       a0  [        XuR                   [        S9nU(       d  Uc   e[        XqX55      nU$ )Nr   r   )r   )r4   r   r   r   r
   _mask_datetimelike_result)	rL   rp   rq   rt   rS   orig_valuesr   r   funcs	           r*   new_func&_datetimelike_compat.<locals>.new_func  sy     ||((D0DL<DfL4TLVL"6+<+<NF'''26Sr,   rL   r   rp   r   rq   rb   rt   npt.NDArray[np.bool_] | NonerZ   )r   r   s   ` r*   _datetimelike_compatr     s`     __T  $-1  	
 + 0 8r,   c                2   U R                   R                  S;   a  U R                  S5      n [        U R                   5      nU R                  S:X  a  U$ Uc  U$ U R
                  SU U R
                  US-   S -   n[        R                  " X2U R                   S9$ )aQ  
Return the missing value for `values`.

Parameters
----------
values : ndarray
axis : int or None
    axis for the reduction, required if values.ndim > 1.

Returns
-------
result : scalar or ndarray
    For 1-D values, returns a scalar of the correct missing type.
    For 2-D values, returns a 1-D array where each element is missing.
iufcbr      Nr   )r4   r   r   r    ndimshaper   full)rL   rp   r   result_shapes       r*   ry   ry     s    " ||G#y)#FLL1J{{a	||ET*V\\$(*-EEww|v||DDr,   c                n   ^  [         R                  " T 5      SS.SU 4S jjj5       n[        [        U5      $ )z
NumPy operations on C-contiguous ndarrays with axis=1 can be
very slow if axis 1 >> axis 0.
Operate row-by-row and concatenate the results.
Nrp   c          	     6  > US:X  a  U R                   S:X  a  U R                  S   (       a  U R                  S   S-  U R                  S   :  a  U R                  [        :w  a  U R                  [
        :w  a  [        U 5      nUR                  S5      bC  UR                  S5      n[        [        U5      5       Vs/ s H  nT" X5   4SXE   0UD6PM     nnOU Vs/ s H  nT" U40 UD6PM     nn[        R                  " U5      $ T" U 4SU0UD6$ s  snf s  snf )Nr      C_CONTIGUOUSi  r   rt   rp   )r   flagsr   r4   r   rb   listrx   r{   rangeru   r   array)	rL   rp   rS   arrsrt   iresultsxr   s	           r*   newfunc&maybe_operate_rowwise.<locals>.newfunc  s
    AIq ^, a4'6<<?:&$<Dzz&!-zz&)CHTCSCSaD9tw9&9CS   7;;d4,V,d;88G$$F0000 <s   ;DD)rL   r   rp   r   rZ   )r   r   s   ` r*   maybe_operate_rowwiser     s7     __T>B 1 1 1. 7r,   r   c               d   U R                   R                  S;   a  Uc  U R                  U5      $ U R                   R                  S:X  a"  [        R                  " S[
        [        5       S9  [        XSUS9u  pU R                   [        :X  a  U R                  [        5      n U R                  U5      $ )a  
Check if any elements along an axis evaluate to True.

Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : bool

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, 2])
>>> nanops.nanany(s.values)
True

>>> from pandas.core import nanops
>>> s = pd.Series([np.nan])
>>> nanops.nanany(s.values)
False
iubr   zz'any' with datetime64 dtypes is deprecated and will raise in a future version. Use (obj != pd.Timestamp(0)).any() instead.
stacklevelFr   rt   )r4   r   rM   warningsr#   FutureWarningr   r   r   r   rb   rL   rp   rq   rt   _s        r*   nananyr     s    D ||E!dl zz$||CJ')		
 Fu4HIF ||vt$ ::dr,   c               d   U R                   R                  S;   a  Uc  U R                  U5      $ U R                   R                  S:X  a"  [        R                  " S[
        [        5       S9  [        XSUS9u  pU R                   [        :X  a  U R                  [        5      n U R                  U5      $ )a  
Check if all elements along an axis evaluate to True.

Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : bool

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, 2, np.nan])
>>> nanops.nanall(s.values)
True

>>> from pandas.core import nanops
>>> s = pd.Series([1, 0])
>>> nanops.nanall(s.values)
False
r   r   zz'all' with datetime64 dtypes is deprecated and will raise in a future version. Use (obj != pd.Timestamp(0)).all() instead.r   Tr   )r4   r   allr   r#   r   r   r   r   r   rb   r   s        r*   nanallr     s    D ||E!dl zz$||CJ')		
 Ft$GIF ||vt$ ::dr,   M8)rp   rq   rs   rt   c               $   U R                   n[        XSUS9u  p[        U5      nUR                  S:X  a  UnO4UR                  S:X  a$  [        R                   " [        R
                  5      nU R                  XS9n[        XqX@R                  US9nU$ )au  
Sum the elements along an axis ignoring NaNs

Parameters
----------
values : ndarray[dtype]
axis : int, optional
skipna : bool, default True
min_count: int, default 0
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : dtype

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, 2, np.nan])
>>> nanops.nansum(s.values)
3.0
r   r   rW   r   r   rs   )	r4   r   r   r   r   r   sum_maybe_null_outr   )rL   rp   rq   rs   rt   r4   	dtype_sumthe_sums           r*   r   r   \  s~    D LLEv!$GLFu%IzzS		s	HHRZZ(	jjj/GgT<<9UGNr,   c                Z   [        U [        R                  5      (       aC  U R                  S5      R	                  UR
                  5      n UR                  US9n[        X'   U $ UR                  5       (       a3  [        R                  " [        5      R	                  UR
                  5      $ U $ )Nr   r   )	r   r   r   r   r   r4   rM   r
   r   )r   rp   rt   r   	axis_masks        r*   r   r     s     &"**%%t$))+*;*;<HH$H'	 ! M 88::88D>&&{'8'899Mr,   c               D   U R                   n[        XSUS9u  p[        U5      n[        R                   " [        R                  5      nUR
                  S;   a%  [        R                   " [        R                  5      nOIUR
                  S;   a%  [        R                   " [        R                  5      nOUR
                  S:X  a  UnUn[        U R                  X1US9nU R                  XS9n[        U5      nUb|  [        USS	5      (       aj  [        [        R                  U5      n[        R                  " S
S9   X-  n	SSS5        US:H  n
U
R                  5       (       a  [        R                  W	U
'   W	$ US:  a  X-  O[        R                  n	U	$ ! , (       d  f       NY= f)a  
Compute the mean of the element along an axis ignoring NaNs

Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
float
    Unless input is a float array, in which case use the same
    precision as the input array.

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, 2, np.nan])
>>> nanops.nanmean(s.values)
1.5
r   r   r   iurW   r   Nr   Fignore)r   )r4   r   r   r   r   r   _get_countsr   r   _ensure_numericr   r   r   errstaterM   rH   )rL   rp   rq   rt   r4   r   dtype_countcountr   the_meanct_masks              r*   r   r     sD   B LLEv!$GLFu%I((2::&K zzTHHRZZ(		t	HHRZZ(		s		dDEjjj/Gg&GGGVU;;RZZ'[[X&H ' 1*;;== "HW O ',ai7?RVVO '&s   9F
Fc                 ^ U R                   R                  S:H  =(       a    USL nSU4S jjnU R                   n[        U TUSS9u  pU R                   R                  S:w  aQ  U R                   [        :X  a+  [        R
                  " U 5      nUS;   a  [        SU  S35      e U R                  S5      n U(       d@  Ub=  U R                  R                  (       d  U R                  5       n [        R                  X'   U R                  n	U R                   S	:  a  Ub  U	(       a  T(       d  [        R"                  " XQU 5      n
O[$        R&                  " 5          [$        R(                  " S
S[*        5        U R,                  S	   S	:X  a  US:X  d  U R,                  S   S	:X  a0  US	:X  a*  [        R.                  " [        R0                  " U 5      SS9n
O[        R.                  " XS9n
SSS5        O6[3        U R,                  U5      n
OU	(       a  U" X5      O[        R                  n
[5        W
U5      $ ! [         a  n[        [        U5      5      UeSnAff = f! , (       d  f       NA= f)a  
Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : float
    Unless input is a float array, in which case use the same
    precision as the input array.

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, np.nan, 2, 2])
>>> nanops.nanmedian(s.values)
2.0
rW   Nc                L  > Uc  [        U 5      nOU) nT(       d%  UR                  5       (       d  [        R                  $ [        R
                  " 5          [        R                  " SS[        5        [        R                  " X   5      nS S S 5        U$ ! , (       d  f       W$ = f)Nr  All-NaN slice encountered)	r!   r   r   rH   r   catch_warningsfilterwarningsRuntimeWarning	nanmedian)r   _maskresrq   s      r*   
get_mediannanmedian.<locals>.get_median  s~    =!HEFEeiikk66M$$&##5~ ,,qx(C ' 
 '& 
s   5B
B#)rt   r   stringmixedzCannot convert  to numericr   r   r  r  r   T)keepdimsr   r&   )r4   r   r   r   r   infer_dtyperP   r   rQ   strr   	writeabler   r   rH   rw   r   apply_along_axisr   r  r  r  r   r  squeeze_get_empty_reduction_resultr   )rL   rp   rq   rt   using_nan_sentinelr  r4   inferrederrnotemptyr  s     `        r*   r  r    s   6  **c1Bddl LLEvvDTJLF||C<<6!v.H../& EFF	/]]4(F $"2||%%[[]Fvv{{H {{Q4+))*FC ,,.++ "=~ Q1,Q1, !ll2::f+=M ll6= /.$ .fllDAC +3j&e$$U  	/CH%3.	/& /.s%   "H, BI,
I6II
I!c                    [         R                  " U 5      n[         R                  " [        U 5      5      n[         R                  " X#U:g     [         R
                  S9nUR                  [         R                  5        U$ )z
The result from a reduction on an empty ndarray.

Parameters
----------
shape : Tuple[int, ...]
axis : int

Returns
-------
np.ndarray
r   )r   r   arangeru   emptyr   fillrH   )r   rp   shpdimsrets        r*   r   r   C  sS      ((5/C99SZ D
((3t|$BJJ
7CHHRVVJr,   c                   [        XX$S9nXTR                  U5      -
  n[        U5      (       a(  XS::  a   [        R                  n[        R                  nXV4$ [        [        R                  U5      nXS:*  nUR                  5       (       aJ  [        R                  " Xa[        R                  5        [        R                  " XQ[        R                  5        XV4$ )a  
Get the count of non-null values along an axis, accounting
for degrees of freedom.

Parameters
----------
values_shape : Tuple[int, ...]
    shape tuple from values ndarray, used if mask is None
mask : Optional[ndarray[bool]]
    locations in values that should be considered missing
axis : Optional[int]
    axis to count along
ddof : int
    degrees of freedom
dtype : type, optional
    type to use for count

Returns
-------
count : int, np.nan or np.ndarray
d : int, np.nan or np.ndarray
r   )	r  r2   r   r   rH   r   r   rM   r   )values_shapert   rp   ddofr4   r  ds          r*   _get_counts_nanvarr0  Z  s    : D>E

4  A = FFEA 8O RZZ'}88::JJq'JJuBFF+8Or,   r   r.  rp   rq   r.  rt   c          
         U R                   S:X  a  U R                  S5      n U R                   n[        XUS9u  p[        R                  " [        XX#US95      n[        Xe5      $ )a_  
Compute the standard deviation along given axis while ignoring NaNs

Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
ddof : int, default 1
    Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
    where N represents the number of elements.
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : float
    Unless input is a float array, in which case use the same
    precision as the input array.

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, np.nan, 2, 3])
>>> nanops.nanstd(s.values)
1.0
zM8[ns]r   )rt   r2  )r4   r   r   r   sqrtnanvarr   )rL   rp   rq   r.  rt   
orig_dtyper   s          r*   nanstdr7    sX    H ||xX&JvD9LFWWVFfdSTF,,r,   m8c                  U R                   n[        XU5      nUR                  S;   a&  U R                  S5      n Ub  [        R
                  X'   U R                   R                  S:X  a$  [        U R                  XAX0R                   5      u  pgO[        U R                  XAU5      u  pgU(       a*  Ub'  U R                  5       n [        R                  " XS5        [        U R                  U[        R                  S95      U-  nUb  [        R                  " X5      n[        X-
  S-  5      n	Ub  [        R                  " XS5        U	R                  U[        R                  S9U-  n
UR                  S:X  a  U
R                  USS9n
U
$ )	aU  
Compute the variance along given axis while ignoring NaNs

Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
ddof : int, default 1
    Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
    where N represents the number of elements.
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : float
    Unless input is a float array, in which case use the same
    precision as the input array.

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, np.nan, 2, 3])
>>> nanops.nanvar(s.values)
1.0
r  r   rW   r   )rp   r4   r   Fr   )r4   r   r   r   r   rH   r0  r   r   r   r  r   r   expand_dims)rL   rp   rq   r.  rt   r4   r  r/  avgsqrr   s              r*   r5  r5    sA   J LLE640DzzTt$66FL||C%fllDllSq%fllDE$"


6# &**$bjj*A
BU
JCnnS'
3<A-
.C


3a WW$bjjW1A5F
 zzSu51Mr,   c                  [        XX#US9  [        XU5      nU R                  R                  S:w  a  U R	                  S5      n U(       d(  Ub%  UR                  5       (       a  [        R                  $ [        U R                  XAX0R                  5      u  pV[        XX#US9n[        R                  " U5      [        R                  " U5      -  $ )ay  
Compute the standard error in the mean along given axis while ignoring NaNs

Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
ddof : int, default 1
    Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
    where N represents the number of elements.
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : float64
    Unless input is a float array, in which case use the same
    precision as the input array.

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, np.nan, 2, 3])
>>> nanops.nansem(s.values)
 0.5773502691896258
r2  rW   r   )r5  r   r4   r   r   rM   r   rH   r0  r   r4  )rL   rp   rq   r.  rt   r  r   vars           r*   nansemr?    s    L 6VTB640D||Ct$d&488::vv!&,,D,,OHE
64
HC773<"''%.((r,   c                f   ^ ^ [        ST  3S9[        S SS S.       SUU 4S jjj5       5       nU$ )NrH   )rl   Tr   c                  > U R                   S:X  a  [        X5      $ [        XTUS9u  p[        U T5      " U5      n[	        XAX0R
                  5      nU$ )Nr   r   rt   )rw   ry   r   r   r   r   )rL   rp   rq   rt   r   r   meths        r*   	reduction_nanminmax.<locals>.reduction;  sW     ;;!$V22">
 &t, t\\Br,   r   )ri   r   )rC  r   rD  s   `` r*   
_nanminmaxrF  :  sf    c$L)  $-1  	
 +   *" r,   minr   )r   max-infc               \    [        U SSUS9u  pU R                  U5      n[        XAX25      nU$ )ax  
Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : int or ndarray[int]
    The index/indices  of max value in specified axis or -1 in the NA case

Examples
--------
>>> from pandas.core import nanops
>>> arr = np.array([1, 2, 3, np.nan, 4])
>>> nanops.nanargmax(arr)
4

>>> arr = np.array(range(12), dtype=np.float64).reshape(4, 3)
>>> arr[2:, 2] = np.nan
>>> arr
array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.],
       [ 6.,  7., nan],
       [ 9., 10., nan]])
>>> nanops.nanargmax(arr, axis=1)
array([2, 2, 1, 1])
TrI  rB  )r   argmax_maybe_arg_null_outrL   rp   rq   rt   r   s        r*   	nanargmaxrN  U  8    L vtFNLF]]4 F !t<FMr,   c               \    [        U SSUS9u  pU R                  U5      n[        XAX25      nU$ )aw  
Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : int or ndarray[int]
    The index/indices of min value in specified axis or -1 in the NA case

Examples
--------
>>> from pandas.core import nanops
>>> arr = np.array([1, 2, 3, np.nan, 4])
>>> nanops.nanargmin(arr)
0

>>> arr = np.array(range(12), dtype=np.float64).reshape(4, 3)
>>> arr[2:, 0] = np.nan
>>> arr
array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.],
       [nan,  7.,  8.],
       [nan, 10., 11.]])
>>> nanops.nanargmin(arr, axis=1)
array([0, 0, 1, 1])
Tr   rB  )r   argminrL  rM  s        r*   	nanargminrR    rO  r,   c               `   [        XU5      nU R                  R                  S:w  a(  U R                  S5      n [	        U R
                  X15      nO[	        U R
                  X1U R                  S9nU(       a+  Ub(  U R                  5       n [        R                  " XS5        O/U(       d(  Ub%  UR                  5       (       a  [        R                  $ [        R                  " SSS9   U R                  U[        R                  S9U-  nSSS5        Ub  [        R                  " WU5      nU W-
  nU(       a  Ub  [        R                  " XcS5        US-  nXv-  nUR                  U[        R                  S9n	UR                  U[        R                  S9n
[        U	5      n	[        U
5      n
[        R                  " SSS9   XDS	-
  S
-  -  US-
  -  XS-  -  -  nSSS5        U R                  nUR                  S:X  a  WR                  USS9n[!        W[        R"                  5      (       a2  [        R$                  " U	S:H  SU5      n[        R                  XS:  '   U$ U	S:X  a  UR'                  S5      OUnUS:  a  [        R                  $ U$ ! , (       d  f       GN= f! , (       d  f       N= f)at  
Compute the sample skewness.

The statistic computed here is the adjusted Fisher-Pearson standardized
moment coefficient G1. The algorithm computes this coefficient directly
from the second and third central moment.

Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : float64
    Unless input is a float array, in which case use the same
    precision as the input array.

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, np.nan, 1, 2])
>>> nanops.nanskew(s.values)
1.7320508075688787
rW   r   r   Nr   r  invaliddivider   r   g      ?g      ?Fr      )r   r4   r   r   r  r   r   r   r   rM   rH   r  r   r   r:  _zero_out_fperrr   r   r   r2   )rL   rp   rq   rt   r  meanadjusted	adjusted2	adjusted3m2m3r   r4   s                r*   nanskewr_    s'   J 640D||Ct$FLL$5FLL$FLLI$"


6#(TXXZZvv	Xh	7zz$bjjz1E9 
8~~dD)}H$"


81%!I$I	t2::	.B	t2::	.B 
	B		B	Xh	719,,	:rG|L 
8 LLEzzSu51&"**%%"'1f-FFqy M	 #%'Av1966MMG 
8	7( 
8	7s   $"J>J
J
J-c               Z   [        XU5      nU R                  R                  S:w  a(  U R                  S5      n [	        U R
                  X15      nO[	        U R
                  X1U R                  S9nU(       a+  Ub(  U R                  5       n [        R                  " XS5        O/U(       d(  Ub%  UR                  5       (       a  [        R                  $ [        R                  " SSS9   U R                  U[        R                  S9U-  nSSS5        Ub  [        R                  " WU5      nU W-
  nU(       a  Ub  [        R                  " XcS5        US-  nUS-  nUR                  U[        R                  S9n	UR                  U[        R                  S9n
[        R                  " SSS9   S	US
-
  S-  -  US-
  US	-
  -  -  nXDS
-   -  US
-
  -  U
-  nUS-
  US	-
  -  U	S-  -  nSSS5        [        W5      n[        W5      n[!        U[        R"                  5      (       d7  US:  a  [        R                  $ US:X  a  U R                  R%                  S5      $ [        R                  " SSS9   X-  W-
  nSSS5        U R                  nUR                  S:X  a  WR                  USS9n[!        W[        R"                  5      (       a0  [        R&                  " US:H  SU5      n[        R                  XS:  '   U$ ! , (       d  f       GN= f! , (       d  f       GN/= f! , (       d  f       N= f)a`  
Compute the sample excess kurtosis

The statistic computed here is the adjusted Fisher-Pearson standardized
moment coefficient G2, computed directly from the second and fourth
central moment.

Parameters
----------
values : ndarray
axis : int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : float64
    Unless input is a float array, in which case use the same
    precision as the input array.

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, np.nan, 1, 3, 2])
>>> nanops.nankurt(s.values)
-1.2892561983471076
rW   r   r   Nr   r  rT  r   rW  r      Fr   )r   r4   r   r   r  r   r   r   r   rM   rH   r  r   r   r:  rX  r   r   r2   r   )rL   rp   rq   rt   r  rY  rZ  r[  	adjusted4r]  m4adj	numeratordenominatorr   r4   s                   r*   nankurtrg  	  s   J 640D||Ct$FLL$5FLL$FLLI$"


6#(TXXZZvv	Xh	7zz$bjjz1E9 
8~~dD)}H$"


81%!I1I	t2::	.B	t2::	.B	Xh	7519""uqyUQY&?@QY'5195:	qyUQY/"a%7 
8  	*I!+.Kk2::.. 1966M!<<$$Q''	Xh	7(3. 
8 LLEzzSu51&"**%%+*Av6FFqyMY 
8	7 
8	7( 
8	7s$   $"K8)9L
+L8
L

L
L*c                   [        XU5      nU(       a  Ub  U R                  5       n SX'   U R                  U5      n[        XQX@R                  US9$ )a  
Parameters
----------
values : ndarray[dtype]
axis : int, optional
skipna : bool, default True
min_count: int, default 0
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
Dtype
    The product of all elements on a given axis. ( NaNs are treated as 1)

Examples
--------
>>> from pandas.core import nanops
>>> s = pd.Series([1, 2, 3, np.nan])
>>> nanops.nanprod(s.values)
6.0
r   r   )r   r   prodr   r   )rL   rp   rq   rs   rt   r   s         r*   r   r   j  sS    @ 640D$"[[F dLLI r,   c                2   Uc  U $ Ub  [        U SS5      (       d9  U(       a  UR                  5       (       a  g U $ UR                  5       (       a  g U $ U(       a  UR                  U5      nOUR                  U5      nUR                  5       (       a  SX'   U $ )Nr   F)r   r   rM   )r   rp   rt   rq   na_masks        r*   rL  rL    s     ||766599xxzz  M xxzz  M hhtnGhhtnG;;== FOMr,   c                L   UcH  Ub  UR                   UR                  5       -
  nO[        R                  " U 5      nUR	                  U5      $ Ub"  UR
                  U   UR                  U5      -
  nOX   n[        U5      (       a  UR	                  U5      $ UR                  USS9$ )a}  
Get the count of non-null values along an axis

Parameters
----------
values_shape : tuple of int
    shape tuple from values ndarray, used if mask is None
mask : Optional[ndarray[bool]]
    locations in values that should be considered missing
axis : Optional[int]
    axis to count along
dtype : type, optional
    type to use for count

Returns
-------
count : scalar or array
Fr   )rw   r   r   ri  r2   r   r   r   )r-  rt   rp   r4   nr  s         r*   r  r    s    0 |		DHHJ&A%Azz!}

4 488D>1"%zz%  <<E<**r,   c                   Uc  US:X  a  U $ UGb	  [        U [        R                  5      (       a  Ub(  UR                  U   UR	                  U5      -
  U-
  S:  nO-X1   U-
  S:  nUSU X1S-   S -   n[        R
                  " Xg5      n[        R                  " U5      (       au  [        U 5      (       aa  [        R                  " U 5      (       a  U R                  S5      n O [        U 5      (       d  U R                  SSS9n [        R                  X'   U $ SX'   U $ U [        LaQ  [        X2U5      (       a@  [        U SS5      n[        U5      (       a  UR                  S	5      n U $ [        R                  n U $ )
za
Returns
-------
Dtype
    The product of all elements on a given axis. ( NaNs are treated as 1)
Nr   r   c16r   Fr   r4   rH   )r   r   r   r   r   broadcast_torM   r   iscomplexobjr   r   rH   r   check_below_min_countr   r2   )	r   rp   rt   r   rs   	null_maskbelow_count	new_shaperesult_dtypes	            r*   r   r     s^    |	QJvrzz::D)DHHTN:YF!KI  +	1A5KetuAXZ'88I?I66)''??6**#]]51F'//#]]4e]<F$&FF! M %)! M 
s	 i88"67D9Ll++%**51 M Mr,   c                    US:  a=  Uc  [         R                  " U 5      nOUR                  UR                  5       -
  nX2:  a  gg)a  
Check for the `min_count` keyword. Returns True if below `min_count` (when
missing value should be returned from the reduction).

Parameters
----------
shape : tuple
    The shape of the values (`values.shape`).
mask : ndarray[bool] or None
    Boolean numpy array (typically of same shape as `shape`) or None.
min_count : int
    Keyword passed through from sum/prod call.

Returns
-------
bool
r   TF)r   ri  rw   r   )r   rt   rs   	non_nullss       r*   rs  rs    s=    ( 1}<I		DHHJ.I r,   c                   [        U [        R                  5      (       a/  [        R                  " [        R                  " U 5      S:  SU 5      $ [        R                  " U 5      S:  a  U R
                  R                  S5      $ U $ )Ng+=r   )r   r   r   r   absr4   r2   )args    r*   rX  rX  *  sZ    #rzz""xxse+Q44$&FF3K%$7syy~~a @S@r,   pearson)methodmin_periodsc               J   [        U 5      [        U5      :w  a  [        S5      eUc  Sn[        U 5      [        U5      -  nUR                  5       (       d  X   n X   n[        U 5      U:  a  [        R
                  $ [        U 5      n [        U5      n[        U5      nU" X5      $ )z
a, b: ndarrays
z'Operands to nancorr must have same sizer   )ru   AssertionErrorr!   r   r   rH   r  get_corr_func)abr~  r  validrW   s         r*   nancorrr  2  s     1vQFGG!HuQxE99;;HH
1vvvAAfAQ7Nr,   c                   ^^ U S:X  a  SSK Jm  U4S jnU$ U S:X  a  SSK Jm  U4S jnU$ U S:X  a  S	 nU$ [        U 5      (       a  U $ [	        S
U  S35      e)Nkendallr   )
kendalltauc                   > T" X5      S   $ Nr   r   )r  r  r  s     r*   r   get_corr_func.<locals>.funcX  s    a#A&&r,   spearman)	spearmanrc                   > T" X5      S   $ r  r   )r  r  r  s     r*   r   r  _  s    Q?1%%r,   r}  c                4    [         R                  " X5      S   $ )Nr   r   )r   corrcoef)r  r  s     r*   r   r  e  s    ;;q$T**r,   zUnknown method 'z@', expected one of 'kendall', 'spearman', 'pearson', or callable)scipy.statsr  r  callablerQ   )r~  r   r  r  s     @@r*   r  r  R  su     *	' 	:	)	& 	9		+ 	&		

6( #8 	8 r,   )r  r.  c               T   [        U 5      [        U5      :w  a  [        S5      eUc  Sn[        U 5      [        U5      -  nUR                  5       (       d  X   n X   n[        U 5      U:  a  [        R
                  $ [        U 5      n [        U5      n[        R                  " XUS9S   $ )Nz&Operands to nancov must have same sizer   r1  r  )ru   r  r!   r   r   rH   r  cov)r  r  r  r.  r  s        r*   nancovr  r  s     1vQEFF!HuQxE99;;HH
1vvvAA66!T"4((r,   c                   [        U [        R                  5      (       a  U R                  R                  S;   a!  U R                  [        R                  5      n U $ U R                  [        :X  a  [        R                  " U 5      nUS;   a  [        SU  S35      e U R                  [        R                  5      n [        R                  " [        R                  " U 5      5      (       d  U R                  n U $  U $ [!        U 5      (       dR  [#        U 5      (       dB  [%        U 5      (       d2  [        U [&        5      (       a  [        SU  S35      e [)        U 5      n U $ U $ ! [        [        4 aF     U R                  [        R                  5      n  U $ ! [         a  n[        SU  S35      UeS nAff = ff = f! [        [        4 a2     [+        U 5      n  U $ ! [         a  n[        SU  S35      UeS nAff = ff = f)Nr   r  zCould not convert r  zCould not convert string 'z' to numeric)r   r   r   r4   r   r   r   r   r   r  rP   
complex128rM   imagrealrQ   r   r   r   r  floatcomplex)r   r"  r#  s      r*   r  r    s   !RZZ  77<<5 $A< H; WWq)H.."4QC{ CDD
HHR]]+ vvbggaj))A H; : H qkkZ]]jmma8<HII	NaA H1H- z* RR,A( H' " R#&8;$GHcQRR :& 	NNAJ H  N"4QC{ CD#MN		NsT   E F7 F4/F
F0F++F00F47G9G
G5 G00G55G9c          	        [         R                  S[         R                  4[         R                  R                  [         R
                  * [         R                  4[         R                  S[         R                  4[         R                  R                  [         R
                  [         R                  40U   u  p4U R                  R                  S;  d   eU(       ao  [        U R                  R                  [         R                  [         R                  45      (       d,  U R                  5       n[        U5      nX5U'   U" USS9nXGU'   U$ U" U SS9nU$ )z
Cumulative function with skipna support.

Parameters
----------
values : np.ndarray or ExtensionArray
accum_func : {np.cumprod, np.maximum.accumulate, np.cumsum, np.minimum.accumulate}
skipna : bool

Returns
-------
np.ndarray or ExtensionArray
g      ?g        r   r   r   )r   cumprodrH   maximum
accumulater   cumsumminimumr4   r   r@   r2   r   bool_r   r   )rL   
accum_funcrq   mask_amask_bvalsrt   r   s           r*   na_accum_funcr    s     	

S"&&M


0
		C=


/	
 NF <<D((( j!2!2RZZ4JKK{{}DzT
Dq)t M F+Mr,   )T)r)   rb   r_   r`   )r4   r   rl   r  r_   rb   ra   )NN)r4   r   r   zScalar | None)rL   r   rq   rb   rt   r   r_   r   )NNN)rL   r   rq   rb   r   r   r   z
str | Nonert   r   r_   z/tuple[np.ndarray, npt.NDArray[np.bool_] | None])r4   np.dtyper_   r  )r4   r   r_   rb   r&   )r4   r  )r   r   r_   r   )rL   r   rp   r   r_   zScalar | np.ndarray)
rL   r   rp   r   rq   rb   rt   r   r_   rb   )rL   r   rp   r   rq   rb   rs   intrt   r   r_   r  )
r   z+np.ndarray | np.datetime64 | np.timedelta64rp   r   rt   znpt.NDArray[np.bool_]r   r   r_   z5np.ndarray | np.datetime64 | np.timedelta64 | NaTType)
rL   r   rp   r   rq   rb   rt   r   r_   r  )rp   r   rq   rb   )r   r   rp   r   r_   r   )r-  r   rt   r   rp   r   r.  r  r4   r  r_   z-tuple[float | np.ndarray, float | np.ndarray])rp   r   rq   rb   r.  r  )rL   r   rp   r   rq   rb   r.  r  )rL   r   rp   r   rq   rb   r.  r  rt   r   r_   r  )
rL   r   rp   r   rq   rb   rt   r   r_   zint | np.ndarray)
r   r   rp   r   rt   r   rq   rb   r_   znp.ndarray | int)
r-  r   rt   r   rp   r   r4   znp.dtype[np.floating]r_   z&np.floating | npt.NDArray[np.floating])r   )r   np.ndarray | float | NaTTyperp   r   rt   r   r   tuple[int, ...]rs   r  r_   r  )r   r  rt   r   rs   r  r_   rb   )
r  r   r  r   r~  r   r  
int | Noner_   r  )r~  r   r_   z)Callable[[np.ndarray, np.ndarray], float])
r  r   r  r   r  r  r.  r  r_   r  )rL   r   rq   rb   r_   r   )]
__future__r   r[   rJ   typingr   r   r   r   numpyr   pandas._configr   pandas._libsr   r	   r
   r   pandas._typingr   r   r   r   r   r   r   r   r   pandas.compat._optionalr   pandas.util._exceptionsr   pandas.core.dtypes.commonr   r   r   r   r   r   r   r   pandas.core.dtypes.missingr   r    r!   r   r'   r(   r+   r.   ri   rz   r|   r   r   r   r   r   r   r   ry   r   r   r   r   r   r   r  r   r4   r   r0  r7  r5  r?  rF  nanminnanmaxrN  rR  r_  rg  r   rL  r  r   rs  rX  r  r  r  r  r  r   r,   r*   <module>r     s   "   
   % 
 
 
 ? 4	 	 	   V<$  :67 8 >5 5p(
 GK!.,)) $),H)!)^ !%)-DDD D 	D
 'D 5DN	2&RDE>J  )-:: : 	:
 ': 
:@  )-:: : 	:
 ': 
:z 
$  )-** * 	*
 * '* *   *Z7
   	
 ;&   )-<< < 	<
 '< <  <~ 04TPT _% _%D
 8 hhrzz*//
&/ / 	/
 / 3/d   	*- *- 	*-
 *- *-Z 
$  	FF F 	F
 F  FR 
$  )-1)1) 1) 	1)
 1) '1) 1) 1)h. 
E&	1	E&	1  )-++ + 	+
 '+ +b  )-++ + 	+
 '+ +\ 
$  )-SS S 	S
 'S S  Sl 
$  )-\\ \ 	\
 '\ \  \~ 
$  )-(( ( 	(
 ( '( (  (V
 ' 	
 > $&88BJJ#7	&+&+
&&+ &+ !	&+
 ,&+\ -(-
- '- 	-
 - "-`">KN	>A 
$
 !*" 	
   >.@ 
$
 #))) 	)
 ) ) )6!H"r,   