Sindbad~EG File Manager

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

�

Mٜg�(���ddlmZddlZddlmZmZddlZddlm	Z	m
Z
ddlmZddl
mZddlmZddlmZmZmZmZmZdd	lmZdd
lmZddlmZddlmZdd
lm Z ddl!m"Z"ddl#m$Z$erddl%m&Z&ejNd�Z(gd�Z)				d									dd�Z*dd�Z+			d									dd�Z,d d�Z-d!d"d�Z.d�Z/d#d�Z0d$d�Z1y)%�)�annotationsN)�
TYPE_CHECKING�cast)�NaT�lib)�InvalidIndexError)�find_common_type)�	safe_sort)�Index�
_new_Index�ensure_index�ensure_index_from_sequences�get_unanimous_names)�CategoricalIndex)�
DatetimeIndex)�
IntervalIndex)�
MultiIndex)�PeriodIndex)�
RangeIndex)�TimedeltaIndex)�Axisz�Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.
)rrrrrrrrrrrr
r�get_objs_combined_axis�
union_indexesr�all_indexes_same�
default_index�safe_sort_indexc�f�|D�cgc]}|j|���}}t||||��Scc}w)a�
    Extract combined index: return intersection or union (depending on the
    value of "intersect") of indexes on given axis, or None if all objects
    lack indexes (e.g. they are numpy arrays).

    Parameters
    ----------
    objs : list
        Series or DataFrame objects, may be mix of the two.
    intersect : bool, default False
        If True, calculate the intersection between indexes. Otherwise,
        calculate the union.
    axis : {0 or 'index', 1 or 'outer'}, default 0
        The axis to extract indexes from.
    sort : bool, default True
        Whether the result index should come out sorted or not.
    copy : bool, default False
        If True, return a copy of the combined index.

    Returns
    -------
    Index
    )�	intersect�sort�copy)�	_get_axis�_get_combined_index)�objsr�axisrr �obj�	obs_idxess       �B/usr/local/lib/python3.12/site-packages/pandas/core/indexes/api.pyrrHs7��<15�5������t�$��I�5��y�I�D�t�T�T��6s�.c��t�}g}|D];}t|�|vs�|jt|��|j|��=|S)z^
    Return a list with distinct elements of "objs" (different ids).
    Preserves order.
    )�set�id�add�append)r#�ids�resr%s    r'�_get_distinct_objsr/jsH��
�E�C�
�C���
�c�7�#���G�G�B�s�G���J�J�s�O���J�c�,�t|�}t|�dk(rtg�}nOt|�dk(r|d}n;|r!|d}|ddD]}|j|�}�nt	|d��}t|�}|rt
|�}|r|j�}|S)a
    Return the union or intersection of indexes.

    Parameters
    ----------
    indexes : list of Index or list objects
        When intersect=True, do not accept list of lists.
    intersect : bool, default False
        If True, calculate the intersection between indexes. Otherwise,
        calculate the union.
    sort : bool, default False
        Whether the result index should come out sorted or not.
    copy : bool, default False
        If True, return a copy of the combined index.

    Returns
    -------
    Index
    r�NF�r)r/�lenr�intersectionrr
rr )�indexesrrr �index�others      r'r"r"xs���4!��)�G�
�7�|�q���b�	��	�W���	���
��	���
���Q�R�[�E��&�&�u�-�E�!��g�E�2���U�#�����&����
�
����Lr0c�\�|jr|S	t|�}t|t�r|St	t
j|�}t|t�r#tj||j��}|St||j|j��}|S#t$rY|SwxYw)z�
    Returns the sorted index

    We keep the dtypes and the name attributes.

    Parameters
    ----------
    index : an Index

    Returns
    -------
    Index
    )�names)�name�dtype)
�is_monotonic_increasingr
�
isinstancerr�np�ndarrayr�from_tuplesr:r;r<�	TypeError)r7�array_sorteds  r'rr�s���
�$�$���L� ��'���l�E�*����B�J�J��5���e�Z�(��*�*�<�u�{�{�K�E��L��,�U�Z�Z�u�{�{�K�E��L���
���L�
�s�B�	B+�*B+c������t��dk(rtd��t��dk(r:�d}t|t�r#�s
t	|�}|St	t|��}|St
��\�}d�fd�}�fd�}|dk(r�d}�D�cgc]}t|t�s�|��}}|D�cgc]}|j��|��}}t|�dt|�fvrtd��t|�t��k(rd	��d}n:t|�dkDr,d
��D�cgc]}|jtd
����c}��d}�ddD]}	|j|	�rdnd
��}�|S|d
k(rZ|��}
�d�t�fd��ddD��s	|�|
��t��d}|�jk7r�j!|���S|��}
|�|
�Scc}wcc}wcc}w)a)
    Return the union of indexes.

    The behavior of sort and names is not consistent.

    Parameters
    ----------
    indexes : list of Index or list objects
    sort : bool, default True
        Whether the result index should come out sorted or not.

    Returns
    -------
    Index
    rz#Must have at least 1 Index to unionr2c
����td�|D��r�|D�cgc]}|j|d����}}|dj�}|dj|dd�}||j	|�dk(}t|�r|j|j��}�r|j
�}|Sd	�}ttj|D�cgc]
}||���c}��
�|��Scc}wcc}w)z�
        Concatenate indices and remove duplicates.

        Parameters
        ----------
        inds : list of Index or list objects
        dtype : dtype to set for the resulting Index

        Returns
        -------
        Index
        c3�<K�|]}t|t����y�w�N)r>r)�.0�inds  r'�	<genexpr>z9union_indexes.<locals>._unique_indices.<locals>.<genexpr>�s����6��#�z�#�u�%��s�F�r rr2�N���c�F�t|t�r|j�}|SrG)r>r�tolist)�is r'�convz4union_indexes.<locals>._unique_indices.<locals>.conv�s���!�U�#��H�H�J���Hr0r3)r<)
�all�astype�uniquer,�get_indexer_forr4�sort_valuesrr�fast_unique_multiple_list)	�indsr<rI�resultr8�diffrQrPrs	        �r'�_unique_indicesz&union_indexes.<locals>._unique_indices�s�����6��6�6�=A�B�T�c�C�J�J�u�5�J�1�T�D�B��!�W�^�^�%�F���G�N�N�4���8�,�E���/�/��6�"�<�=�D��4�y����t�{�{�}�5����+�+�-���M�	�
��)�)�D�*A�D�q�4��7�D�*A��M��
�	
��C�� +Bs�C,�C1c����D�cgc]}t|t�s�|j��!}}|r
t|�}|Sd}|Scc}w)a
        Finds a common type for the indexes to pass through to resulting index.

        Parameters
        ----------
        inds: list of Index or list objects

        Returns
        -------
        The common type or None if no indexes were given
        N)r>rr<r	)rX�idx�dtypesr<r6s    �r'�_find_common_index_dtypez/union_indexes.<locals>._find_common_index_dtype	sL���(/�I�w��*�S�%�2H�#�)�)�w��I��$�V�,�E����E����
Js�?�?�specialNz0Cannot join tz-naive with tz-aware DatetimeIndexTFrKr3�arrayc3�@�K�|]}�j|����y�wrG��equals)rHr8r7s  �r'rJz union_indexes.<locals>.<genexpr>>s�����@�K�5�5�<�<��&�K���)�returnr)r4�AssertionErrorr>�listr�sorted�_sanitize_and_checkr�tzrBrS�object�unionrRrr;�rename)
r6rrY�kindr[r_�x�dtis�dti_tzsr8r<r;r7s
``          @r'rr�s��� �7�|�q���B�C�C�
�7�|�q�������f�d�#���v����
��v�f�~�.���
�'��0�M�G�T� 
�D�(�y������"�C�7�a�j��M�&B��7��C�"�7�d��a�d�d�&6�1�d��7��w�<��3�t�9�~�-�
�N�O�O��t�9��G��$��D��Q�Z�F�
��Y��]��D�>E�E�W��q�x�x��U�x�3�W�E�G��Q�Z�F��Q�R�[�E��\�\�%�d�d��\�F�F�!��
�	
���(��1����
���@�G�A�B�K�@�@�#�G�U�3�E�"�G�,�Q�/���5�:�:���L�L��&�E���(��1���w��.�.��OD��7��&Fs�G�"G�,G�>G�Gc�\�t|D�chc]
}t|���c}�}t|vr[t|�dkDrI|D�cgc](}t|t�st	t|��n|��*}}|jt�n|dfSt|�dkDst|vr|dfS|dfScc}wcc}w)aN
    Verify the type of indexes and convert lists to Index.

    Cases:

    - [list, list, ...]: Return ([list, list, ...], 'list')
    - [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...])
        Lists are sorted and converted to Index.
    - [Index, Index, ...]: Return ([Index, Index, ...], TYPE)
        TYPE = 'special' if at least one special type, 'array' otherwise.

    Parameters
    ----------
    indexes : list of Index or list objects

    Returns
    -------
    sanitized_indexes : list of Index or list objects
    type : {'list', 'array', 'special'}
    r2rhr`ra)rh�typer4r>r�remove)r6r7�kindsrps    r'rjrjJs���*
�7�3�7�%�$�u�+�7�3�4�E��u�}��u�:��>�KR��KR�a�j��E�&:��d�1�g���A�7�
��
�L�L����F�?�"�
�5�z�A�~��e�+��	�!�!������4��s
�B$�-B)c�X��t|�}t|��t�fd�|D��S)z�
    Determine if all indexes contain the same elements.

    Parameters
    ----------
    indexes : iterable of Index objects

    Returns
    -------
    bool
        True if all indexes contain the same elements, False otherwise.
    c3�@�K�|]}�j|����y�wrGrc)rHr7�firsts  �r'rJz#all_indexes_same.<locals>.<genexpr>s�����4��u�u�|�|�E�"��re)�iter�nextrR)r6�itrrys  @r'rrps(����w�-�C���I�E��4��4�4�4r0c�F�t|�}tj|d��S)N)r;)�ranger�_simple_new)�n�rngs  r'rr�s��
��(�C��!�!�#�D�1�1r0)FrTF)
r�boolr$rrr�r r�rfr)r#�list[Index]rfr�)FFF)
r6r�rr�rr�r r�rfr)r7rrfr)T)rzbool | Nonerfr)rfr�)r��intrfr)2�
__future__r�textwrap�typingrr�numpyr?�pandas._libsrr�
pandas.errorsr�pandas.core.dtypes.castr	�pandas.core.algorithmsr
�pandas.core.indexes.baserrr
rr�pandas.core.indexes.categoryr�pandas.core.indexes.datetimesr�pandas.core.indexes.intervalr�pandas.core.indexes.multir�pandas.core.indexes.periodr�pandas.core.indexes.ranger�pandas.core.indexes.timedeltasr�pandas._typingr�dedent�	_sort_msg�__all__rr/r"rrrjrr�r0r'�<module>r�s��"���
��,�4�,���:�7�6�0�2�0�9��#��H�O�O��	
�	���2����U��U��U��	U�
�U��
U�D� ���	-�
�-��-��-��	-�
�-�`�D}/�@# �L5�$2r0

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