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

�

Mٜg����R�dZddlmZddlZddlZddlmZddlmZm	Z	m
Z
ddlZddlZ
ddlmZmZmZmZddlmZmZmZmZmZmZddlmZdd	lmZdd
lm Z m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3dd
l4m5Z5m6Z6m7Z7m8Z8ddl9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?ddl@mAZAmBZBddlCmDZDddlEmFZGmHZHmIZIddlJmKZKerddlmLZLmMZMmNZNddlOmPZPmQZQmRZRddlSmTZTmUZUd6d�ZV								d7d�ZWd8d�ZXej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�d�Zgd9d�Zhd:d�Zid�Zjd;d�Zkd<d=d�ZlejZmdZnd>d �Zo				d?											d@d!�Zpeed"�ed#�ed$��%�			dA							dBd&��Zq					dC									dDd'�Zr					dC									dDd(�Zs	d<							dEd)�Zt		dF							dGd*�Zu	dH							dId+�Zv					dJ													dKd,�Zw			dL					dMd-�Zx		dN									dOd.�Zyhd/�ZzdPdQd0�Z{				dR											dSd1�Z|dTd2�Z}dUd3�Z~						dVd4�Z		dW							dXd5�Z�y)Yzl
Generic data algorithms. This module is experimental at the moment and not
intended for public consumption
�)�annotationsN)�dedent)�
TYPE_CHECKING�Literal�cast)�algos�	hashtable�iNaT�lib)�AnyArrayLike�	ArrayLike�AxisInt�DtypeObj�TakeIndexer�npt)�doc)�find_stack_level)�'construct_1d_object_array_from_listlike�np_find_common_type)�ensure_float64�
ensure_object�ensure_platform_int�
is_array_like�
is_bool_dtype�is_complex_dtype�is_dict_like�is_extension_array_dtype�is_float_dtype�
is_integer�is_integer_dtype�is_list_like�is_object_dtype�is_signed_integer_dtype�needs_i8_conversion)�
concat_compat)�BaseMaskedDtype�CategoricalDtype�ExtensionDtype�NumpyEADtype)�ABCDatetimeArray�ABCExtensionArray�ABCIndex�
ABCMultiIndex�	ABCSeries�ABCTimedeltaArray)�isna�na_value_for_dtype)�take_nd)�array�ensure_wrapped_if_datetimelike�
extract_array)�validate_indices)�ListLike�NumpySorter�NumpyValueArrayLike)�Categorical�Index�Series)�BaseMaskedArray�ExtensionArrayc���t|t�s
t|d��}t|j�rtt
j|��St|jt�rBtd|�}|jst|j�St
j|�St|jt�rtd|�}|jSt|j�rdt|tj �r$t
j|�j#d�St
j|�j%dd��St'|j�rt
j|�St)|j�r8|jj*dvrt-|�St
j|�St/|j�rttj |�St1|j�r-|j#d	�}ttj |�}|St
j|t2�
�}t|�S)a�
    routine to ensure that our data is of the correct
    input dtype for lower-level routines

    This will coerce:
    - ints -> int64
    - uint -> uint64
    - bool -> uint8
    - datetimelike -> i8
    - datetime64tz -> i8 (in local tz)
    - categorical -> codes

    Parameters
    ----------
    values : np.ndarray or ExtensionArray

    Returns
    -------
    np.ndarray
    T��
extract_numpyr=r:�uint8F��copy)����i8��dtype)�
isinstancer-r5r"rJr�np�asarrayr&r�_hasna�_ensure_data�_datar'�codesr�ndarray�view�astyper r�itemsizerrr$�object)�values�npvaluess  �A/usr/local/lib/python3.12/site-packages/pandas/core/algorithms.pyrOrOjs���,�f�m�,��v�T�:���v�|�|�$��R�Z�Z��/�0�0�	�F�L�L�/�	2��'��0���}�}� ����-�-��z�z�&�!�!�	�F�L�L�"2�	3��m�V�,���|�|��	�v�|�|�	$��f�b�j�j�)��:�:�f�%�*�*�7�3�3��:�:�f�%�,�,�W�5�,�A�A�	�&�,�,�	'��z�z�&�!�!�	����	%��<�<� � �K�/�!�&�)�)��z�z�&�!�!�	�&�,�,�	'��B�J�J��'�'�
�V�\�\�	*��;�;�t�$����
�
�H�-�����Z�Z��f�
-�F��� � �c���t|t�r|j|k(r|St|tj�s%|j	�}|j||��}|S|j
|d��}|S)z�
    reverse of _ensure_data

    Parameters
    ----------
    values : np.ndarray or ExtensionArray
    dtype : np.dtype or ExtensionDtype
    original : AnyArrayLike

    Returns
    -------
    ExtensionArray or np.ndarray
    rIFrC)rKr+rJrL�construct_array_type�_from_sequencerT)rWrJ�original�clss    rY�_reconstruct_datar`�sr�� �&�+�,�����1F��
��e�R�X�X�&��(�(�*���#�#�F�%�#�8��
�M����u�5��1���MrZc�b�t|ttttj
f�s�|dk7r't
j|�d�tt���tj|d��}|dvr(t|t�rt|�}t|�}|St	j|�}|S)z5
    ensure that we are arraylike if not already
    �isin-targetsz with argument that is not not a Series, Index, ExtensionArray, or np.ndarray is deprecated and will raise in a future version.��
stacklevelF��skipna)�mixed�string�
mixed-integer)rKr,r.r+rLrR�warnings�warn�
FutureWarningrr�infer_dtype�tuple�listrrM)rW�	func_name�inferreds   rY�_ensure_arraylikerr�s����f�x��4E�r�z�z�R�S���&��M�M��+�"�"��+�-�
��?�?�6�%�8���;�;��&�%�(��f���<�V�D�F��M��Z�Z��'�F��MrZ)�
complex128�	complex64�float64�float32�uint64�uint32�uint16rB�int64�int32�int16�int8rhrVc�H�t|�}t|�}t|}||fS)z�
    Parameters
    ----------
    values : np.ndarray

    Returns
    -------
    htable : HashTable subclass
    values : ndarray
    )rO�_check_object_for_strings�_hashtables)rW�ndtyper	s   rY�_get_hashtable_algor�s-���&�
!�F�
&�v�
.�F��F�#�I��f��rZc�n�|jj}|dk(rtj|d��rd}|S)z�
    Check if we can use string hashtable instead of object hashtable.

    Parameters
    ----------
    values : ndarray

    Returns
    -------
    str
    rVFrerh)rJ�namer�is_string_array)rWr�s  rYrrs7���\�\�
�
�F�
������v�e�4��F��MrZc��t|�S)a3

    Return unique values based on a hash table.

    Uniques are returned in order of appearance. This does NOT sort.

    Significantly faster than numpy.unique for long enough sequences.
    Includes NA values.

    Parameters
    ----------
    values : 1d array-like

    Returns
    -------
    numpy.ndarray or ExtensionArray

        The return can be:

        * Index : when the input is an Index
        * Categorical : when the input is a Categorical dtype
        * ndarray : when the input is a Series/ndarray

        Return numpy.ndarray or ExtensionArray.

    See Also
    --------
    Index.unique : Return unique values from an Index.
    Series.unique : Return unique values of Series object.

    Examples
    --------
    >>> pd.unique(pd.Series([2, 1, 3, 3]))
    array([2, 1, 3])

    >>> pd.unique(pd.Series([2] + [1] * 5))
    array([2, 1])

    >>> pd.unique(pd.Series([pd.Timestamp("20160101"), pd.Timestamp("20160101")]))
    array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]')

    >>> pd.unique(
    ...     pd.Series(
    ...         [
    ...             pd.Timestamp("20160101", tz="US/Eastern"),
    ...             pd.Timestamp("20160101", tz="US/Eastern"),
    ...         ]
    ...     )
    ... )
    <DatetimeArray>
    ['2016-01-01 00:00:00-05:00']
    Length: 1, dtype: datetime64[ns, US/Eastern]

    >>> pd.unique(
    ...     pd.Index(
    ...         [
    ...             pd.Timestamp("20160101", tz="US/Eastern"),
    ...             pd.Timestamp("20160101", tz="US/Eastern"),
    ...         ]
    ...     )
    ... )
    DatetimeIndex(['2016-01-01 00:00:00-05:00'],
            dtype='datetime64[ns, US/Eastern]',
            freq=None)

    >>> pd.unique(np.array(list("baabc"), dtype="O"))
    array(['b', 'a', 'c'], dtype=object)

    An unordered Categorical will return categories in the
    order of appearance.

    >>> pd.unique(pd.Series(pd.Categorical(list("baabc"))))
    ['b', 'a', 'c']
    Categories (3, object): ['a', 'b', 'c']

    >>> pd.unique(pd.Series(pd.Categorical(list("baabc"), categories=list("abc"))))
    ['b', 'a', 'c']
    Categories (3, object): ['a', 'b', 'c']

    An ordered Categorical preserves the category ordering.

    >>> pd.unique(
    ...     pd.Series(
    ...         pd.Categorical(list("baabc"), categories=list("abc"), ordered=True)
    ...     )
    ... )
    ['b', 'a', 'c']
    Categories (3, object): ['a' < 'b' < 'c']

    An array of tuples

    >>> pd.unique(pd.Series([("a", "b"), ("b", "a"), ("a", "c"), ("b", "a")]).values)
    array([('a', 'b'), ('b', 'a'), ('a', 'c')], dtype=object)
    )�unique_with_mask)rWs rY�uniquer�3s��|�F�#�#rZc��t|�dk(ryt|�}tj|j	�jd��dk7j
�}|S)aH
    Return the number of unique values for integer array-likes.

    Significantly faster than pandas.unique for long enough sequences.
    No checks are done to ensure input is integral.

    Parameters
    ----------
    values : 1d array-like

    Returns
    -------
    int : The number of unique values in ``values``
    r�intp)�lenrOrL�bincount�ravelrT�sum)rW�results  rY�nunique_intsr��sO���6�{�a���
�&�
!�F��k�k�&�,�,�.�/�/��7�8�A�=�
B�
B�
D�F��MrZc��t|d��}t|jt�r|j	�S|}t|�\}}|t
|��}|�*|j	|�}t||j|�}|S|j	||��\}}t||j|�}|�J�||jd�fS)z?See algorithms.unique for docs. Takes a mask for masked arrays.r��rp��mask�bool)	rrrKrJr(r�r�r�r`rT)rWr�r^r	�table�uniquess      rYr�r��s���
�v��
:�F��&�,�,��/��}�}����H�+�F�3��I�v��c�&�k�"�E��|��,�,�v�&��#�G�X�^�^�X�F�������V�$��7�
���#�G�X�^�^�X�F����������F�+�+�+rZi@Bc��t|�s"tdt|�j�d���t|�s"tdt|�j�d���t	|t
tttjf�sUt|�}t|d��}t|�dkDrc|jjdvrKt|�s@t!|�}n4t	|t"�rtj$|�}nt'|dd��}t|d	��}t'|d�
�}t	|tj�s|j)|�St+|j�rt-|�j)|�St+|j�r:t/|j�s%tj0|j2t4��St+|j�rt)||j7t8��St	|jt:�r2t)tj<|�tj<|��St|�t>kDrBt|�dkr4|jt8k7r!tA|�jC�rd
�}nZd�}nVtE|j|j�}|j7|d��}|j7|d��}tFjH}|||�S)z�
    Compute the isin boolean array.

    Parameters
    ----------
    comps : list-like
    values : list-like

    Returns
    -------
    ndarray[bool]
        Same length as `comps`.
    zIonly list-like objects are allowed to be passed to isin(), you passed a `�`rbr�r�iufcbT)rA�
extract_range�isinr@rI�c��tjtj||�j�tj|��S�N)rL�
logical_orr�r��isnan)�c�vs  rY�fzisin.<locals>.fs.���}�}�R�W�W�Q��]�%8�%8�%:�B�H�H�Q�K�H�HrZc�J�tj||�j�Sr�)rLr�r�)�a�bs  rY�<lambda>zisin.<locals>.<lambda>s��R�W�W�Q��]�0�0�2rZFrC)%r!�	TypeError�type�__name__rKr,r.r+rLrRrorrr�rJ�kindr#rr-r3r5r�r$�pd_arrayr"�zeros�shaper�rTrVr(rM�_MINIMUM_COMP_ARR_LENr0�anyr�htable�ismember)�compsrW�orig_values�comps_arrayr��commons      rYr�r��sj������
(�(,�U��(<�(<�'=�Q�
@�
�	
�����
(�(,�V��(=�(=�'>�a�
A�
�	
�
�f�x��4E�r�z�z�R�S��6�l��"�;�.�I��
��K�!�O����!�!�W�,�+�E�2�=�[�I�F�	�F�M�	*����&�!���v�T��N��#�E�V�<�K���4�@�K��k�2�:�:�.�����'�'�	�[�.�.�	/���$�)�)�&�1�1�	�V�\�\�	*�?�;�CT�CT�3U��x�x��)�)��6�6�	�V�\�\�	*��K����v�!6�7�7�	�F�L�L�.�	1��B�J�J�{�+�R�Z�Z��-?�@�@�	�K��0�0���K�2������'���<����
I�3�A�%�V�\�\�;�3D�3D�E�����v�E��2��!�(�(��e�(�<���O�O���[�&�!�!rZc��|}|jjdvrt}t|�\}}||xst	|��}|j|d|||��\}}	t
||j|�}t|	�}	|	|fS)a(
    Factorize a numpy array to codes and uniques.

    This doesn't do any coercion of types or unboxing before factorization.

    Parameters
    ----------
    values : ndarray
    use_na_sentinel : bool, default True
        If True, the sentinel -1 will be used for NaN values. If False,
        NaN values will be encoded as non-negative integers and will not drop the
        NaN from the uniques of the values.
    size_hint : int, optional
        Passed through to the hashtable's 'get_labels' method
    na_value : object, optional
        A value in `values` to consider missing. Note: only use this
        parameter when you know that you don't have any values pandas would
        consider missing in the array (NaN for float data, iNaT for
        datetimes, etc.).
    mask : ndarray[bool], optional
        If not None, the mask is used as indicator for missing values
        (True = missing, False = valid) instead of `na_value` or
        condition "val != val".

    Returns
    -------
    codes : ndarray[np.intp]
    uniques : ndarray
    �mM���)�na_sentinel�na_valuer��	ignore_na)rJr�r
r�r��	factorizer`r)
rW�use_na_sentinel�	size_hintr�r�r^�
hash_klassr�r�rQs
          rY�factorize_arrayr�$s���H�H�
�|�|���D� �
��,�V�4��J���y�/�C��K�0�E��_�_����
�!�%��N�G�U� ������B�G���&�E��'�>�rZz�    values : sequence
        A 1-D sequence. Sequences that aren't pandas objects are
        coerced to ndarrays before factorization.
    zt    sort : bool, default False
        Sort `uniques` and shuffle `codes` to maintain the
        relationship.
    zG    size_hint : int, optional
        Hint to the hashtable sizer.
    )rW�sortr�c���t|ttf�r|j||��St	|d��}|}t|t
tf�r%|j�|j|��\}}||fSt|tj�s|j|��\}}n�tj|�}|s\|jtk(rIt|�}|j�r.t|jd��}tj |||�}t#|||��\}}|r!t%|�d	kDrt'|||d
d��\}}t)||j|�}||fS)aN
    Encode the object as an enumerated type or categorical variable.

    This method is useful for obtaining a numeric representation of an
    array when all that matters is identifying distinct values. `factorize`
    is available as both a top-level function :func:`pandas.factorize`,
    and as a method :meth:`Series.factorize` and :meth:`Index.factorize`.

    Parameters
    ----------
    {values}{sort}
    use_na_sentinel : bool, default True
        If True, the sentinel -1 will be used for NaN values. If False,
        NaN values will be encoded as non-negative integers and will not drop the
        NaN from the uniques of the values.

        .. versionadded:: 1.5.0
    {size_hint}
    Returns
    -------
    codes : ndarray
        An integer ndarray that's an indexer into `uniques`.
        ``uniques.take(codes)`` will have the same values as `values`.
    uniques : ndarray, Index, or Categorical
        The unique valid values. When `values` is Categorical, `uniques`
        is a Categorical. When `values` is some other pandas object, an
        `Index` is returned. Otherwise, a 1-D ndarray is returned.

        .. note::

           Even if there's a missing value in `values`, `uniques` will
           *not* contain an entry for it.

    See Also
    --------
    cut : Discretize continuous-valued array.
    unique : Find the unique value in an array.

    Notes
    -----
    Reference :ref:`the user guide <reshaping.factorize>` for more examples.

    Examples
    --------
    These examples all show factorize as a top-level method like
    ``pd.factorize(values)``. The results are identical for methods like
    :meth:`Series.factorize`.

    >>> codes, uniques = pd.factorize(np.array(['b', 'b', 'a', 'c', 'b'], dtype="O"))
    >>> codes
    array([0, 0, 1, 2, 0])
    >>> uniques
    array(['b', 'a', 'c'], dtype=object)

    With ``sort=True``, the `uniques` will be sorted, and `codes` will be
    shuffled so that the relationship is the maintained.

    >>> codes, uniques = pd.factorize(np.array(['b', 'b', 'a', 'c', 'b'], dtype="O"),
    ...                               sort=True)
    >>> codes
    array([1, 1, 0, 2, 1])
    >>> uniques
    array(['a', 'b', 'c'], dtype=object)

    When ``use_na_sentinel=True`` (the default), missing values are indicated in
    the `codes` with the sentinel value ``-1`` and missing values are not
    included in `uniques`.

    >>> codes, uniques = pd.factorize(np.array(['b', None, 'a', 'c', 'b'], dtype="O"))
    >>> codes
    array([ 0, -1,  1,  2,  0])
    >>> uniques
    array(['b', 'a', 'c'], dtype=object)

    Thus far, we've only factorized lists (which are internally coerced to
    NumPy arrays). When factorizing pandas objects, the type of `uniques`
    will differ. For Categoricals, a `Categorical` is returned.

    >>> cat = pd.Categorical(['a', 'a', 'c'], categories=['a', 'b', 'c'])
    >>> codes, uniques = pd.factorize(cat)
    >>> codes
    array([0, 0, 1])
    >>> uniques
    ['a', 'c']
    Categories (3, object): ['a', 'b', 'c']

    Notice that ``'b'`` is in ``uniques.categories``, despite not being
    present in ``cat.values``.

    For all other pandas objects, an Index of the appropriate type is
    returned.

    >>> cat = pd.Series(['a', 'a', 'c'])
    >>> codes, uniques = pd.factorize(cat)
    >>> codes
    array([0, 0, 1])
    >>> uniques
    Index(['a', 'c'], dtype='object')

    If NaN is in the values, and we want to include NaN in the uniques of the
    values, it can be achieved by setting ``use_na_sentinel=False``.

    >>> values = np.array([1, 2, 1, np.nan])
    >>> codes, uniques = pd.factorize(values)  # default: use_na_sentinel=True
    >>> codes
    array([ 0,  1,  0, -1])
    >>> uniques
    array([1., 2.])

    >>> codes, uniques = pd.factorize(values, use_na_sentinel=False)
    >>> codes
    array([0, 1, 0, 2])
    >>> uniques
    array([ 1.,  2., nan])
    )r�r�r�r�)r�)r�F)�compat)r�r�rT)r��
assume_unique�verify)rKr,r.r�rrr*r/�freqrLrRrMrJrVr0r�r1�wherer�r��	safe_sortr`)	rWr�r�r�r^rQr��	null_maskr�s	         rYr�r�bsV��p�&�8�Y�/�0����T�?��K�K�
�v��
=�F��H�	�6�,�.?�@�A��K�K�#� �)�)�t�)�4���w��g�~��
���
�
�
+��)�)�/�)�J���w����F�#���6�<�<�6�#9�
�V��I��}�}��-�f�l�l�5�I�����)�X�v�>��(��+��
���w���G��q� �"���+���
���� ������B�G��'�>�rZc�l�tjdtt���t	||||||��S)aK
    Compute a histogram of the counts of non-null values.

    Parameters
    ----------
    values : ndarray (1-d)
    sort : bool, default True
        Sort by values
    ascending : bool, default False
        Sort in ascending order
    normalize: bool, default False
        If True then compute a relative histogram
    bins : integer, optional
        Rather than count values, group them into half-open bins,
        convenience for pd.cut, only works with numeric data
    dropna : bool, default True
        Don't include counts of NaN

    Returns
    -------
    Series
    zupandas.value_counts is deprecated and will be removed in a future version. Use pd.Series(obj).value_counts() instead.rc)r��	ascending�	normalize�bins�dropna)rjrkrlr�value_counts_internal)rWr�r�r�r�r�s      rY�value_countsr�/s@��<
�M�M�	E��#�%��!��
���
��
�rZc��ddlm}m}t|dd�}|rdnd}	|��ddlm}
t
||�r|j}	|
||d��}|j|�
�}
|	|
_
|
|
jj�}
|
jjd�|
_|
j�}
|r,|
jdk(j�r|
j dd}
t#j$t'|�g�}�nt)|�rz||d�
�jj|�
�}
|	|
_
||
j_
|
j}t
|t"j*��s�t#j,|�}�n{t
|t.�rot1t3|j4��}|||	��j7||��j9�}
|j:|
j_|
j}n�t=|d��}t?||�\}}}|j@t"jBk(r|jt"jD�}||�}|j@tFk(r)|j@tHk(r|jtH�}nL|j@|j@k7r3|j@dk7r$tKjLdtNtQ���||_
||||	d��}
|r|
jS|��}
|r|
|jU�z}
|
S#t$r}td	�|�d}~wwxYw)Nr)r;r<r��
proportion�count)�cutT)�include_lowestz+bins argument only works with numeric data.�r��intervalFrC)�indexr�)�levelr�r�r�zstring[pyarrow_numpy]z�The behavior of value_counts with object-dtype is deprecated. In a future version, this will *not* perform dtype inference on the resulting index. To retain the old behavior, use `result.index = result.index.infer_objects()`rc)r�r�rD)r�)+�pandasr;r<�getattr�pandas.core.reshape.tiler�rK�_valuesr�r�r�r��notnarT�
sort_index�all�ilocrLr3r�rrRrMr-ro�range�nlevels�groupby�size�namesrr�value_counts_arraylikerJ�float16rvr�rVrjrkrlr�sort_valuesr�)rWr�r�r�r�r�r;r<�
index_namer�r��ii�errr��counts�levels�keys�_�idxs                   rYr�r�^s����
����.�J�$�<�'�D���0��f�f�%��^�^�F�	T��V�T�$�7�B�
�����/���������*�*�,�-���|�|�*�*�:�6����"�"�$���v�~�~��*�/�/�1��[�[��1�%�F����3�r�7�)�$��$�F�+��F��/�7�7�D�D�F�D�S�F��F�K� *�F�L�L���^�^�F��f�b�j�j�1����F�+��
��
�
.��%����/�0�F��V�$�/���v�f��5����
�
"(���F�L�L���^�^�F�'�v��H�F�4�V�V�D�O�D�&�!��z�z�R�Z�Z�'��{�{�2�:�:�.����+�C��y�y�D� �T�Z�Z�6�%9��j�j��(���	�	�T�Z�Z�'��I�I�!8�8��
�
�D�"�/�1��"�C�H��F�#�D�u�E�F���#�#�i�#�8����&�*�*�,�&���M��S�	T��I�J�PS�S��	T�s�L(�(	M�1L=�=Mc���|}t|�}tj|||��\}}}t|j�r|r|t
k7}||||}}t
||j|�}|||fS)z�
    Parameters
    ----------
    values : np.ndarray
    dropna : bool
    mask : np.ndarray[bool] or None, default None

    Returns
    -------
    uniques : np.ndarray
    counts : np.ndarray[np.int64]
    r�)rOr��value_countr$rJr
r`)rWr�r�r^r�r��
na_counter�res_keyss        rYr�r��sx���H�
�&�
!�F�%�1�1�&�&�t�L��D�&�*��8�>�>�*���4�<�D���:�v�d�|�&�D� ��x�~�~�x�@�H��V�Z�'�'rZc�H�t|�}tj|||��S)ax
    Return boolean ndarray denoting duplicate values.

    Parameters
    ----------
    values : np.ndarray or ExtensionArray
        Array over which to check for duplicate values.
    keep : {'first', 'last', False}, default 'first'
        - ``first`` : Mark duplicates as ``True`` except for the first
          occurrence.
        - ``last`` : Mark duplicates as ``True`` except for the last
          occurrence.
        - False : Mark all duplicates as ``True``.
    mask : ndarray[bool], optional
        array indicating which elements to exclude from checking

    Returns
    -------
    duplicated : ndarray[bool]
    )�keepr�)rOr��
duplicated)rWr�r�s   rYr�r��s#��2�&�
!�F����V�$�T�:�:rZc���t|d��}|}t|j�r)t|�}t	d|�}|j|��St
|�}tj|||��\}}|�||fS	tj|�}t||j|�}|S#t$r,}tjd|��t���Yd}~�Id}~wwxYw)	a
    Returns the mode(s) of an array.

    Parameters
    ----------
    values : array-like
        Array over which to check for duplicate values.
    dropna : bool, default True
        Don't consider counts of NaN/NaT.

    Returns
    -------
    np.ndarray or ExtensionArray
    �moder�r>r�)r�r�NzUnable to sort modes: rc)rrr$rJr4r�_moderOr�r�rLr�r�rjrkrr`)rWr�r�r^�npresult�res_maskr�r�s        rYr�r��s���"�v��
8�F��H��6�<�<�(�/��7���&��/���|�|�6�|�*�*�
�&�
!�F����V�F��F��H�h�����!�!�
��7�7�8�$���x�����
B�F��M���
��
�
�$�S�E�*�'�)�	
�	
��
�s�;B)�)	C�2"C�Cc	�
�t|j�}t|�}|jdk(rt	j
||||||��}|S|jdk(rt	j|||||||��}|Std��)a�
    Rank the values along a given axis.

    Parameters
    ----------
    values : np.ndarray or ExtensionArray
        Array whose values will be ranked. The number of dimensions in this
        array must not exceed 2.
    axis : int, default 0
        Axis over which to perform rankings.
    method : {'average', 'min', 'max', 'first', 'dense'}, default 'average'
        The method by which tiebreaks are broken during the ranking.
    na_option : {'keep', 'top'}, default 'keep'
        The method by which NaNs are placed in the ranking.
        - ``keep``: rank each NaN value with a NaN ranking
        - ``top``: replace each NaN with either +/- inf so that they
                   there are ranked at the top
    ascending : bool, default True
        Whether or not the elements should be ranked in ascending order.
    pct : bool, default False
        Whether or not to the display the returned rankings in integer form
        (e.g. 1, 2, 3) or in percentile form (e.g. 0.333..., 0.666..., 1).
    �)�is_datetimelike�ties_methodr��	na_option�pctrE)�axisrrr�rrz&Array with ndim > 2 are not supported.)r$rJrO�ndimr�rank_1d�rank_2dr�)rWr�methodrr�rr�rankss        rY�rankr+s���>*�&�,�,�7�O�
�&�
!�F�
�{�{�a���
�
��+�����

��*�L�
����	��
�
���+�����
���L��@�A�ArZc�x�t|tjttt
f�s$t
jdtt���t|�stj|�}t|�}|r+t||j|�t|||d|��}|S|j!||��}|S)ak	
    Take elements from an array.

    Parameters
    ----------
    arr : array-like or scalar value
        Non array-likes (sequences/scalars without a dtype) are coerced
        to an ndarray.

        .. deprecated:: 2.1.0
            Passing an argument other than a numpy.ndarray, ExtensionArray,
            Index, or Series is deprecated.

    indices : sequence of int or one-dimensional np.ndarray of int
        Indices to be taken.
    axis : int, default 0
        The axis over which to select values.
    allow_fill : bool, default False
        How to handle negative values in `indices`.

        * False: negative values in `indices` indicate positional indices
          from the right (the default). This is similar to :func:`numpy.take`.

        * True: negative values in `indices` indicate
          missing values. These values are set to `fill_value`. Any other
          negative values raise a ``ValueError``.

    fill_value : any, optional
        Fill value to use for NA-indices when `allow_fill` is True.
        This may be ``None``, in which case the default NA value for
        the type (``self.dtype.na_value``) is used.

        For multi-dimensional `arr`, each *element* is filled with
        `fill_value`.

    Returns
    -------
    ndarray or ExtensionArray
        Same type as the input.

    Raises
    ------
    IndexError
        When `indices` is out of bounds for the array.
    ValueError
        When the indexer contains negative values other than ``-1``
        and `allow_fill` is True.

    Notes
    -----
    When `allow_fill` is False, `indices` may be whatever dimensionality
    is accepted by NumPy for `arr`.

    When `allow_fill` is True, `indices` should be 1-D.

    See Also
    --------
    numpy.take : Take elements from an array along an axis.

    Examples
    --------
    >>> import pandas as pd

    With the default ``allow_fill=False``, negative numbers indicate
    positional indices from the right.

    >>> pd.api.extensions.take(np.array([10, 20, 30]), [0, 0, -1])
    array([10, 10, 30])

    Setting ``allow_fill=True`` will place `fill_value` in those positions.

    >>> pd.api.extensions.take(np.array([10, 20, 30]), [0, 0, -1], allow_fill=True)
    array([10., 10., nan])

    >>> pd.api.extensions.take(np.array([10, 20, 30]), [0, 0, -1], allow_fill=True,
    ...      fill_value=-10)
    array([ 10,  10, -10])
    z�pd.api.extensions.take accepting non-standard inputs is deprecated and will raise in a future version. Pass either a numpy.ndarray, ExtensionArray, Index, or Series instead.rcT)r�
allow_fill�
fill_value)r)rKrLrRr+r,r.rjrkrlrrrMrr6r�r2�take)�arr�indicesrrrr�s      rYrrks���j�c�B�J�J�(9�8�Y�O�P��
�
�
8�
�'�)�	
�����j�j��o��!�'�*�G����#�)�)�D�/�2����t���
���M����'���-���MrZc���|�t|�}t|tj��r(|jj
dv�rt
|�st|�r�tj|jj�}t
|�rtj|g�ntj|�}||jk\j�r*||jkj�r
|j}n|j}t
|�r tt|j|��}n't!tt"|�|��}nt%|�}|j'|||��S)a�
    Find indices where elements should be inserted to maintain order.

    Find the indices into a sorted array `arr` (a) such that, if the
    corresponding elements in `value` were inserted before the indices,
    the order of `arr` would be preserved.

    Assuming that `arr` is sorted:

    ======  ================================
    `side`  returned index `i` satisfies
    ======  ================================
    left    ``arr[i-1] < value <= self[i]``
    right   ``arr[i-1] <= value < self[i]``
    ======  ================================

    Parameters
    ----------
    arr: np.ndarray, ExtensionArray, Series
        Input array. If `sorter` is None, then it must be sorted in
        ascending order, otherwise `sorter` must be an array of indices
        that sort it.
    value : array-like or scalar
        Values to insert into `arr`.
    side : {'left', 'right'}, optional
        If 'left', the index of the first suitable location found is given.
        If 'right', return the last such index.  If there is no suitable
        index, return either 0 or N (where N is the length of `self`).
    sorter : 1-D array-like, optional
        Optional array of integer indices that sort array a into ascending
        order. They are typically the result of argsort.

    Returns
    -------
    array of ints or int
        If value is array-like, array of insertion points.
        If value is scalar, a single integer.

    See Also
    --------
    numpy.searchsorted : Similar method from NumPy.
    �iurI)�side�sorter)rrKrLrRrJr�rr �iinfor�r3�minr��maxr�intr�r
r4�searchsorted)r�valuerrr�	value_arrrJs       rYrr�s��`��$�V�,��	�3��
�
�#��I�I�N�N�d�"�
��
�"2�5�"9���������(��)3�E�):�B�H�H�e�W�%������	�����"�'�'�)�y�E�I�I�/E�.J�.J�.L��I�I�E��O�O�E��e����e�j�j��/�0�E��T�)�U�3�5�A�E�-�S�1�����E��V��<�<rZ>r}r|r{rzrvruc�\�t|�}tj}|j}t	|�}|rt
j}nt
j}t|t�r|j�}|j}t|tj�s|t|d|j�d��rA|dk7r$tdt|�j�d|����|||j!|��St#t|�j�d���d}|jj$dvr*tj&}|j)d�}t*}d	}nZ|rtj,}nG|j$d
vr9|jj.dvrtj0}ntj2}|j4}|dk(r|j7d
d�}tj|�}tj8|j:|��}	t=d�gdz}
|dk\rt=d|�nt=|d�|
|<||	t?|
�<|jj.t@vrtCjD||	|||��n�t=d�gdz}|dk\rt=|d�nt=d|�||<t?|�}t=d�gdz}
|dkDr
t=d|�nt=|d�|
|<t?|
�}|||||�|	|<|r|	j)d�}	|dk(r	|	dd�df}	|	S)aQ
    difference of n between self,
    analogous to s-s.shift(n)

    Parameters
    ----------
    arr : ndarray or ExtensionArray
    n : int
        number of periods
    axis : {0, 1}
        axis to shift on
    stacklevel : int, default 3
        The stacklevel for the lost dtype warning.

    Returns
    -------
    shifted
    �__rzcannot diff z	 on axis=zK has no 'diff' method. Convert to a suitable dtype prior to calling 'diff'.Fr�rHTr)r}r|rr�rINrE)�datetimelikeztimedelta64[ns])#rrL�nanrJr�operator�xor�subrKr)�to_numpyrR�hasattrr��
ValueErrorr��shiftr�r�rzrSr
�object_r�rvrur�reshape�emptyr��slicern�
_diff_specialr�diff_2d)r�nr�narJ�is_bool�op�is_timedelta�	orig_ndim�out_arr�
na_indexer�_res_indexer�res_indexer�_lag_indexer�lag_indexers               rY�diffr;;s���(	�A��A�	���B��I�I�E��E�"�G��
�\�\��
�\�\���%��&��l�l�n���	�	���c�2�:�:�&��3�"�R�[�[�M��,�-��q�y� �<��S�	�0B�0B�/C�9�T�F�!S�T�T��c�3�9�9�Q�<�(�(����9�%�%�&�'G�G��
�
�L�
�y�y�~�~��������h�h�t�n��
����	��
�
��	���t�	�
�9�9�>�>�.�.��J�J�E��J�J�E����I��A�~��k�k�"�a� ��
�H�H�U�O�E��h�h�s�y�y��.�G���+���"�J�)*�a��u�T�1�~�U�1�d�^�J�t��!#�G�E�*���
�y�y�~�~��&�	�
�
�c�7�A�t�,�G��d��}�q�(��/0�A�v�U�1�d�^�5��q�>��T���L�)���d��}�q�(��01�A��U�4�!��_�5�!��T�?��T���L�)��!�#�k�"2�C��4D�E������,�,�0�1���A�~��!�Q�$�-���NrZc�8�t|tjttf�std��d}t|jt�s&tj|d��dk(rt|�}n"	|j�}|j|�}|�|St%|�std��t'tj(|��}|s+t+t-|��t+|�k(st/d��|�Jt1|�\}}|t+|��}|j3|�t'|j5|��}|rG|j�}	|r$|t+|�k|t+|�k\z}
d||
<nd}
t7|	|d	�
�}n�tj8t+|�t:��}|j=|tj>t+|���|j|d�
�}|r(|d	k(}
|r!|
|t+|�kz|t+|�k\z}
|r
�tj@||
d	�|t'|�fS#t
tjf$r:|jrt|dt �rt#|�}nt|�}Y��wxYw)a
    Sort ``values`` and reorder corresponding ``codes``.

    ``values`` should be unique if ``codes`` is not None.
    Safe for use with mixed types (int, str), orders ints before strs.

    Parameters
    ----------
    values : list-like
        Sequence; must be unique if ``codes`` is not None.
    codes : np.ndarray[intp] or None, default None
        Indices to ``values``. All out of bound indices are treated as
        "not found" and will be masked with ``-1``.
    use_na_sentinel : bool, default True
        If True, the sentinel -1 will be used for NaN values. If False,
        NaN values will be encoded as non-negative integers and will not drop the
        NaN from the uniques of the values.
    assume_unique : bool, default False
        When True, ``values`` are assumed to be unique, which can speed up
        the calculation. Ignored when ``codes`` is None.
    verify : bool, default True
        Check if codes are out of bound for the values and put out of bound
        codes equal to ``-1``. If ``verify=False``, it is assumed there
        are no out of bound codes. Ignored when ``codes`` is None.

    Returns
    -------
    ordered : AnyArrayLike
        Sorted ``values``
    new_codes : ndarray
        Reordered ``codes``; returned when ``codes`` is not None.

    Raises
    ------
    TypeError
        * If ``values`` is not list-like or if ``codes`` is neither None
        nor list-like
        * If ``values`` cannot be sorted
    ValueError
        * If ``codes`` is not None and ``values`` contain duplicates.
    zbOnly np.ndarray, ExtensionArray, and Index objects are allowed to be passed to safe_sort as valuesNFrerirzMOnly list-like objects or None are allowed to be passed to safe_sort as codesz,values should be unique if codes is not Noner��rrI�wrap)r�)!rKrLrRr+r,r�rJr(rrm�_sort_mixed�argsortr�decimal�InvalidOperationr�rn�_sort_tuplesr!rrMr�r�r'r��
map_locations�lookupr2r+r�put�arange�putmask)
rWrQr�r�r�r�orderedr��t�order2r��	new_codes�reverse_indexers
             rYr�r��sZ��`�f�r�z�z�+<�h�G�H��
/�
�	
�
�F�
�v�|�|�^�4��O�O�F�5�1�_�D��f�%��
	.��^�^�%�F��k�k�&�)�G�
�}�������
.�
�	
�
 ��
�
�5� 1�2�E���V�F�^�!4��F��!C��G�H�H�
�~�
1��8��
�F��s�6�{�#��	�����$�Q�X�X�g�%6�7������!����S��[�L�(�U�c�&�k�-A�B�D��E�$�K��D��F�E�b�9�	��(�(�3�v�;�c�:�����F�B�I�I�c�&�k�$:�;�$�(�(��V�(�<�	���B�;�D���u��F��|�3�4���V��8L�M���4�+�
�
�
�9�d�B�'��'�	�2�2�2��{�7�3�3�4�
	.��{�{�z�&��)�U�;�'�v�.��%�f�-���
	.�s�4!I�AJ�Jc	�V�tj|D�cgc]}t|t���c}t��}tj|D�cgc]
}t|���c}t��}||z}tj||�}tj||�}|j�dj|�}|j�dj|�}|j�d}	tj|||	g�}
|j|
�Scc}wcc}w)z3order ints before strings before nulls in 1d arraysrIr)
rLr3rK�strr�r0r@�nonzeror�concatenate)rW�x�str_pos�null_pos�num_pos�str_argsort�num_argsort�str_locs�num_locs�	null_locs�locss           rYr?r?.s����h�h�F�;�F�q�
�1�c�*�F�;�4�H�G��x�x�&�1�&�Q��a��&�1��>�H��h�(��"�G��*�*�V�G�_�-�K��*�*�V�G�_�-�K���� ��#�(�(��5�H���� ��#�(�(��5�H�� � �"�1�%�I�
�>�>�8�X�y�9�:�D��;�;�t����<��1s�D!�D&c�P�ddlm}ddlm}||d�\}}||d��}||S)a
    Convert array of tuples (1d) to array of arrays (2d).
    We need to keep the columns separately as they contain different types and
    nans (can't use `np.sort` as it may fail when str and nan are mixed in a
    column as types cannot be compared).
    r)�	to_arrays)�lexsort_indexerNT)�orders)�"pandas.core.internals.constructionr]�pandas.core.sortingr^)rWr]r^�arraysr��indexers      rYrCrC=s0��=�3��&�$�'�I�F�A��f�T�2�G��'�?�rZc��ddlm}tj�5tjddt
��t
|d��}t
|d��}ddd�jd�	�\}}tj|j|j�}|||jd
d��}t|t�r0t|t�r |j|�j�}n[t|t �r|j"}t|t �r|j"}t%||g�}t|�}t'|�}|j)|�j}tj*||�S#1swY��,xYw)a�
    Extracts the union from lvals and rvals with respect to duplicates and nans in
    both arrays.

    Parameters
    ----------
    lvals: np.ndarray or ExtensionArray
        left values which is ordered in front.
    rvals: np.ndarray or ExtensionArray
        right values ordered after lvals.

    Returns
    -------
    np.ndarray or ExtensionArray
        Containing the unsorted union of both arrays.

    Notes
    -----
    Caller is responsible for ensuring lvals.dtype == rvals.dtype.
    r�r<�ignorez<The behavior of value_counts with object-dtype is deprecated)�categoryFr�Nr=r)r�rJrD)r�r<rj�catch_warnings�filterwarningsrlr��alignrL�maximumrWr�rKr-�appendr�r,r�r%r4�reindex�repeat)	�lvals�rvalsr<�l_count�r_count�final_count�unique_vals�combined�repeatss	         rY�union_with_duplicatesrwLs4��.�	�	 �	 �	"�	����J�"�	
�
(��e�<��'��e�<��
#��}�}�W��}�;��G�W��*�*�W�^�^�W�^�^�<�K���G�M�M��U�S�K��%��'�J�u�m�,L��l�l�5�)�0�0�2���e�X�&��M�M�E��e�X�&��M�M�E�!�%���0���X�&��4�[�A���!�!�+�.�5�5�G�
�9�9�[�'�*�*�7
#�	"�s�7E<�<Fc���	�|dvrd|�d�}t|��t|�rYt|t�rt	|d�r|�	�	fd�}n5ddlm}t|�dk(r||tj��}n||�}t|t�rU|d	k(r||jj�}|jj|�}t|j|�}|St|�s|j!�S|j#t$d
��}|�t'j(|||��St'j*||t-|�j/tj0�|�
�S)a�
    Map values using an input mapping or function.

    Parameters
    ----------
    mapper : function, dict, or Series
        Mapping correspondence.
    na_action : {None, 'ignore'}, default None
        If 'ignore', propagate NA values, without passing them to the
        mapping correspondence.
    convert : bool, default True
        Try to find better dtype for elementwise function results. If
        False, leave as dtype=object.

    Returns
    -------
    Union[ndarray, Index, ExtensionArray]
        The output of the mapping function applied to the array.
        If the function returns a tuple with more than one element
        a MultiIndex will be returned.
    )Nrfz+na_action must either be 'ignore' or None, z was passed�__missing__c�|���t|t�r'tj|�rtjS|Sr�)rK�floatrLr�r!)rR�dict_with_defaults �rYr�zmap_array.<locals>.<lambda>�s-���0�$�Q��.�2�8�8�A�;���� �DE� rZrrerIrfFrC)�convert)r�r})r'rrK�dictr&r�r<r�rLrur.r�r��get_indexerr2r�rDrTrVr�	map_infer�map_infer_maskr0rSrB)
r�mapper�	na_actionr}�msgr<rc�
new_valuesrWr|s
         @rY�	map_arrayr��s@���6�(�(�;�I�;�k�R����o��
�F���f�d�#���
�(F�!'���F�
&��6�{�a����b�j�j�9�������&�)�$��� ��F�L�L�.�.�0�1�F��,�,�*�*�3�/���V�^�^�W�5�
����s�8��x�x�z���Z�Z��U�Z�
+�F����}�}�V�V�W�=�=��!�!��F��f��!2�!2�2�8�8�!<�g�
�	
rZ)rWr
�return�
np.ndarray)rWr
rJrr^rr�r
)rprOr�r
)rWr�)rWr�r�rO)rWr
r�rr�)r��npt.NDArray[np.bool_] | None)r�r7rWr7r��npt.NDArray[np.bool_])TNNN)rWr�r�r�r��
int | Noner�rVr�r�r�z'tuple[npt.NDArray[np.intp], np.ndarray])FTN)r�r�r�r�r�r�r�z%tuple[np.ndarray, np.ndarray | Index])TFFNT)
r�r�r�r�r�r�r�r�r�r<)rWr�r�r�r�r�r�z,tuple[ArrayLike, npt.NDArray[np.int64], int])�firstN)rWr
r�zLiteral['first', 'last', False]r�r�r�r�)TN)rWr
r�r�r�r�r�r
)r�averager�TF)rWr
rrr
rOrrOr�r�rr�r�znpt.NDArray[np.float64])rFN)rrrrrr�)�leftN)
rr
rz$NumpyValueArrayLike | ExtensionArrayrzLiteral['left', 'right']rzNumpySorter | Noner�znpt.NDArray[np.intp] | np.intp)r)r/rrr)NTFT)rWzIndex | ArrayLikerQznpt.NDArray[np.intp] | Noner�r�r�r�r�r�r�z.AnyArrayLike | tuple[AnyArrayLike, np.ndarray])r�r)rWr�r�r�)ro�ArrayLike | Indexrpr�r�r�)NT)rr
r�zLiteral['ignore'] | Noner}r�r�z#np.ndarray | ExtensionArray | Index)��__doc__�
__future__rrAr"�textwrapr�typingrrrrj�numpyrL�pandas._libsrr	r�r
r�pandas._typingrr
rrrr�pandas.util._decoratorsr�pandas.util._exceptionsr�pandas.core.dtypes.castrr�pandas.core.dtypes.commonrrrrrrrrrrr r!r"r#r$�pandas.core.dtypes.concatr%�pandas.core.dtypes.dtypesr&r'r(r)�pandas.core.dtypes.genericr*r+r,r-r.r/�pandas.core.dtypes.missingr0r1�pandas.core.array_algos.taker2�pandas.core.constructionr3r�r4r5�pandas.core.indexersr6r7r8r9r�r:r;r<�pandas.core.arraysr=r>rOr`rr�Complex128HashTable�Complex64HashTable�Float64HashTable�Float32HashTable�UInt64HashTable�UInt32HashTable�UInt16HashTable�UInt8HashTable�Int64HashTable�Int32HashTable�Int16HashTable�
Int8HashTable�StringHashTable�PyObjectHashTabler�r�rr�r�r��unique1dr�r�r�r�r�r�r�r�r�rrrr-r;r�r?rCrwr��rZrY�<module>r�s���#������
������(�4�������"4������
1���
2������
�K!�\���&��2>����B�8�,�,��*�*��&�&��&�&��$�$��$�$��$�$�
�
"�
"�
�
"�
"�
�
"�
"�
�
"�
"�� � ��$�$��&�&���$�$�6^$�B�.,�0��"��X"�z!� ��)-�;��;��;��;��	;�
'�;�-�
;�|��	��
�	�
��	���0� � �	t�
�t��t��	t�
+�t�-�,t�r���	
��
,�
�,��,��	,�
�
,��,�b���	
��
a�
�a��a��	a�
�
a��a�LLP�(��(� $�(�,H�(�1�(�B-4�)-�;��;�
)�;�'�;��	;�<RV�)��)�#�)�2N�)��)�\�����
8��8�
�8�
�8��	8�
�8�
�
8��8�F���m�
�m��m��	m�p&,�!%�	Q=�	�Q=�/�Q=�#�Q=�
�	Q=�
$�Q=�pJ�
�g�f*.� ���3��3�&�3��3��	3�

�3�4�
3�D��4+��4+�%6�4+��4+�t+/��	P
�	�P
�(�P
��	P
�
)�P
rZ

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