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__/common.cpython-312.pyc

�

Mٜg)D���dZddlmZddlZddlmZmZddlmZm	Z	m
Z
mZmZddl
Z
ddlmZddlZddlmZmZmZmZmZddlZddlZddlmZdd	lmZdd
lmZddl m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'dd
l(m)Z)erddl*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1d�Z2d�Z3dAd�Z4d�Z5d�Z6dBd�Z7dBd�Z8dBd�Z9dBd�Z:dCd�Z;e	dD					dEd��Z<edDdFd��Z<dGdFd�Z<	dG					dHd�Z=d�Z>dId�Z?dBd �Z@dBd!�ZAdJd"�ZBdKd#�ZCd$�ZDd%�ZEd&�ZFedLd'��ZGe				dMd(��ZGdGdNd)�ZG				dOd*�ZHd+�ZI				dPd,�ZJe
j�	dQ					dRd-��ZLdSd.�ZMej�ej�ej�ej�j�ej�ej�j�iZTej�d/ej�d0ej�d1iZUiej�d2�ej�d3�ej�d4�ej�d5�ej�d6�ej�d2�ej�d2�ej�d7�ej�d7�ej�d8�ej�d8�ej�d9�ej�d9�ej�d:�ej�d:�ej�d;�ej�d;�ej�d3ej�d3ej�d4ej�d4ej�d<ej�d<ej�d=ej�d=i�ZidTd>�Zjd?�ZkdUd@�Zly)Vzh
Misc tools for implementing data structures

Note: pandas.core.common is *not* part of the public API.
�)�annotationsN)�abc�defaultdict)�
Collection�	Generator�Hashable�Iterable�Sequence)�partial)�
TYPE_CHECKING�Any�Callable�cast�overload)�lib)�np_version_gte1p24)�'construct_1d_object_array_from_listlike)�
is_bool_dtype�
is_integer)�ABCExtensionArray�ABCIndex�
ABCMultiIndex�	ABCSeries)�iterable_not_string)�AnyArrayLike�	ArrayLike�NpDtype�RandomState�T)�Indexc#�dK�|D]%}t|�rt|�Ed{����"|���'y7��w)a
    Flatten an arbitrarily nested sequence.

    Parameters
    ----------
    line : sequence
        The non string sequence to flatten

    Notes
    -----
    This doesn't consider strings sequences.

    Returns
    -------
    flattened : generator
    N)r�flatten)�line�elements  �=/usr/local/lib/python3.12/site-packages/pandas/core/common.pyr"r">s0����"���w�'��w�'�'�'��M�	�'�s�0�.�
0c�~�|dj}|ddD]}	|j|k7rd}�|S#t$rd}Y�&wxYw)Nr�)�name�
ValueError)�objsr(�objs   r%�consensus_name_attrr,VsS����7�<�<�D��A�B�x��	��x�x�4�������K���	��D�	�s�.�<�<c��t|ttjtt
f�r�t|t�s�|jtjk(rPtj|�}tj|�s%d}tj|d��rt|��yyt|j�ryyt|t�r?t|�dkDr1t!|�turt|�}tj"|�Sy)a�
    Check whether `key` is a valid boolean indexer.

    Parameters
    ----------
    key : Any
        Only list-likes may be considered boolean indexers.
        All other types are not considered a boolean indexer.
        For array-like input, boolean ndarrays or ExtensionArrays
        with ``_is_boolean`` set are considered boolean indexers.

    Returns
    -------
    bool
        Whether `key` is a valid boolean indexer.

    Raises
    ------
    ValueError
        When the array is an object-dtype ndarray or ExtensionArray
        and contains missing values.

    See Also
    --------
    check_array_indexer : Check that `key` is a valid array to index,
        and convert to an ndarray.
    z=Cannot mask with non-boolean array containing NA / NaN valuesT)�skipnaFr)�
isinstancer�np�ndarrayrrr�dtype�object_�asarrayr�
is_bool_arrayr)r�list�len�type�is_bool_list)�key�	key_array�na_msgs   r%�is_bool_indexerr=as���8��i����X�/@�
A����m�,��9�9��
�
�"��
�
�3��I��$�$�Y�/�X���$�$�Y�t�<�%�V�,�,���
�3�9�9�
%���
�C��	��s�8�a�<��C�y��$��3�i���#�#�C�(�(��c�f�tj|�r|j�rtd��|S)z�
    Disallow indexing with a float key, even if that key is a round number.

    Parameters
    ----------
    val : scalar

    Returns
    -------
    outval : scalar
    zYIndexing with a float is no longer supported. Manually convert to an integer key instead.)r�is_floatr�
IndexError)�vals r%�cast_scalar_indexerrC�s2���|�|�C��S�^�^�-��
)�
�	
�
�Jr>c��d�|D�S)zL
    Returns a generator consisting of the arguments that are not None.
    c3�&K�|]	}|��|���y�w�N���.0�args  r%�	<genexpr>znot_none.<locals>.<genexpr>�s����3�4�C�3�?�C�4�s��rG��argss r%�not_nonerN�s��4�4�3�3r>c�&�td�|D��S)z?
    Returns a boolean indicating if any argument is None.
    c3�$K�|]}|du���
y�wrFrGrHs  r%rKzany_none.<locals>.<genexpr>������+�d�s�s�d�{�d�����anyrLs r%�any_nonerU�����+�d�+�+�+r>c�&�td�|D��S)zA
    Returns a boolean indicating if all arguments are None.
    c3�$K�|]}|du���
y�wrFrGrHs  r%rKzall_none.<locals>.<genexpr>�rQrR��allrLs r%�all_noner[�rVr>c�&�td�|D��S)zC
    Returns a boolean indicating if any argument is not None.
    c3�$K�|]}|du���
y�wrFrGrHs  r%rKzany_not_none.<locals>.<genexpr>������/�$�3�s�$��$�rRrSrLs r%�any_not_noner_�����/�$�/�/�/r>c�&�td�|D��S)zE
    Returns a boolean indicating if all arguments are not None.
    c3�$K�|]}|du���
y�wrFrGrHs  r%rKzall_not_none.<locals>.<genexpr>�r^rRrYrLs r%�all_not_nonerc�r`r>c�&�td�|D��S)z;
    Returns the count of arguments that are not None.
    c3�$K�|]}|du���
y�wrFrG)rI�xs  r%rKz!count_not_none.<locals>.<genexpr>�s����+�d��q��}�d�rR)�sumrLs r%�count_not_nonerh�rVr>c��yrFrG��valuesr2s  r%�asarray_tuplesaferl�s��r>c��yrFrGrjs  r%rlrl����r>c�.�t|ttf�st|d�st|�}n8t|t�r|j
St|t�r|j
St|t�r#|tjtfvrt|�S	tj�5ts$tjdtj�tj ||��}ddd�t%j&j(t*�rtj |t��}|j,dk(r#|D�cgc]
}t|���}}t|�}|S#1swY�|xYw#t"$rt|�cYSwxYwcc}w)N�	__array__�ignore�r2�)r/r6�tuple�hasattrr�_valuesrr0r3�objectr�warnings�catch_warningsr�simplefilter�VisibleDeprecationWarningr4r)�
issubclassr2r8�str�ndim)rkr2�resultrfs    r%rlrl�s1���v��e�}�-����1M��f���	�F�H�	%��~�~��	�F�I�	&��~�~���&�$��E�b�j�j�&�-A�$A�6�v�>�>�?�
�
$�
$�
&�%��%�%�h��0L�0L�M��Z�Z��e�4�F�	'��&�,�,�#�#�S�)����F�&�1��
�{�{�a��$*�+�F�q�%��(�F��+�8��@���M�)'�
&��
�?�
7�v�>�>�?��,s1�E8�/AE,�1E8�F�,E5�1E8�8F�Fc���t|ttf�r|g}t|ttj
f�s	t|�}t||��}|S#t$r|g}Y�wxYw)z�
    Transform label or iterable of labels to array, for use in Index.

    Parameters
    ----------
    dtype : dtype
        If specified, use as dtype of the resulting array, otherwise infer.

    Returns
    -------
    array
    rr)r/r}rtr6r0r1�	TypeErrorrl)�labelsr2s  r%�index_labels_to_arrayr�
se���&�3��,�'�����f�t�R�Z�Z�0�1�	��&�\�F��v�U�
3�F��M���	��X�F�	�s�A�A$�#A$c�<�|�t|ttf�s|gS|SrF)r/rtr6�r+s r%�maybe_make_listr�'s ��
��z�#��t�}�=��u���Jr>c��t|tj�r%t|tj�st	|�Stt|�}|S)zB
    If obj is Iterable but not list-like, consume into list.
    )r/rr	�Sizedr6rrr�s r%�maybe_iterable_to_listr�-s:���#�s�|�|�$�Z��S�Y�Y�-G��C�y��
�z�3�
�C��Jr>c��t|t�xr.|jduxr|jduxr|jduS)z
    We have a null slice.
    N�r/�slice�start�stop�stepr�s r%�
is_null_slicer�7sH��
	�3���	��I�I���	��H�H���	�
�H�H���	r>c��t|t�xr9|jduxr)|jduxr|j|jk(S)z>
    We have an empty slice, e.g. no values are selected.
    N)r/r�r�r�r�s r%�is_empty_slicer�CsL��
	�3���	"��I�I�T�!�	"��H�H�D� �	"�
�I�I����!�	r>c�d�|D�cgc] }t|t�xrt|���"c}Scc}w)zX
    Find non-trivial slices in "line": return a list of booleans with same length.
    )r/r�r�)r#�ks  r%�is_true_slicesr�Os5��DH�H�4�a�J�q�%� �9��q�)9�%9�9�4�H�H��Hs�%-c��t|t�xr0|jdk(xr|j|k(xr|jduS)z&
    We have a full length slice.
    rNr�)r+r#s  r%�
is_full_slicer�WsG��
	�3���	��I�I��N�	��H�H���	�
�H�H���	r>c��t|d�rt|d�St|t�rt	|j
�St
|�rt|�jSy)N�__name__)	ru�getattrr/r�get_callable_name�func�callabler8r�r�s r%r�r�csN���s�J���s�J�'�'��#�w�� ����*�*���}��C�y�!�!�!�
r>c�.�t|�r	||fi|��S|S)z�
    Evaluate possibly callable input using obj and kwargs if it is callable,
    otherwise return as it is.

    Parameters
    ----------
    maybe_callable : possibly a callable
    obj : NDFrame
    **kwargs
    )r�)�maybe_callabler+�kwargss   r%�apply_if_callabler�ts"������c�,�V�,�,��r>c��tj|�s5t|t�rt	t|j
�St
|�}t|tj�std|����|tk(rtd��|S)a
    Helper function to standardize a supplied mapping.

    Parameters
    ----------
    into : instance or subclass of collections.abc.Mapping
        Must be a class, an initialized collections.defaultdict,
        or an instance of a collections.abc.Mapping subclass.

    Returns
    -------
    mapping : a collections.abc.Mapping subclass or other constructor
        a callable object that can accept an iterator to create
        the desired Mapping.

    See Also
    --------
    DataFrame.to_dict
    Series.to_dict
    zunsupported type: z/to_dict() only accepts initialized defaultdicts)�inspect�isclassr/rr�default_factoryr8r|r�Mappingr�)�intos r%�standardize_mappingr��sp��*�?�?�4� ��d�K�(��;��(<�(<�=�=��D�z���d�C�K�K�(��,�T�F�3�4�4��{���I�J�J��Kr>c��yrFrG��states r%�random_stater��rnr>c��yrFrGr�s r%r�r��s��r>c��t|�s4t|tjtjj
f�rtjj
|�St|tjj�r|St|tjj�r|S|�tjStd��)aq
    Helper function for processing random_state arguments.

    Parameters
    ----------
    state : int, array-like, BitGenerator, Generator, np.random.RandomState, None.
        If receives an int, array-like, or BitGenerator, passes to
        np.random.RandomState() as seed.
        If receives an np.random RandomState or Generator, just returns that unchanged.
        If receives `None`, returns np.random.
        If receives anything else, raises an informative ValueError.

        Default None.

    Returns
    -------
    np.random.RandomState or np.random.Generator. If state is None, returns np.random

    zdrandom_state must be an integer, array-like, a BitGenerator, Generator, a numpy RandomState, or None)	rr/r0r1�random�BitGeneratorrrr)r�s r%r�r��s���(�%��J�u�r�z�z�2�9�9�;Q�;Q�.R�S��y�y�$�$�U�+�+�	�E�2�9�9�0�0�	1���	�E�2�9�9�.�.�	/���	���y�y���
+�
�	
r>c��t|t�r&|\}}||vr|�d�}t|��|||<||i|��S||g|��i|��S)as
    Apply a function ``func`` to object ``obj`` either by passing obj as the
    first argument to the function or, in the case that the func is a tuple,
    interpret the first element of the tuple as a function and pass the obj to
    that function as a keyword argument whose key is the value of the second
    element of the tuple.

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

    Returns
    -------
    object : the return type of ``func``.
    z/ is both the pipe target and a keyword argument)r/rtr))r+r�rMr��target�msgs      r%�piper��sd��4�$������f��V���H�K�L�C��S�/�!���v���T�$�V�$�$��C�)�$�)�&�)�)r>c�V���fd�}t�tjtf�r|S�S)zv
    Returns a function that will map names/labels, dependent if mapper
    is a dict, Series or just a function.
    c���|�vr�|S|SrFrG)rf�mappers �r%�fzget_rename_function.<locals>.f�s�����;��!�9���Hr>)r/rr�r)r�r�s` r%�get_rename_functionr��s'�����6�C�K�K��#;�<�1�H�&�Hr>c���t|ttjtt
tf�r|St|tj�rt|t�st|�S|gS)z�
    Convert list-like or scalar input to list-like. List, numpy and pandas array-like
    inputs are returned unmodified whereas others are converted to list.
    )
r/r6r0r1rrrrr	r})rks r%�convert_to_list_liker�sK���&�4����X�y�BS�T�U��
�	�F�C�L�L�	)�*�V�S�2I��F�|���8�Or>c#�K�|rt||�}t|||�	|��|rt||�yy#|rt||�wwxYw�w)a�
    Temporarily set attribute on an object.

    Parameters
    ----------
    obj : object
        Object whose attribute will be modified.
    attr : str
        Attribute to modify.
    value : Any
        Value to temporarily set attribute to.
    condition : bool, default True
        Whether to set the attribute. Provided in order to not have to
        conditionally use this context manager.

    Yields
    ------
    object : obj with modified attribute.
    N)r��setattr)r+�attr�value�	condition�	old_values     r%�temp_setattrr�sU����.��C��&�	���T�5�!�*��	���C��y�)���9��C��y�)��s�A	�4�A	�A�A	c�z�t|�t|�k7r$tdt|��dt|��d���y)zC
    Check the length of data matches the length of the index.
    zLength of values (z") does not match length of index (�)N)r7r))�data�indexs  r%�require_length_matchr�8sI���4�y�C��J���
��D�	�{���E�
�|�1�
�
�	
�r>znp.sumznp.maximum.reduceznp.minimum.reducerg�max�minrZrT�mean�prod�std�var�median�cumprod�cumsumc�,�tj|�S)zH
    if we define an internal function for this argument, return it
    )�
_cython_table�get�rJs r%�get_cython_funcr�rs�����S�!�!r>c�.�tj||�S)zd
    if we define a builtin function for this argument, return it,
    otherwise return the arg
    )�_builtin_tabler�r�s r%�is_builtin_funcr�ys��
���c�3�'�'r>c�X�t|�D��cgc]\}}|�d|��n|��c}}Scc}}w)a,
    If a name is missing then replace it by level_n, where n is the count

    .. versionadded:: 1.4.0

    Parameters
    ----------
    names : list-like
        list of column names or None values.

    Returns
    -------
    list
        list of column names with the None values replaced.
    �level_)�	enumerate)�names�ir(s   r%�fill_missing_namesr��s8�� CL�E�BR�S�BR�w�q�$�D�L�f�Q�C�L�d�2�BR�S�S��Ss�&)r:r
�return�bool)r�r�)r��int).)rkzArrayLike | list | tuple | zipr2�NpDtype | Noner��
np.ndarray)rkr	r2r�r�rrF)r�znp.ndarray | Iterabler2r�r�r�)r+zIterable[T] | Tr�zCollection[T] | T)r�z
list[bool])r#r�r�r�)r��np.random.Generatorr�r�)r�zHint | np.ndarray | np.random.BitGenerator | np.random.RandomState | Noner�znp.random.RandomState)r�zRandomState | None)r�z/Callable[..., T] | tuple[Callable[..., T], str]r�r)rkz"Hashable | Iterable | AnyArrayLiker�zlist | AnyArrayLike)T)r�r}r�r�r�zGenerator[None, None, None])r�r r��None)rJrr�z
str | None)r�zSequence[Hashable | None]r�zlist[Hashable])m�__doc__�
__future__r�builtins�collectionsrr�collections.abcrrrr	r
�
contextlib�	functoolsrr��typingrr
rrrrx�numpyr0�pandas._libsr�pandas.compat.numpyr�pandas.core.dtypes.castr�pandas.core.dtypes.commonrr�pandas.core.dtypes.genericrrrr�pandas.core.dtypes.inferencer�pandas._typingrrrrr�pandasr r"r,r=rCrNrUr[r_rcrhrlr�r�r�r�r�r�r�r�r�r�r�r�r�r��contextmanagerr�r�rgr��maximum�reducer��minimumr��_builtin_table_aliasrZrT�nansumr��nanmeanr��nanprodr��nanstdr��nanvarr��	nanmedian�nanmax�nanminr��
nancumprodr��	nancumsumr�r�r�r�rGr>r%�<module>rs����
#�������������2�K����=������0�4�n�,4�,�,�0�0�,�
�DG��*��3A����
��
��
�� �H<@��!��*8����:��	�	�I�	��"�"�@
��
��
��S����
�� 
�F"*�>�"*��"*�JI��.�������-1�*��*�&*�*� �*��*�@

�"
�L�L�"�&�&��L�L�"�*�*�#�#��L�L�"�*�*�#�#���
�L�L�(��L�L�%��L�L�%�����L�L�%���L�L�%��
�L�L�%���F�F�E�	�
�F�F�E���F�F�E�
��I�I�u���G�G�V���J�J����G�G�V���J�J����F�F�E���I�I�u���F�F�E���I�I�u�� �I�I�x�!�"�L�L�(�#�$�F�F�E��I�I�u��F�F�E��I�I�u��J�J�	��M�M�9��I�I�x��L�L�(�3�
�:"�(�Tr>

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