§
    tŠtjF:  ã                  óL  — d Z ddlmZ ddlmZmZ ddlmZmZ ddl	Z
ddlmZ ddlmZ ddlmZmZ  ed	ee¦  «        Z ed
eed¦  «        Zd7d„Zd7d„Zd7d„Zd7d„Zd7d„Zd7d„Z	 	 d8d9d„Zd:d„Zd;d<d„Zd=d#„Zed>d%„¦   «         Z ed?d(„¦   «         Z d@d+„Z dAd/„Z!dBd1„Z"dCd5„Z#d7d6„Z$dS )DzV
Module that contains many useful utilities
for validating data or function arguments
é    )Úannotations)ÚIterableÚSequence)ÚTypeVarÚoverloadN)Úlib)ÚNA)Úis_boolÚ
is_integerÚBoolishTÚBoolishNoneTÚreturnÚNonec           
     ó  — |dk     rt          d¦  «        ‚t          |¦  «        t          |¦  «        k    rIt          |¦  «        |z   }t          |¦  «        |z   }|dk    rdnd}t          | › d|› d|› d|› d	�¦  «        ‚d
S )zÀ
    Checks whether 'args' has length of at most 'compat_args'. Raises
    a TypeError if that is not the case, similar to in Python when a
    function is called with too many arguments.
    r   z*'max_fname_arg_count' must be non-negativeé   ÚargumentÚ	argumentsz() takes at most ú z (z given)N)Ú
ValueErrorÚlenÚ	TypeError)ÚfnameÚargsÚmax_fname_arg_countÚcompat_argsÚmax_arg_countÚactual_arg_countr   s          úU/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/pandas/util/_validators.pyÚ_check_arg_lengthr      sÀ   € ð ˜QÒÐÝÐEÑFÔFÐFå
ˆ4�y„y•3�{Ñ#Ô#Ò#Ð#Ý˜KÑ(Ô(Ð+>Ñ>ˆÝ˜t™9œ9Ð':Ñ:ÐØ!.°!Ò!3Ð!3�:�:¸ˆåØð *ð * }ð *ð *°xð *ð *Ø ð*ð *ð *ñ
ô 
ð 	
ð $Ð#ó    c                ó  — |D ]{}	 ||         }||         }|�|�|€|�d}n||k    }t          |¦  «        st          d¦  «        ‚n # t          $ r ||         ||         u }Y nw xY w|st          d|› d| › d�¦  «        ‚Œ|dS )zø
    Check that the keys in `arg_val_dict` are mapped to their
    default values as specified in `compat_args`.

    Note that this function is to be called only when it has been
    checked that arg_val_dict.keys() is a subset of compat_args
    NFz'match' is not a booleanzthe 'z=' parameter is not supported in the pandas implementation of z())r
   r   )r   Úarg_val_dictr   ÚkeyÚv1Úv2Úmatchs          r   Ú_check_for_default_valuesr'   3   sô   € ð ð ð ˆð	:Ø˜cÔ"ˆBØ˜SÔ!ˆBð � 2 :°2°:À"À.Ø��à˜bš�å˜5‘>”>ð =Ý Ð!;Ñ<Ô<Ð<ð=øõ
 ð 	:ð 	:ð 	:Ø  Ô%¨°SÔ)9Ð9ˆEˆEˆEð	:øøøð ð 	Ýð:˜ð :ð :Ø05ð:ð :ð :ñô ð ð	ð/ð s   †?AÁA#Á"A#c                óŠ   — t          | |||¦  «         t          t          ||d¬¦  «        ¦  «        }t          | ||¦  «         dS )a  
    Checks whether the length of the `*args` argument passed into a function
    has at most `len(compat_args)` arguments and whether or not all of these
    elements in `args` are set to their default values.

    Parameters
    ----------
    fname : str
        The name of the function being passed the `*args` parameter
    args : tuple
        The `*args` parameter passed into a function
    max_fname_arg_count : int
        The maximum number of arguments that the function `fname`
        can accept, excluding those in `args`. Used for displaying
        appropriate error messages. Must be non-negative.
    compat_args : dict
        A dictionary of keys and their associated default values.
        In order to accommodate buggy behaviour in some versions of `numpy`,
        where a signature displayed keyword arguments but then passed those
        arguments **positionally** internally when calling downstream
        implementations, a dict ensures that the original
        order of the keyword arguments is enforced.

    Raises
    ------
    TypeError
        If `args` contains more values than there are `compat_args`
    ValueError
        If `args` contains values that do not correspond to those
        of the default values specified in `compat_args`
    F©ÚstrictN)r   ÚdictÚzipr'   )r   r   r   r   Úkwargss        r   Úvalidate_argsr.   Y   sP   € õ@ �e˜TÐ#6¸ÑDÔDÐDõ
 •#�k 4°Ð6Ñ6Ô6Ñ7Ô7€FÝ˜e V¨[Ñ9Ô9Ð9Ð9Ð9r    c                óª   — t          |¦  «        t          |¦  «        z
  }|r1t          t          |¦  «        ¦  «        }t          | › d|› d�¦  «        ‚dS )z}
    Checks whether 'kwargs' contains any keys that are not
    in 'compat_args' and raises a TypeError if there is one.
    z'() got an unexpected keyword argument 'ú'N)ÚsetÚnextÚiterr   )r   r-   r   ÚdiffÚbad_args        r   Ú_check_for_invalid_keysr6   ‚   sc   € õ ˆv‰;Œ;�˜[Ñ)Ô)Ñ)€Dàð UÝ•t˜D‘z”zÑ"Ô"ˆÝ˜5ÐSÐSÈÐSÐSÐSÑTÔTÐTðUð Ur    c                ór   — |                      ¦   «         }t          | ||¦  «         t          | ||¦  «         dS )aÞ  
    Checks whether parameters passed to the **kwargs argument in a
    function `fname` are valid parameters as specified in `*compat_args`
    and whether or not they are set to their default values.

    Parameters
    ----------
    fname : str
        The name of the function being passed the `**kwargs` parameter
    kwargs : dict
        The `**kwargs` parameter passed into `fname`
    compat_args: dict
        A dictionary of keys that `kwargs` is allowed to have and their
        associated default values

    Raises
    ------
    TypeError if `kwargs` contains keys not in `compat_args`
    ValueError if `kwargs` contains keys in `compat_args` that do not
    map to the default values specified in `compat_args`
    N)Úcopyr6   r'   )r   r-   r   Úkwdss       r   Úvalidate_kwargsr:   �   s;   € ð, �;Š;‰=Œ=€DÝ˜E 6¨;Ñ7Ô7Ð7Ý˜e T¨;Ñ7Ô7Ð7Ð7Ð7r    c                ó4  — t          | |t          |                     ¦   «         ¦  «        z   ||¦  «         t          t	          ||d¬¦  «        ¦  «        }|D ]}||v rt          | › d|› d�¦  «        ‚Œ|                     |¦  «         t          | ||¦  «         dS )aý  
    Checks whether parameters passed to the *args and **kwargs argument in a
    function `fname` are valid parameters as specified in `*compat_args`
    and whether or not they are set to their default values.

    Parameters
    ----------
    fname: str
        The name of the function being passed the `**kwargs` parameter
    args: tuple
        The `*args` parameter passed into a function
    kwargs: dict
        The `**kwargs` parameter passed into `fname`
    max_fname_arg_count: int
        The minimum number of arguments that the function `fname`
        requires, excluding those in `args`. Used for displaying
        appropriate error messages. Must be non-negative.
    compat_args: dict
        A dictionary of keys that `kwargs` is allowed to
        have and their associated default values.

    Raises
    ------
    TypeError if `args` contains more values than there are
    `compat_args` OR `kwargs` contains keys not in `compat_args`
    ValueError if `args` contains values not at the default value (`None`)
    `kwargs` contains keys in `compat_args` that do not map to the default
    value as specified in `compat_args`

    See Also
    --------
    validate_args : Purely args validation.
    validate_kwargs : Purely kwargs validation.

    Fr)   z-() got multiple values for keyword argument 'r0   N)r   ÚtupleÚvaluesr+   r,   r   Úupdater:   )r   r   r-   r   r   Ú	args_dictr#   s          r   Úvalidate_args_and_kwargsr@   ª   sÃ   € õP Øˆt•e˜FŸMšM™OœOÑ,Ô,Ñ,Ð.AÀ;ñô ð õ •S˜ d°5Ð9Ñ9Ô9Ñ:Ô:€Iàð ð ˆØ�&ˆ=ˆ=ÝØÐMÐMÀsÐMÐMÐMñô ð ð ð
 ‡M‚M�)ÑÔÐÝ�E˜6 ;Ñ/Ô/Ð/Ð/Ð/r    TFÚvalueÚarg_nameÚstrÚnone_allowedÚboolÚint_allowedc                óº   — t          | ¦  «        }|r|p| du }|r|pt          | t          ¦  «        }|s(t          d|› dt	          | ¦  «        j        › d�¦  «        ‚| S )aR  
    Ensure that argument passed in arg_name can be interpreted as boolean.

    Parameters
    ----------
    value : bool
        Value to be validated.
    arg_name : str
        Name of the argument. To be reflected in the error message.
    none_allowed : bool, default True
        Whether to consider None to be a valid boolean.
    int_allowed : bool, default False
        Whether to consider integer value to be a valid boolean.

    Returns
    -------
    value
        The same value as input.

    Raises
    ------
    ValueError
        If the value is not a valid boolean.
    NzFor argument "z$" expected type bool, received type ú.)r
   Ú
isinstanceÚintr   ÚtypeÚ__name__)rA   rB   rD   rF   Ú
good_values        r   Úvalidate_bool_kwargrN   ä   sŽ   € õ< ˜‘”€JØð 3ØÐ2 E¨T Mˆ
àð :ØÐ9¥:¨eµSÑ#9Ô#9ˆ
àð 
Ýð,˜Xð ,ð ,Ý˜‘K”KÔ(ð,ð ,ð ,ñ
ô 
ð 	
ð €Lr    Únamec                óÚ   — | t           j        u sHt          | t          ¦  «        s3| �1| t          u s(t          j        | ¦  «        rt          j        | ¦  «        rdS t          |› d| › �¦  «        ‚)a   
    Validate na arguments.

    Parameters
    ----------
    value : object
        Value to validate.
    name : str
        Name of the argument, used to raise an informative error message.

    Raises
    ______
    ValueError
        When ``value`` is determined to be invalid.
    Nz2 must be None, pd.NA, np.nan, True, or False; got )	r   Ú
no_defaultrI   rE   r	   Úis_floatÚnpÚisnanr   )rA   rO   s     r   Úvalidate_na_argrU     sw   € ð" 	•”ÐÐÝ�e�TÑ"Ô"ð 	 àˆ=Ø•Bˆ;ˆ;ÝŒL˜ÑÔð Ý$&¤H¨U¡O¤Oð ð 	ˆÝ
˜ÐWÐWÐPUÐWÐWÑ
XÔ
XÐXr    Úvalidate_scalar_dict_valuec                ó  — ddl m} | €|€t          d¦  «        ‚| €|� ||¦  «        }n[| �F|€D|rAt          | t          t
          f¦  «        r%t          dt          | ¦  «        j        › d�¦  «        ‚n| �|�t          d¦  «        ‚| |fS )a$  
    Validate the keyword arguments to 'fillna'.

    This checks that exactly one of 'value' and 'method' is specified.
    If 'method' is specified, this validates that it's a valid method.

    Parameters
    ----------
    value, method : object
        The 'value' and 'method' keyword arguments for 'fillna'.
    validate_scalar_dict_value : bool, default True
        Whether to validate that 'value' is a scalar or dict. Specifically,
        validate that it is not a list or tuple.

    Returns
    -------
    value, method : object
    r   )Úclean_fill_methodNz(Must specify a fill 'value' or 'method'.z>"value" parameter must be a scalar or dict, but you passed a "ú"z)Cannot specify both 'value' and 'method'.)	Úpandas.core.missingrX   r   rI   Úlistr<   r   rK   rL   )rA   ÚmethodrV   rX   s       r   Úvalidate_fillna_kwargsr]   ,  sÊ   € ð& 6Ð5Ð5Ð5Ð5Ð5à€}˜˜ÝÐCÑDÔDÐDØ€}˜Ð+Ø"Ð" 6Ñ*Ô*ˆˆà	Ð	˜v˜~Ø%ð 	­*°U½TÅ5¸MÑ*JÔ*Jð 	Ýð9Ý!% e¡¤Ô!5ð9ð 9ð 9ñô ð øð
 
Ð	˜vÐ1ÝÐDÑEÔEÐEà�&ˆ=Ðr    Úqúfloat | Iterable[float]ú
np.ndarrayc                óÖ   — t          j        | ¦  «        }d}|j        dk    rd|cxk    rdk    sn t          |¦  «        ‚n(t	          d„ |D ¦   «         ¦  «        st          |¦  «        ‚|S )aå  
    Validate percentiles (used by describe and quantile).

    This function checks if the given float or iterable of floats is a valid percentile
    otherwise raises a ValueError.

    Parameters
    ----------
    q: float or iterable of floats
        A single percentile or an iterable of percentiles.

    Returns
    -------
    ndarray
        An ndarray of the percentiles if valid.

    Raises
    ------
    ValueError if percentiles are not in given interval([0, 1]).
    z0percentiles should all be in the interval [0, 1]r   r   c              3  ó6   K  — | ]}d |cxk    odk    nc V — ŒdS )r   r   N© )Ú.0Úqss     r   ú	<genexpr>z&validate_percentile.<locals>.<genexpr>o  s6   è è € Ð.Ð. "��b��’�˜A’���Ð.Ð.Ð.Ð.Ð.Ð.r    )rS   ÚasarrayÚndimr   Úall)r^   Úq_arrÚmsgs      r   Úvalidate_percentilerl   S  s{   € õ* ŒJ�q‰MŒM€Eð =€CØ„z�Q‚€Ø�EˆˆŠˆ˜QŠˆˆˆÝ˜S‘/”/Ð!ð åÐ.Ð.¨Ð.Ñ.Ô.Ñ.Ô.ð Ý˜‰oŒoÐØ€Lr    Ú	ascendingc                ó   — d S ©Nrc   ©rm   s    r   Úvalidate_ascendingrq   t  s   € Ø9<¸r    úSequence[BoolishT]úlist[BoolishT]c                ó   — d S ro   rc   rp   s    r   rq   rq   x  s   € ØILÈr    úbool | int | Sequence[BoolishT]úbool | int | list[BoolishT]c                óp   ‡— dddœŠt          | t          ¦  «        st          | dfi ‰¤ŽS ˆfd„| D ¦   «         S )z8Validate ``ascending`` kwargs for ``sort_index`` method.FT)rD   rF   rm   c                ó,   •— g | ]}t          |d fi ‰¤Ž‘ŒS rp   )rN   )rd   Úitemr-   s     €r   ú
<listcomp>z&validate_ascending.<locals>.<listcomp>„  s,   ø€ ÐSÐSÐSÀÕ  kÐ<Ð<°VÐ<Ð<ÐSÐSÐSr    )rI   r   rN   )rm   r-   s    @r   rq   rq   |  sW   ø€ ð $°DÐ9Ð9€FÝ�i¥Ñ*Ô*ð EÝ" 9¨kÐDÐD¸VÐDÐDÐDàSÐSÐSÐSÈÐSÑSÔSÐSr    Úclosedú
str | Noneútuple[bool, bool]c                ób   — d}d}| €d}d}n!| dk    rd}n| dk    rd}nt          d¦  «        ‚||fS )a%  
    Check that the `closed` argument is among [None, "left", "right"]

    Parameters
    ----------
    closed : {None, "left", "right"}

    Returns
    -------
    left_closed : bool
    right_closed : bool

    Raises
    ------
    ValueError : if argument is not among valid values
    FNTÚleftÚrightz/Closed has to be either 'left', 'right' or None)r   )r{   Úleft_closedÚright_closeds      r   Úvalidate_endpointsrƒ   ‡  s]   € ð" €KØ€Là€~ØˆØˆˆØ	�6Ò	Ð	ØˆˆØ	�7Ò	Ð	ØˆˆåÐJÑKÔKÐKà˜Ð$Ð$r    Ú	inclusivec                óŠ   — d}t          | t          ¦  «        rdddddœ                     | ¦  «        }|€t          d¦  «        ‚|S )aD  
    Check that the `inclusive` argument is among {"both", "neither", "left", "right"}.

    Parameters
    ----------
    inclusive : {"both", "neither", "left", "right"}

    Returns
    -------
    left_right_inclusive : tuple[bool, bool]

    Raises
    ------
    ValueError : if argument is not among valid values
    N)TT©TF)FT)FF)Úbothr   r€   Úneitherz?Inclusive has to be either 'both', 'neither', 'left' or 'right')rI   rC   Úgetr   )r„   Úleft_right_inclusives     r   Úvalidate_inclusiver‹   ¨  si   € ð  6:Ðå�)�SÑ!Ô!ð à Ø!Ø"Ø%ð	 
ð  
÷
 Š#ˆi‰.Œ.ð 	ð Ð#ÝØMñ
ô 
ð 	
ð  Ðr    ÚlocrJ   Úlengthc                ó¬   — t          | ¦  «        st          d|› d|› �¦  «        ‚| dk     r| |z  } d| cxk    r|k    sn t          d|› d|› �¦  «        ‚| S )z¼
    Check that we have an integer between -length and length, inclusive.

    Standardize negative loc to within [0, length].

    The exceptions we raise on failure match np.insert.
    z loc must be an integer between -z and r   )r   r   Ú
IndexError)rŒ   r�   s     r   Úvalidate_insert_locr�   Ê  s‡   € õ �c‰?Œ?ð RÝÐP¸6ÐPÐPÈÐPÐPÑQÔQÐQà
ˆQ‚w€wØˆv‰ˆØ�ÐÐÒÐ�vÒÐÐÐÝÐQ¸FÐQÐQÈÐQÐQÑRÔRÐRØ€Jr    c                óT   — | t           j        ur| dvrt          d| › d�¦  «        ‚d S d S )N)Únumpy_nullableÚpyarrowzdtype_backend z= is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.)r   rQ   r   )Údtype_backends    r   Úcheck_dtype_backendr•   Ü  sQ   € Ø�CœNÐ*Ð*ØÐ =Ð=Ð=Ýð* ð *ð *ð *ñô ð ð +Ð*Ø=Ð=r    )r   r   r†   )
rA   r   rB   rC   rD   rE   rF   rE   r   r   )rO   rC   )T)rV   rE   )r^   r_   r   r`   )rm   r   r   r   )rm   rr   r   rs   )rm   ru   r   rv   )r{   r|   r   r}   )r„   r|   r   r}   )rŒ   rJ   r�   rJ   r   rJ   )%Ú__doc__Ú
__future__r   Úcollections.abcr   r   Útypingr   r   ÚnumpyrS   Úpandas._libsr   Úpandas._libs.missingr	   Úpandas.core.dtypes.commonr
   r   rE   rJ   r   r   r   r'   r.   r6   r:   r@   rN   rU   r]   rl   rq   rƒ   r‹   r�   r•   rc   r    r   ú<module>rž      sƒ  ððð ð
 #Ð "Ð "Ð "Ð "Ð "ðð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð
 Ð Ð Ð à Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #ðð ð ð ð ð ð ð ð
 ˆ7�:˜t SÑ)Ô)€Øˆw�~ t¨S°$Ñ7Ô7€ð
ð 
ð 
ð 
ð(#ð #ð #ð #ðL&:ð &:ð &:ð &:ðR
Uð 
Uð 
Uð 
Uð8ð 8ð 8ð 8ð670ð 70ð 70ð 70ðz Øð	*ð *ð *ð *ð *ðZYð Yð Yð Yð6$ð $ð $ð $ð $ðNð ð ð ðB 
Ø <Ð <Ð <ñ 
„Ø <ð 
Ø LÐ LÐ Lñ 
„Ø LðTð Tð Tð Tð%ð %ð %ð %ðB ð  ð  ð  ðDð ð ð ð$ð ð ð ð ð r    