Sindbad~EG File Manager

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

�

Mٜg(�����ddlmZddlZddlZddlmZmZmZddlZddl	Z
ddlmZddl
mZmZmZmZddlmZmZmZmZmZmZmZmZmZddlmZddlmZdd	l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dd
l)m*Z*m+Z+m,Z,edd�
�Z-e-duZ.da/dKdLd�Z0e0ed��Gd�d�Z1Gd�d�Z2dMd�Z3dNd�Z4	dO			dPd�Z5								dQd�Z6			dR											dSd�Z7dTd�Z8dUd�Z9dVdWd�Z:dXd�Z;dYd�Z<dXd �Z=dddd!�									dZd"�Z>dddd!�									dZd#�Z?e1d$�e;e=ddddd%�											d[d&����Z@										d\d'�ZAe2�e;dddd!�									d]d(���ZBe2�dddd!�d^d)��ZC						d_d*�ZDe
j�e
j��f											d`d+�ZGe2d,�-�ddd,dd.�					dad/��ZHe1d$d0�e2d,�-�ddd,dd.�							dbd1���ZIe1d$d0�ddd,dd.�											dcd2��ZJd3�ZKeKd4d5�6�ZLeKd7d8�6�ZMdddd!�									ddd9�ZNdddd!�									ddd:�ZOe1d$d0�e=dddd!�									d]d;���ZPe1d$d0�e=dddd!�									d]d<���ZQe1d$d0�e=ddddd%�											d[d=���ZR										ded>�ZSe
j�e
j��f									dfd?�ZT	dg											dhd@�ZU								didA�ZVdB�ZWe1d$d0�dCddD�									djdE��ZX				dkdF�ZYe1d$d0�dd,dG�									dldH��ZZdI�Z[dmdJ�Z\y)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��tr|ayy�N)�_BOTTLENECK_INSTALLED�_USE_BOTTLENECK)�vs �=/usr/local/lib/python3.12/site-packages/pandas/core/nanops.py�set_use_bottleneckr+9s������zcompute.use_bottleneckc�0��eZdZd�fd�Zdd�Zdd�Z�xZS)�disallowc�P��t�|��td�|D��|_y)Nc3�FK�|]}t|�j���y�wr&)r�type)�.0�dtypes  r*�	<genexpr>z$disallow.__init__.<locals>.<genexpr>Fs����I�&��L��/�4�4�&�s�!)�super�__init__�tuple�dtypes)�selfr8�	__class__s  �r*r6zdisallow.__init__Ds ���
�����I�&�I�I��r,c�r�t|d�xr*t|jj|j�S)Nr3)�hasattr�
issubclassr3r1r8)r9�objs  r*�checkzdisallow.checkHs'���s�G�$�P��C�I�I�N�N�D�K�K�)P�Pr,c�b���tj����fd��}tt|�S)Nc�4��tj||j��}t�fd�|D��r+�jjdd�}t
d|�d���	�|i|��S#t$r }t|d�rt
|�|��d}~wwxYw)Nc3�@�K�|]}�j|����y�wr&)r?)r2r>r9s  �r*r4z0disallow.__call__.<locals>._f.<locals>.<genexpr>Os�����7�h�s�4�:�:�c�?�h�s��nan�zreduction operation 'z' not allowed for this dtyper)	�	itertools�chain�values�any�__name__�replace�	TypeError�
ValueErrorr)�args�kwargs�obj_iter�f_name�e�fr9s     ��r*�_fzdisallow.__call__.<locals>._fLs���� ���t�V�]�]�_�=�H��7�h�7�7����+�+�E�2�6���+�F�8�3O�P���	
��$�)�&�)�)���
�
#�4��7�+�#�A�,�A�-���
�s�&A.�.	B�7B�B��	functools�wrapsrr)r9rRrSs`` r*�__call__zdisallow.__call__Ks,���	����	�	�
�	�$�A�r�{�r,)r8r�return�None�rX�bool)rRrrXr)rI�
__module__�__qualname__r6r?rW�
__classcell__)r:s@r*r.r.Cs���J�Q�r,r.c��eZdZddd�Zdd�Zy)�bottleneck_switchNc� �||_||_yr&)�namerN)r9rbrNs   r*r6zbottleneck_switch.__init__cs����	���r,c�������jxs�j�	tt���t
j��ddd�					d����fd��}tt|�S#tt
f$rd�Y�MwxYw)NT��axis�skipnac����t�
j�dkDr,�
jj�D]\}}||vs�|||<�|jdk(r|j	d��t||�Strn|rlt|j�	�rV|j	dd��6|jdd��|fd|i|��}t|�r�|f||d�|��}|S�|f||d�|��}|S�|f||d�|��}|S)Nr�	min_count�maskrerd)�lenrN�items�size�get�_na_for_min_countr(�_bn_ok_dtyper3�pop�	_has_infs)rGrerf�kwds�kr)�result�alt�bn_func�bn_namer9s       ����r*rRz%bottleneck_switch.__call__.<locals>.fos����4�;�;��!�#� �K�K�-�-�/�D�A�q���}�"#��Q��0��{�{�a��D�H�H�[�$9�$A�)���6�6��6�l�6�<�<��.Q��8�8�F�D�)�1��H�H�V�T�*�$�V�?�$�?�$�?�F�!��(�!$�V�!N�$�v�!N��!N���M�	!��J�d�6�J�T�J�F��M��V�F�$�v�F��F���Mr,)rG�
np.ndarrayre�AxisInt | Nonerfr[)
rbrI�getattr�bn�AttributeError�	NameErrorrUrVrr)r9rurRrvrws`` @@r*rWzbottleneck_switch.__call__gs�����)�)�+�s�|�|��	��b�'�*�G�
����	�$(��	%	��%	�!�%	��	%	�
�%	�N�A�q�z���W�	�*�	��G�	�s�A*�*A>�=A>r&)rXrY)rurrXr)rIr\r]r6rW�r,r*r`r`bs���0r,r`c�4�|tk7rt|�s|dvSy)N)�nansum�nanprod�nanmeanF)�objectr)r3rbs  r*roro�s"�����2�5�9��;�;�;�r,c��t|tj�r2|jdvr$t	j
|j
d��S	tj|�j�S#ttf$rYywxYw)N)�f8�f4�KF)�
isinstance�np�ndarrayr3r�has_infs�ravel�isinfrHrK�NotImplementedError)rts r*rqrq�sk���&�"�*�*�%��<�<�<�'��<�<����S� 1�2�2���x�x���#�#�%�%���*�+����s�"A1�1B�Bc���|�|St|�r8|�tjS|dk(rtjStjS|dk(rtj
StS)z9return the correct fill value for the dtype of the values�+inf)�_na_ok_dtyper�rC�infr�i8maxr
)r3�
fill_value�fill_value_typs   r*�_get_fill_valuer��sZ�������E���!��6�6�M���'��v�v�
����w���V�#��9�9���Kr,c��|�>|jjdvry|s|jjdvrt|�}|S)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)r3�kindr)rGrfris   r*�_maybe_get_maskr��sA��B�|��<�<����%���V�\�\�&�&�$�.���<�D��Kr,c��t|||�}|j}d}|jjdvr&tj|jd��}d}|rr|�pt
|||��}|�`|j�rP|st|�r+|j�}tj|||�||fStj|||�}||fS)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�r3r�r��asarray�viewr�rHr��copy�putmask�where)rGrfr�r�rir3�datetimelikes       r*�_get_valuesr��s���R�6�6�4�0�D��L�L�E��L�
�|�|���D� ����F�K�K��-�.����
�4�#�%��j��
�
��!��x�x�z��<��#6�#�[�[�]�F��J�J�v�t�Z�8�
�4�<�� �X�X�t�e�V�Z�@�F��4�<�r,c�<�|}|jdvr%tjtj�}|S|jdk(r%tjtj�}|S|jdk(r#tjtj
�}|S)N�bi�urR)r�r�r3�int64�uint64�float64)r3�	dtype_maxs  r*�_get_dtype_maxr�Ds{���I��z�z�T���H�H�R�X�X�&�	�
��	
���s�	��H�H�R�Y�Y�'�	���
���s�	��H�H�R�Z�Z�(�	��r,c�d�t|�ryt|jtj�S)NF)rr=r1r��integer�r3s r*r�r�Ps%���5�!���%�*�*�b�j�j�1�1�1r,c��|tur	|S|jdk(r�|�t}t|tj
�s�t
|�rJd��||k(rtj}t
|�r&t	jdd�j|�}n$t	j|�j|�}|j|d��}|S|j|�}|S|jdk(r�t|tj
�s�||k(st	j|�r&t	jd�j|�}|St	j|�tj kDrt#d��t	j|�j|d��}|S|jd	�j|�}|S)
zwrap our results if needed�MzExpected non-null fill_valuer�nsF�r��mzoverflow in timedelta operation�m8[ns])rr�r
r�r�r�rrC�
datetime64�astyper�r��isnan�timedelta64�fabsrr�rL)rtr3r�s   r*�
_wrap_resultsr�Vs���
��}��F�M�C
���s�	����J��&�"�*�*�-��J�'�G�)G�G�'���#������F�|����u�d�3�:�:�5�A�����&�)�.�.�u�5���]�]�5�u�]�5�F�&�M�!�]�]�5�)�F� �M�
���s�	��&�"�*�*�-���#�r�x�x��'7�����.�5�5�e�<���M������3�9�9�,� �!B�C�C����&�)�0�0��U�0�C��
�M��]�]�8�,�1�1�%�8�F��Mr,c�x��tj��dddd�							d�fd��}tt|�S)z�
    If we have datetime64 or timedelta64 values, ensure we have a correct
    mask before calling the wrapped function, then cast back afterwards.
    NT�rerfric����|}|jjdv}|r
|�t|�}�|f|||d�|��}|r0t||jt��}|s|�J�t||||�}|S)Nr�r�)r�)r3r�rr�r
�_mask_datetimelike_result)	rGrerfrirN�orig_valuesr�rt�funcs	        �r*�new_funcz&_datetimelike_compat.<locals>.new_func�s�������|�|�(�(�D�0���D�L���<�D��f�L�4��T�L�V�L���"�6�;�+<�+<��N�F���'�'�'�2�6�4��{�S���
r,�rGrxreryrfr[ri�npt.NDArray[np.bool_] | NonerT)r�r�s` r*�_datetimelike_compatr�s`����_�_�T�� $��-1�������	�
+����0��8��r,c�0�|jjdvr|jd�}t|j�}|jdk(r|S|�|S|j
d||j
|dzdz}t
j|||j��S)a�
    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�)r3r�r�r �ndim�shaper��full)rGrer��result_shapes    r*rnrn�s���"�|�|���G�#����y�)��#�F�L�L�1�J�
�{�{�a����	
�����|�|�E�T�*�V�\�\�$��(�*�-E�E���w�w�|�Z�v�|�|�D�Dr,c�f��tj��dd�d�fd��}tt|�S)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�rec	���|dk(r�|jdk(r�|jdr�|jddz|jdkDr�|jtk7r�|jt
k7r�t
|�}|jd��B|jd�}tt|��D�cgc]}�||fd||i|����}}n|D�cgc]}�|fi|����
}}tj|�S�|fd|i|��Scc}wcc}w)Nr���C_CONTIGUOUSi�rrire)
r��flagsr�r3r�r[�listrmrp�rangerjr��array)	rGrerN�arrsri�i�results�xr�s	        �r*�newfuncz&maybe_operate_rowwise.<locals>.newfunc�s���
�A�I����q� ����^�,����a��4�'�6�<�<��?�:�����&�����$���<�D��z�z�&�!�-��z�z�&�)��CH��T��CS��CS�a�D��a��9�t�A�w�9�&�9�CS���7;�;�d��4��,�V�,�d��;��8�8�G�$�$��F�0��0��0�0����<s�0D�D)rGrxreryrT)r�r�s` r*�maybe_operate_rowwiser��s2����_�_�T��>B�1��1�.��7��r,r�c�h�|jjdvr|�|j|�S|jjdk(r$tjdt
t
���t||d|��\}}|jtk(r|jt�}|j|�S)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�ri)r3r�rH�warningsr#�
FutureWarningrr�r�r�r[�rGrerfri�_s     r*�nananyr��s���D�|�|���E�!�d�l��z�z�$���
�|�|���C���
�
�
J��'�)�		
��F�F�u�4�H�I�F�A��|�|�v�����t�$���:�:�d��r,c�h�|jjdvr|�|j|�S|jjdk(r$tjdt
t
���t||d|��\}}|jtk(r|jt�}|j|�S)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�)r3r��allr�r#r�rr�r�r�r[r�s     r*�nanallr�s���D�|�|���E�!�d�l��z�z�$���
�|�|���C���
�
�
J��'�)�		
��F�F�t�$�G�I�F�A��|�|�v�����t�$���:�:�d��r,�M8)rerfrhric�:�|j}t||d|��\}}t|�}|jdk(r|}n2|jdk(r#t	jtj
�}|j
||��}t||||j|��}|S)a�
    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
    rr�rRr�r��rh)	r3r�r�r�r�r��sum�_maybe_null_outr�)rGrerfrhrir3�	dtype_sum�the_sums        r*r�r�\s���D
�L�L�E��v�v�!�$�G�L�F�D��u�%�I��z�z�S���	�	���s�	��H�H�R�Z�Z�(�	��j�j��Y�j�/�G��g�t�T�6�<�<�9�U�G��Nr,c�L�t|tj�rG|jd�j	|j
�}|j
|��}t||<|S|j
�r2tjt�j	|j
�S|S)Nr�r�)	r�r�r�r�r�r3rHr
r�)rtrerir��	axis_masks     r*r�r��s����&�"�*�*�%����t�$�)�)�+�*;�*;�<���H�H�$�H�'�	�!��y���M��8�8�:��8�8�D�>�&�&�{�'8�'8�9�9��Mr,c�4�|j}t||d|��\}}t|�}tjtj�}|j
dvr$tjtj�}nE|j
dvr$tjtj�}n|j
dk(r|}|}t
|j|||��}|j||��}t|�}|�ut|dd	�rhttj|�}tjd
��5||z}	ddd�|dk(}
|
j�rtj	|
<	S|dkDr||zntj}	|	S#1swY�OxYw)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
    rr�r��iurRr�Nr�F�ignore)r�)r3r�r�r�r�r��_get_countsr�r��_ensure_numericrzrr��errstaterHrC)rGrerfrir3r��dtype_count�countr��the_mean�ct_masks           r*r�r��sK��B
�L�L�E��v�v�!�$�G�L�F�D��u�%�I��(�(�2�:�:�&�K�
�z�z�T���H�H�R�Z�Z�(�	�	���t�	��H�H�R�Z�Z�(�	�	���s�	��	�������d�D��D�E��j�j��Y�j�/�G��g�&�G���G�G�V�U�;��R�Z�Z��'��
�[�[�X�
&����H�'��1�*���;�;�=� "���H�W���O�',�a�i�7�U�?�R�V�V���O�'�
&�s�:F�Fc�t��|jjdk(xr|du}d�fd�	}|j}t|�|d��\}}|jjdk7rM|jtk(r(t	j
|�}|dvrt
d|�d���	|jd�}|s;|�9|jjs|j�}tj||<|j}	|j d	kDr�|��|	rÉstj"|||�}
n�t%j&�5t%j(d
dt*�|j,d	d	k(r|dk(s|j,dd	k(r0|d	k(r+tj.tj0|�d
��}
ntj.||��}
ddd�n2t3|j,|�}
n|	r	|||�ntj}
t5
|�S#t$r}t
t|��|�d}~wwxYw#1swY�;xYw)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
    rRNc�(��|�t|�}n|}�s |j�stjSt	j
�5t	jddt�tj||�}ddd�|S#1swYSxYw)Nr��All-NaN slice encountered)	r!r�r�rCr��catch_warnings�filterwarnings�RuntimeWarning�	nanmedian)r��_mask�resrfs   �r*�
get_medianznanmedian.<locals>.get_median�s{����=��!�H�E��F�E��e�i�i�k��6�6�M�
�
$�
$�
&��#�#��5�~�
��,�,�q��x�(�C�'��
�
'��
�s�	4B�B)rir���string�mixedzCannot convert � to numericr�r�r�r�rT)�keepdimsr�r&)r3r�r�r�r�infer_dtyperKr�rL�strr��	writeabler�r�rCrlr��apply_along_axisr�r�rrr�r�squeeze�_get_empty_reduction_resultr�)rGrerfri�using_nan_sentinelrr3�inferred�err�notemptyrs  `        r*rr�s����6 ���*�*�c�1�B�d�d�l��
�
�L�L�E��v�v�D�T�J�L�F�D�
�|�|���C���<�<�6�!����v�.�H��.�.��/�&��� E�F�F�	/��]�]�4�(�F��$�"2��|�|�%�%��[�[�]�F��v�v��t���{�{�H��{�{�Q��4�+����)�)�*�d�F�C���,�,�.��+�+� �"=�~�����Q��1�,�������Q��1�,����!�l�l�2�:�:�f�+=��M�� �l�l�6��=��/�.�$.�f�l�l�D�A�C�+3�j���&�������e�$�$��U�	/��C��H�%�3�.��	/��&/�.�s%�H�5BH.�	H+�H&�&H+�.H7c��tj|�}tjt|��}tj|||k7tj
��}|j
tj�|S)z�
    The result from a reduction on an empty ndarray.

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

    Returns
    -------
    np.ndarray
    r�)r�r��arangerj�emptyr��fillrC)r�re�shp�dims�rets     r*rrCsU�� 
�(�(�5�/�C�
�9�9�S��Z� �D�
�(�(�3�t�t�|�$�B�J�J�
7�C��H�H�R�V�V���Jr,c��t||||��}||j|�z
}t|�r)||kr tj}tj}||fSttj|�}||k}|j�rJtj||tj�tj||tj�||fS)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�r1rr�rCrr�rHr�)�values_shaperire�ddofr3r��ds       r*�_get_counts_nanvarr Zs���:
��d�D��>�E�
��
�
�4� � �A�����D�=��F�F�E����A��!�8�O��R�Z�Z��'����}���8�8�:��J�J�q�$����'��J�J�u�d�B�F�F�+��!�8�Or,r��r�rerfrric	���|jdk(r|jd�}|j}t|||��\}}tjt|||||���}t
||�S)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
    zM8[ns]r�)rir")r3r�r�r��sqrt�nanvarr�)rGrerfrri�
orig_dtyperts       r*�nanstdr'�sb��H�|�|�x�����X�&�����J��v�v�D�9�L�F�D�
�W�W�V�F��f�4�d�S�
T�F����,�,r,�m8c��|j}t|||�}|jdvr&|jd�}|�tj
||<|jjdk(r't
|j||||j�\}}nt
|j|||�\}}|r)|�'|j�}t	j||d�t|j|tj���|z}|�t	j||�}t||z
dz�}	|�t	j|	|d�|	j|tj��|z}
|jdk(r|
j|d��}
|
S)	a�
    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�rRr)rer3r�Fr�)r3r�r�r�r�rCr r�r�r�r�r�r��expand_dims)rGrerfrrir3r�r�avg�sqrrts           r*r%r%�sU��J
�L�L�E��6�6�4�0�D��z�z�T�����t�$�����6�6�F�4�L�
�|�|���C��%�f�l�l�D�$��f�l�l�S���q�%�f�l�l�D�$��E���q�
�$�"������
�
�
�6�4��#��&�*�*�$�b�j�j�*�A�
B�U�
J�C����n�n�S�$�'��
�3��<�A�-�
.�C���
�
�
�3��a� �
�W�W�$�b�j�j�W�
1�A�
5�F�

�z�z�S�����u�5��1���Mr,c��t|||||��t|||�}|jjdk7r|j	d�}|s"|� |j�rtjSt|j||||j�\}}t|||||��}t
j|�t
j|�zS)a�
    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
    r"rRr�)r%r�r3r�r�rHr�rCr r�r$)rGrerfrrir�r��vars        r*�nansemr/s���L�6��V�$�T�B��6�6�4�0�D�
�|�|���C�����t�$���d�&�4�8�8�:��v�v�
�!�&�,�,��d�D�&�,�,�O�H�E�1�
��d�6��4�
H�C�
�7�7�3�<�"�'�'�%�.�(�(r,c�f���td�����tdddd�							d��fd���}|S)NrC)rbTr�c���|jdk(rt||�St||�|��\}}t|��|�}t	||||j
�}|S)Nr�r�ri)rlrnr�rzr�r�)rGrerfrirtr��meths     ��r*�	reductionz_nanminmax.<locals>.reduction;sc����;�;�!��$�V�T�2�2�"��F�>��
����'����&�t�,�� ���t�V�\�\�B���
r,r�)r`r�)r3r�r4s`` r*�
_nanminmaxr5:sa����c�$��L�)�� $��-1�������	�
+���*��"�r,�minr�)r��max�-infc�h�t|dd|��\}}|j|�}t||||�}|S)a�
    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])
    Tr8r2)r��argmax�_maybe_arg_null_out�rGrerfrirts     r*�	nanargmaxr=U�>��L�v�t�F��N�L�F�D�
�]�]�4�
 �F�!���t�V�
<�F��Mr,c�h�t|dd|��\}}|j|�}t||||�}|S)a�
    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�r2)r��argminr;r<s     r*�	nanargminrA�r>r,c�:�t|||�}|jjdk7r)|jd�}t	|j
||�}n#t	|j
|||j��}|r*|�(|j
�}tj||d�n$|s"|� |j�rtjStjdd��5|j|tj��|z}ddd�|�tj|�}|z
}|r|�tj||d�|dz}||z}|j|tj��}	|j|tj��}
t|	�}	t|
�}
tjdd��5||d	z
d
zz|dz
z|
|	dzzz}ddd�|j}|jdk(rj|d�
�}t!tj"�r2tj$|	dk(d|�}tj||dk<|S|	dk(r|j'd�n|}|dkrtjS|S#1swY���xYw#1swY��xYw)a�
    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
    rRr�r�Nrr���invalid�divider�r�g�?g�?Fr��)r�r3r�r�r�r�r�r�r�rHrCr�r�r�r*�_zero_out_fperrr�r�r�r1)
rGrerfrir��mean�adjusted�	adjusted2�	adjusted3�m2�m3rtr3s
             r*�nanskewrN�s4��J�6�6�4�0�D�
�|�|���C�����t�$���F�L�L�$��5���F�L�L�$��F�L�L�I��
�$�"������
�
�
�6�4��#�
��(�T�X�X�Z��v�v�
�	���X�h�	7��z�z�$�b�j�j�z�1�E�9��
8����~�~�d�D�)����}�H�
�$�"�
�
�
�8�T�1�%��!��I��H�$�I�	���t�2�:�:��	.�B�	���t�2�:�:��	.�B�
��	�B�	��	�B�	���X�h�	7��5�1�9��,�,���	�:�r�B��G�|�L��
8�
�L�L�E��z�z�S�����u�5��1���&�"�*�*�%����"��'�1�f�-���F�F��u�q�y���M�	#%��'����A��v���1�9��6�6�M��M�G
8�	7��(
8�	7�s�%J�8J�J�Jc�"�t|||�}|jjdk7r)|jd�}t	|j
||�}n#t	|j
|||j��}|r*|�(|j
�}tj||d�n$|s"|� |j�rtjStjdd��5|j|tj��|z}ddd�|�tj|�}|z
}|r|�tj||d�|dz}|dz}|j|tj��}	|j|tj��}
tjdd��5d	|d
z
dzz|dz
|d	z
zz}||d
zz|d
z
z|
z}|dz
|d	z
z|	dzz}
ddd�t�}t
�}
t!|
tj"�s5|dkrtjS|
dk(r|jj%d�Stjdd��5||
zz
}ddd�|j}|jdk(rj|d�
�}t!tj"�r0tj&|
dk(d|�}tj||dk<|S#1swY���xYw#1swY��xYw#1swY��xYw)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
    rRr�r�Nrr�rCr�rFr��Fr�)r�r3r�r�r�r�r�r�r�rHrCr�r�r�r*rGr�r�r1r�)rGrerfrir�rHrIrJ�	adjusted4rL�m4�adj�	numerator�denominatorrtr3s                r*�nankurtrV	s���J�6�6�4�0�D�
�|�|���C�����t�$���F�L�L�$��5���F�L�L�$��F�L�L�I��
�$�"������
�
�
�6�4��#�
��(�T�X�X�Z��v�v�
�	���X�h�	7��z�z�$�b�j�j�z�1�E�9��
8����~�~�d�D�)����}�H�
�$�"�
�
�
�8�T�1�%��!��I��1��I�	���t�2�:�:��	.�B�	���t�2�:�:��	.�B�	���X�h�	7��5�1�9��"�"�u�q�y�U�Q�Y�&?�@���U�Q�Y�'�5�1�9�5��:�	��q�y�U�Q�Y�/�"�a�%�7��
8� �	�*�I�!�+�.�K��k�2�:�:�.��1�9��6�6�M��!���<�<�$�$�Q�'�'�	���X�h�	7��[�(�3�.��
8�
�L�L�E��z�z�S�����u�5��1���&�"�*�*�%����+��*�A�v�6���F�F��u�q�y���M�Y
8�	7��
8�	7��(
8�	7�s$�%K+�":K8� 	L�+K5�8L�Lc��t|||�}|r|�|j�}d||<|j|�}t||||j|��S)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�)rGrerfrhrirts      r*r�r�js[��@�6�6�4�0�D�
�$�"��������t��
�[�[��
�F����d�F�L�L�I��r,c���|�|S|�
t|dd�s&|r|j�ry|j�ry|S|r|j|�}n|j|�}|j�rd||<|S)Nr�F���)rzr�rH)rtrerirf�na_masks     r*r;r;�sv���|��
��|�7�6�6�5�9���x�x�z���x�x�z���M�
��h�h�t�n�G��h�h�t�n�G��;�;�=� �F�7�O��Mr,c�B�|�F|�|j|j�z
}ntj|�}|j	|�S|�"|j
||j|�z
}n||}t
|�r|j	|�S|j|d��S)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�)rlr�r�rXr1r�rr�)rrirer3�nr�s      r*r�r��s���0�|����	�	�D�H�H�J�&�A�����%�A��z�z�!�}�����
�
�4� �4�8�8�D�>�1���T�"���%���z�z�%� � ��<�<��E�<�*�*r,c��|�|dk(r|S|��t|tj�r�|�(|j||j	|�z
|z
dk}n/|||z
dk}|d|||dzdz}tj
||�}tj|�rjt|�rZtj|�r|jd�}nt|�s|jdd��}tj||<|Sd||<|S|turHt|||�r;t|dd�}t|�r|jd	�}|Stj}|S)
zu
    Returns
    -------
    Dtype
        The product of all elements on a given axis. ( NaNs are treated as 1)
    Nrr��c16r�Fr�r3rC)r�r�r�r�r��broadcast_torHr�iscomplexobjr�rrCr�check_below_min_countrzr1)	rtrerir�rh�	null_mask�below_count�	new_shape�result_dtypes	         r*r�r��sU���|�	�Q���
���J�v�r�z�z�:������D�)�D�H�H�T�N�:�Y�F�!�K�I� ��+�	�1�A�5�K��e�t��u�T�A�X�Z�'8�8�I�����Y�?�I�
�6�6�)����'��?�?�6�*�#�]�]�5�1�F�'��/�#�]�]�4�e�]�<�F�$&�F�F��y�!��M�%)��y�!��M�
�s�	� ���i�8�"�6�7�D�9�L��l�+�%�*�*�5�1���M������Mr,c��|dkDr;|�tj|�}n|j|j�z
}||kryy)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
    rTF)r�rXrlr�)r�rirh�	non_nullss    r*rbrbs?��(�1�}��<������I��	�	�D�H�H�J�.�I��y� ��r,c��t|tj�r-tjtj|�dkd|�Stj|�dkr|j
j
d�S|S)Ng�+����=r)r�r�r�r��absr3r1)�args r*rGrG*sW���#�r�z�z�"��x�x����s��e�+�Q��4�4�$&�F�F�3�K�%�$7�s�y�y�~�~�a� �@�S�@r,�pearson)�method�min_periodsc�@�t|�t|�k7rtd��|�d}t|�t|�z}|j�s
||}||}t|�|krtj
St
|�}t
|�}t|�}|||�S)z
    a, b: ndarrays
    z'Operands to nancorr must have same sizer�)rj�AssertionErrorr!r�r�rCr��
get_corr_func)�a�brmrn�validrRs      r*�nancorrru2s����1�v��Q����F�G�G������!�H�u�Q�x��E��9�9�;�
�e�H��
�e�H��
�1�v����v�v�
����A����A��f��A��Q��7�Nr,c����|dk(r
ddlm��fd�}|S|dk(r
ddlm��fd�}|S|dk(rd	�}|St|�r|St	d
|�d���)N�kendallr)�
kendalltauc����||�dS�Nrr~)rrrsrxs  �r*r�zget_corr_func.<locals>.funcXs����a��#�A�&�&r,�spearman)�	spearmanrc����||�dSrzr~)rrrsr|s  �r*r�zget_corr_func.<locals>.func_s����Q��?�1�%�%r,rlc�4�tj||�dS)N�rr�)r��corrcoef)rrrss  r*r�zget_corr_func.<locals>.funces���;�;�q�!�$�T�*�*r,zUnknown method 'z@', expected one of 'kendall', 'spearman', 'pearson', or callable)�scipy.statsrxr|�callablerL)rmr�rxr|s  @@r*rqrqRsr������*�	'���	�:�	�)�	&���	�9�	�	+���	�&�	��
�
�
�6�(�#8�	8��r,)rnrc�N�t|�t|�k7rtd��|�d}t|�t|�z}|j�s
||}||}t|�|krtj
St
|�}t
|�}t	j|||��dS)Nz&Operands to nancov must have same sizer�r!r)rjrpr!r�r�rCr��cov)rrrsrnrrts     r*�nancovr�rs����1�v��Q����E�F�F������!�H�u�Q�x��E��9�9�;�
�e�H��
�e�H��
�1�v����v�v�
����A����A�
�6�6�!�Q�T�"�4�(�(r,c��t|tj�r�|jjdvr!|jtj�}|S|jtk(r~tj|�}|dvrtd|�d���	|jtj�}tjtj|��s|j}|S|St!|�sCt#|�s8t%|�s-t|t&�rtd|�d���	t)|�}|S|S#ttf$rF	|jtj�}n!#t$r}td|�d��|�d}~wwxYwY|SwxYw#ttf$r1	t+|�}Y|S#t$r}td|�d��|�d}~wwxYwwxYw)Nr�rzCould not convert r	zCould not convert string 'z' to numeric)r�r�r�r3r�r�r�r�rrrK�
complex128rH�imag�realrLrrrr�float�complex)r�rrs   r*r�r��s����!�R�Z�Z� ��7�7�<�<�5� �������$�A�<
�H�;�W�W��
����q�)�H��.�.��"4�Q�C�{� C�D�D�

��H�H�R�]�]�+���v�v�b�g�g�a�j�)����A�
�H�1�H��q�k�Z��]�j��m��a����8���<�H�I�I�	N��a��A�
�H�1�H��-�z�*�
R�R�������,�A��!�R�#�&8���;�$G�H�c�Q��R���(
�H�-
R���:�&�	N�
N��A�J��
�H���
N��"4�Q�C�{� C�D�#�M��
N��		N�s`�D7�(F�7F�E'�&F�'	F�0F�F�F�F�G�F-�-	G�6G�G�Gc	��tjdtjftjjtj
tjftjdtjftjjtj
tjfi|\}}|jjdvsJ�|rot|jjtjtjf�s1|j�}t|�}|||<||d��}|||<|S||d��}|S)a
    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�?gr�rr�)r��cumprodrC�maximum�
accumulater��cumsum�minimumr3r�r=r1r��bool_r�r)rG�
accum_funcrf�mask_a�mask_b�valsrirts        r*�
na_accum_funcr��s��	�
�
�S�"�&�&�M�
�
�
����������0�
�	�	�C����=�
�
�
���������/�	�
��N�F�F��<�<���D�(�(�(��j����!2�!2�R�Z�Z����4J�K��{�{�}���D�z����T�
��D�q�)����t���M��F��+���Mr,)T)r)r[rXrY)r3rrbrrXr[rZ)NN)r3rr�z
Scalar | None)rGrxrfr[rir�rXr�)NNN)rGrxrfr[r�rr�z
str | Nonerir�rXz/tuple[np.ndarray, npt.NDArray[np.bool_] | None])r3�np.dtyperXr�)r3rrXr[r&)r3r�)r�rrXr)rGrxreryrXzScalar | np.ndarray)
rGrxreryrfr[rir�rXr[)rGrxreryrfr[rh�intrir�rXr�)
rtz+np.ndarray | np.datetime64 | np.timedelta64reryriznpt.NDArray[np.bool_]r�rxrXz5np.ndarray | np.datetime64 | np.timedelta64 | NaTType)
rGrxreryrfr[rir�rXr�)reryrfr[)r�rrer
rXrx)rrrir�reryrr�r3r�rXz-tuple[float | np.ndarray, float | np.ndarray])reryrfr[rr�)rGrxreryrfr[rr�)rGrxreryrfr[rr�rir�rXr�)
rGrxreryrfr[rir�rXzint | np.ndarray)
rtrxreryrir�rfr[rXznp.ndarray | int)
rrrir�reryr3znp.dtype[np.floating]rXz&np.floating | npt.NDArray[np.floating])r�)rt�np.ndarray | float | NaTTypereryrir�r��tuple[int, ...]rhr�rXr�)r�r�rir�rhr�rXr[)
rrrxrsrxrmrrn�
int | NonerXr�)rmrrXz)Callable[[np.ndarray, np.ndarray], float])
rrrxrsrxrnr�rr�rXr�)rGrrfr[rXr)]�
__future__rrUrE�typingrrrr��numpyr��pandas._configr�pandas._libsrr	r
r�pandas._typingrr
rrrrrrr�pandas.compat._optionalr�pandas.util._exceptionsr�pandas.core.dtypes.commonrrrrrrrr�pandas.core.dtypes.missingrr r!r{r'r(r+r.r`rorqr�r�r�r�r�r�r�rnr�r�r�r�r�r�rrr3r�r r'r%r/r5�nanmin�nanmaxr=rArNrVr�r;r�r�rbrGrurqr�r�r�r~r,r*�<module>r�s��"�����
��%���
�
�
�?�4�	�	�	��� ��V�<���$�������:�6�7�8���>5�5�p�(
�GK����!.��,)��)� $�)�,H�)�!�)�^�!%�)-�D��D��D��D��	D�
'�D�5�
D�N	�2�&�R�DE�>�J ��)-�:��:��:�
�	:�
'�:�
�
:�@ ��)-�:��:��:�
�	:�
'�:�
�
:�z
�$���� ���)-�
*��*��*�
�	*�
�*�'�
*��*����*�Z�7��
�� ���	�
;��&��� ��)-�<��<��<�
�	<�
'�<��
<���<�~��04�T�PT�_%��_%�D���
����8�b�h�h�r�z�z�*�/��/�
&�/��/��	/�
�/�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���
��'��
�	�
��>$,�2�8�8�B�J�J�#7�	&+��&+�
&�&+��&+�!�	&+�
,�&+�\�-�(�-�
�-�'�-��	-�
�-�"�
-�`���">��KN��	��>A�
�$���
!*�"������
�	�
���
���>���.��@
�$���
#��)��)��)��	)�
�)��
)��)�6!
�H"r,

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