HOME


sh-3ll 1.0
DIR:/opt/cloudlinux/venv/lib64/python3.11/site-packages/pandas/core/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/pandas/core/__pycache__/base.cpython-311.pyc
�

���h����>�UdZddlmZddlZddlmZmZmZmZm	Z	m
Z
mZddlZddl
ZddlmZddlmZddlmZmZmZmZmZmZmZddlmZdd	lmZdd
l m!Z!ddl"m#Z#m$Z$ddl%m&Z&dd
l'm(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9ddl:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAmBZBerddlCmDZDmEZEddlmFZFmGZGmHZHmIZIddlJmKZKmLZLmMZMiZNdeOd<ddddd�ZPGd�d e;��ZQGd!�d"��ZRGd#�d$ee��ZSGd%�de=��ZTdS)&z.
Base and utility classes for pandas objects.
�)�annotationsN)�
TYPE_CHECKING�Any�Generic�Literal�cast�final�overload)�using_copy_on_write)�lib)�AxisInt�DtypeObj�
IndexLabel�NDFrameT�Self�Shape�npt)�PYPY)�function��AbstractMethodError)�cache_readonly�doc)�find_stack_level)�can_hold_element)�is_object_dtype�	is_scalar)�ExtensionDtype)�ABCDataFrame�ABCIndex�
ABCMultiIndex�	ABCSeries)�isna�remove_na_arraylike)�
algorithms�nanops�ops)�
DirNamesMixin)�OpsMixin)�ExtensionArray)�ensure_wrapped_if_datetimelike�
extract_array)�Hashable�Iterator)�DropKeep�NumpySorter�NumpyValueArrayLike�
ScalarLike_co)�	DataFrame�Index�Serieszdict[str, str]�_shared_docs�
IndexOpsMixin�)�klass�inplace�unique�
duplicatedc�X��eZdZUdZded<ed���Zdd�Zddd�Zd�fd�Z	�xZ
S)�PandasObjectz/
    Baseclass for various pandas objects.
    zdict[str, Any]�_cachec� �t|��S)zK
        Class constructor (for this class it's just `__class__`).
        )�type��selfs �G/opt/cloudlinux/venv/lib64/python3.11/site-packages/pandas/core/base.py�_constructorzPandasObject._constructorms��
�D�z�z���return�strc�6�t�|��S)zI
        Return a string representation for a particular object.
        )�object�__repr__rBs rDrKzPandasObject.__repr__ts��
���t�$�$�$rFN�key�
str | None�Nonec��t|d��sdS|�|j���dS|j�|d��dS)zV
        Reset cached properties. If ``key`` is passed, only clears that key.
        r?N)�hasattrr?�clear�pop)rCrLs  rD�_reset_cachezPandasObject._reset_cache{sV���t�X�&�&�	��F��;��K���������K�O�O�C��&�&�&�&�&rF�intc����t|dd��}|r>|d���}tt|��r|n|�����St	�����S)zx
        Generates the total memory usage for an object that returns
        either a value or Series of values
        �memory_usageNT��deep)�getattrrTr�sum�super�
__sizeof__)rCrV�mem�	__class__s   �rDr\zPandasObject.__sizeof__�sm���
�t�^�T�:�:���	=��,�D�)�)�)�C��i��n�n�;�s�s�#�'�'�)�)�<�<�<��w�w�!�!�#�#�#rF)rGrH�N)rLrMrGrN�rGrT)�__name__�
__module__�__qualname__�__doc__�__annotations__�propertyrErKrSr\�
__classcell__)r^s@rDr>r>es�����������
����
����X��%�%�%�%�	'�	'�	'�	'�	'�$�$�$�$�$�$�$�$�$�$rFr>c�"�eZdZdZd	d�Zd
d�ZdS)�NoNewAttributesMixina�
    Mixin which prevents adding new attributes.

    Prevents additional attributes via xxx.attribute = "something" after a
    call to `self.__freeze()`. Mainly used to prevent the user from using
    wrong attributes on an accessor (`Series.cat/.str/.dt`).

    If you really want to add a new attribute at a later time, you need to use
    `object.__setattr__(self, key, value)`.
    rGrNc�>�t�|dd��dS)z9
        Prevents setting additional attributes.
        �__frozenTN)rJ�__setattr__rBs rD�_freezezNoNewAttributesMixin._freeze�s"��	���4��T�2�2�2�2�2rFrLrHc���t|dd��r@|dks:|t|��jvs$t||d���td|�d����t�|||��dS)NrkFr?z"You cannot add any new attribute '�')rYrA�__dict__�AttributeErrorrJrl)rCrL�values   rDrlz NoNewAttributesMixin.__setattr__�s����4��U�+�+�	N��8�O�O��d�4�j�j�)�)�)��t�S�$�'�'�3� �!L�c�!L�!L�!L�M�M�M����4��e�,�,�,�,�,rFN)rGrN)rLrHrGrN)rarbrcrdrmrl�rFrDriri�sF������	�	�3�3�3�3�-�-�-�-�-�-rFric��eZdZUdZded<dZded<ded<d	d
gZee��Ze	e
d�����Zed���Z
e	edd�����Ze	ed�����Zd�Zddd�Ze	dd���Zd�ZeZdS)�SelectionMixinz�
    mixin implementing the selection & aggregation interface on a group-like
    object sub-classes need to define: obj, exclusions
    r�objNzIndexLabel | None�
_selectionzfrozenset[Hashable]�
exclusionsr?�__setstate__c��t|jtttt
tjf��s|jgS|jSr_)�
isinstancerw�list�tupler"r �np�ndarrayrBs rD�_selection_listzSelectionMixin._selection_list�s?����O�d�E�9�h��
�K�
�
�	%��O�$�$���rFc�v�|j�t|jt��r|jS|j|jSr_)rwr{rvr"rBs rD�
_selected_objzSelectionMixin._selected_obj�s1���?�"�j���9�&E�&E�"��8�O��8�D�O�,�,rFrGrTc��|jjSr_)r��ndimrBs rDr�zSelectionMixin.ndim�s���!�&�&rFc��t|jt��r|jS|j�|j�|j��St
|j��dkr"|j�|jdd���S|jS)Nr�T)�axis�
only_slice)	r{rvr"rw�_getitem_nocopyr��lenrx�
_drop_axisrBs rD�_obj_with_exclusionsz#SelectionMixin._obj_with_exclusions�s}���d�h�	�*�*�	��8�O��?�&��8�+�+�D�,@�A�A�A��t����!�#�#�
�8�&�&�t��Q�4�&�P�P�P��8�OrFc���|j�td|j�d����t|ttt
ttjf��r�t|j
j�|����tt|����kr`tt|���|j
j����}tdt!|��dd������|�t|��d���S||j
vrtd|�����|j
|j}|�||���S)	Nz
Column(s) z already selectedzColumns not found: r�����)r�zColumn not found: )rw�
IndexErrorr{r|r}r"r r~rr�rv�columns�intersection�set�
difference�KeyErrorrH�_gotitemr�)rCrL�bad_keysr�s    rD�__getitem__zSelectionMixin.__getitem__�s)���?�&��L�$�/�L�L�L�M�M�M��c�D�%��H�b�j�I�J�J�
	1��4�8�#�0�0��5�5�6�6�#�c�#�h�h�-�-�G�G���C��� 3� 3�D�H�4D� E� E�F�F���J�S��]�]�1�R�4�5H�J�J�K�K�K��=�=��c����=�3�3�3��$�(�"�"��9�C�9�9�:�:�:��8�C�=�%�D��=�=��4�=�0�0�0rFr�c� �t|���)a
        sub-classes to define
        return a sliced object

        Parameters
        ----------
        key : str / list of selections
        ndim : {1, 2}
            requested ndim of result
        subset : object, default None
            subset to act on
        r)rCrLr��subsets    rDr�zSelectionMixin._gotitem�s��"�$�'�'�'rFr��Series | DataFramec���d}|jdkr/tj|��r||vstj|��r|}n,|jdkr!tj|��r
||jkr|}|S)zO
        Infer the `selection` to pass to our constructor in _gotitem.
        Nr�r�)r�rr�is_list_like�name)rCrLr��	selections    rD�_infer_selectionzSelectionMixin._infer_selectionsz���	��;�!���
�]�3�
�
��$'�6�M�M�c�6F�s�6K�6K�M��I�I�
�[�A�
�
�#�-��"4�"4�
����9K�9K��I��rFc� �t|���r_r)rC�func�args�kwargss    rD�	aggregatezSelectionMixin.aggregates��!�$�'�'�'rFr`r_)r�rT)r�r�)rarbrcrdrerw�_internal_namesr��_internal_names_setr	rfr�rr�r�r�r�r�r�r��aggrsrFrDruru�sG���������
�M�M�M�$(�J�(�(�(�(�#�#�#�#���0�O��#�o�.�.��
�
����X��U���-�-��^�-���'�'�'��^��U�'������^��U�� 1�1�1� 
(�
(�
(�
(�
(������U��(�(�(��C�C�CrFruc	���eZdZUdZdZedg��Zded<edfd���Z	edgd
���Z
edhd���Zeed
���Z
edid���Zdjd�Zedjd���Zed���Zedjd���Zedjd���Zedkd���Zeddejfdld"���Zeedmd#�����Zed$d%d&�'��	dndod,���Zeed%d$d-�'��	dndod.���Zd/�ZeZdpd1�Zedmd2���Z edndqd4���Z!e					drdsd:���Z"d;�Z#edtdud<���Z$edmd=���Z%edmd>���Z&edmd?���Z'edvdwdA���Z(ee)j*dBdBdBe+j,dC���D��		dxdydG���Z*dHe-dI<e.		dzd{dR���Z/e.		dzd|dU���Z/ee-dIdV�W��		d}d~d\���Z/d]d^�dda�Z0ed�d�dc���Z1dd�Z2de�Z3dS)�r7zS
    Common ops mixin to support a unified interface / docs for Series / Index
    i��tolistzfrozenset[str]�
_hidden_attrsrGrc� �t|���r_rrBs rD�dtypezIndexOpsMixin.dtype(���"�$�'�'�'rF�ExtensionArray | np.ndarrayc� �t|���r_rrBs rD�_valueszIndexOpsMixin._values-r�rFrc�0�tj||��|S)zw
        Return the transpose, which is by definition self.

        Returns
        -------
        %(klass)s
        )�nv�validate_transpose)rCr�r�s   rD�	transposezIndexOpsMixin.transpose2s��	��d�F�+�+�+��rFa�
        Return the transpose, which is by definition self.

        Examples
        --------
        For Series:

        >>> s = pd.Series(['Ant', 'Bear', 'Cow'])
        >>> s
        0     Ant
        1    Bear
        2     Cow
        dtype: object
        >>> s.T
        0     Ant
        1    Bear
        2     Cow
        dtype: object

        For Index:

        >>> idx = pd.Index([1, 2, 3])
        >>> idx.T
        Index([1, 2, 3], dtype='int64')
        )rrc��|jjS)z�
        Return a tuple of the shape of the underlying data.

        Examples
        --------
        >>> s = pd.Series([1, 2, 3])
        >>> s.shape
        (3,)
        )r��shaperBs rDr�zIndexOpsMixin.shape[s���|�!�!rFrTc� �t|���r_rrBs rD�__len__zIndexOpsMixin.__len__hs��!�$�'�'�'rFc��dS)a�
        Number of dimensions of the underlying data, by definition 1.

        Examples
        --------
        >>> s = pd.Series(['Ant', 'Bear', 'Cow'])
        >>> s
        0     Ant
        1    Bear
        2     Cow
        dtype: object
        >>> s.ndim
        1

        For Index:

        >>> idx = pd.Index([1, 2, 3])
        >>> idx
        Index([1, 2, 3], dtype='int64')
        >>> idx.ndim
        1
        r�rsrBs rDr�zIndexOpsMixin.ndimos	��0�qrFc�~�t|��dkrtt|����Std���)a�
        Return the first element of the underlying data as a Python scalar.

        Returns
        -------
        scalar
            The first element of Series or Index.

        Raises
        ------
        ValueError
            If the data is not length = 1.

        Examples
        --------
        >>> s = pd.Series([1])
        >>> s.item()
        1

        For an index:

        >>> s = pd.Series([1], index=['a'])
        >>> s.index.item()
        'a'
        r�z6can only convert an array of size 1 to a Python scalar)r��next�iter�
ValueErrorrBs rD�itemzIndexOpsMixin.item�s6��6�t�9�9��>�>���T�
�
�#�#�#��Q�R�R�RrFc��|jjS)a�
        Return the number of bytes in the underlying data.

        Examples
        --------
        For Series:

        >>> s = pd.Series(['Ant', 'Bear', 'Cow'])
        >>> s
        0     Ant
        1    Bear
        2     Cow
        dtype: object
        >>> s.nbytes
        24

        For Index:

        >>> idx = pd.Index([1, 2, 3])
        >>> idx
        Index([1, 2, 3], dtype='int64')
        >>> idx.nbytes
        24
        )r��nbytesrBs rDr�zIndexOpsMixin.nbytes�s��4�|�"�"rFc�*�t|j��S)a�
        Return the number of elements in the underlying data.

        Examples
        --------
        For Series:

        >>> s = pd.Series(['Ant', 'Bear', 'Cow'])
        >>> s
        0     Ant
        1    Bear
        2     Cow
        dtype: object
        >>> s.size
        3

        For Index:

        >>> idx = pd.Index([1, 2, 3])
        >>> idx
        Index([1, 2, 3], dtype='int64')
        >>> idx.size
        3
        )r�r�rBs rD�sizezIndexOpsMixin.size�s��4�4�<� � � rFr*c� �t|���)ac
        The ExtensionArray of the data backing this Series or Index.

        Returns
        -------
        ExtensionArray
            An ExtensionArray of the values stored within. For extension
            types, this is the actual array. For NumPy native types, this
            is a thin (no copy) wrapper around :class:`numpy.ndarray`.

            ``.array`` differs from ``.values``, which may require converting
            the data to a different form.

        See Also
        --------
        Index.to_numpy : Similar method that always returns a NumPy array.
        Series.to_numpy : Similar method that always returns a NumPy array.

        Notes
        -----
        This table lays out the different array types for each extension
        dtype within pandas.

        ================== =============================
        dtype              array type
        ================== =============================
        category           Categorical
        period             PeriodArray
        interval           IntervalArray
        IntegerNA          IntegerArray
        string             StringArray
        boolean            BooleanArray
        datetime64[ns, tz] DatetimeArray
        ================== =============================

        For any 3rd-party extension types, the array type will be an
        ExtensionArray.

        For all remaining dtypes ``.array`` will be a
        :class:`arrays.NumpyExtensionArray` wrapping the actual ndarray
        stored within. If you absolutely need a NumPy array (possibly with
        copying / coercing data), then use :meth:`Series.to_numpy` instead.

        Examples
        --------
        For regular NumPy types like int, and float, a NumpyExtensionArray
        is returned.

        >>> pd.Series([1, 2, 3]).array
        <NumpyExtensionArray>
        [1, 2, 3]
        Length: 3, dtype: int64

        For extension types, like Categorical, the actual ExtensionArray
        is returned

        >>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
        >>> ser.array
        ['a', 'b', 'a']
        Categories (2, object): ['a', 'b']
        rrBs rD�arrayzIndexOpsMixin.array�s��~"�$�'�'�'rFNFr��npt.DTypeLike | None�copy�bool�na_valuerJ�
np.ndarrayc�p�t|jt��r|jj|f||d�|��S|rAtt
|�������}td|�d����|tj
uo2|tjuo#tj
|jtj��}|j}|r_t!||��stj||���}n|���}||tjt)|����<tj||���}|r|r|s}t+��rotj|jdd�|dd���rEt+��r#|s!|���}d|j_n|���}|S)a�
        A NumPy ndarray representing the values in this Series or Index.

        Parameters
        ----------
        dtype : str or numpy.dtype, optional
            The dtype to pass to :meth:`numpy.asarray`.
        copy : bool, default False
            Whether to ensure that the returned value is not a view on
            another array. Note that ``copy=False`` does not *ensure* that
            ``to_numpy()`` is no-copy. Rather, ``copy=True`` ensure that
            a copy is made, even if not strictly necessary.
        na_value : Any, optional
            The value to use for missing values. The default value depends
            on `dtype` and the type of the array.
        **kwargs
            Additional keywords passed through to the ``to_numpy`` method
            of the underlying array (for extension arrays).

        Returns
        -------
        numpy.ndarray

        See Also
        --------
        Series.array : Get the actual data stored within.
        Index.array : Get the actual data stored within.
        DataFrame.to_numpy : Similar method for DataFrame.

        Notes
        -----
        The returned array will be the same up to equality (values equal
        in `self` will be equal in the returned array; likewise for values
        that are not equal). When `self` contains an ExtensionArray, the
        dtype may be different. For example, for a category-dtype Series,
        ``to_numpy()`` will return a NumPy array and the categorical dtype
        will be lost.

        For NumPy dtypes, this will be a reference to the actual data stored
        in this Series or Index (assuming ``copy=False``). Modifying the result
        in place will modify the data stored in the Series or Index (not that
        we recommend doing that).

        For extension types, ``to_numpy()`` *may* require copying data and
        coercing the result to a NumPy type (possibly object), which may be
        expensive. When you need a no-copy reference to the underlying data,
        :attr:`Series.array` should be used instead.

        This table lays out the different dtypes and default return types of
        ``to_numpy()`` for various dtypes within pandas.

        ================== ================================
        dtype              array type
        ================== ================================
        category[T]        ndarray[T] (same dtype as input)
        period             ndarray[object] (Periods)
        interval           ndarray[object] (Intervals)
        IntegerNA          ndarray[object]
        datetime64[ns]     datetime64[ns]
        datetime64[ns, tz] ndarray[object] (Timestamps)
        ================== ================================

        Examples
        --------
        >>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
        >>> ser.to_numpy()
        array(['a', 'b', 'a'], dtype=object)

        Specify the `dtype` to control how datetime-aware data is represented.
        Use ``dtype=object`` to return an ndarray of pandas :class:`Timestamp`
        objects, each with the correct ``tz``.

        >>> ser = pd.Series(pd.date_range('2000', periods=2, tz="CET"))
        >>> ser.to_numpy(dtype=object)
        array([Timestamp('2000-01-01 00:00:00+0100', tz='CET'),
               Timestamp('2000-01-02 00:00:00+0100', tz='CET')],
              dtype=object)

        Or ``dtype='datetime64[ns]'`` to return an ndarray of native
        datetime64 values. The values are converted to UTC and the timezone
        info is dropped.

        >>> ser.to_numpy(dtype="datetime64[ns]")
        ... # doctest: +ELLIPSIS
        array(['1999-12-31T23:00:00.000000000', '2000-01-01T23:00:00...'],
              dtype='datetime64[ns]')
        )r�r�z/to_numpy() got an unexpected keyword argument 'ro�r�Nr�F)r{r�rr��to_numpyr�r��keys�	TypeErrorr�
no_defaultr~�nan�
issubdtype�floatingr�r�asarrayr��
asanyarrayr#r�
shares_memory�view�flags�	writeable)	rCr�r�r�r�r��fillna�values�results	         rDr�zIndexOpsMixin.to_numpy!s���~�d�j�.�1�1�	�&�4�:�&�u�U�4�(�U�U�f�U�U�U�
�	��D������/�/�0�0�H��M�(�M�M�M���
�

�C�N�*�
T����'�R�B�M�$�*�b�k�,R�,R�S�	�����		9�#�F�H�5�5�
'���F�%�8�8�8���������08�F�2�=��d���,�,�-���F�%�0�0�0���	+��	+��	+�2E�2G�2G�	+�����R�a�R� 0�&��!��*�=�=�
+�&�(�(�+��+�#�[�[�]�]�F�-2�F�L�*�*�#�[�[�]�]�F��
rFc��|jSr_)r�rBs rD�emptyzIndexOpsMixin.empty�s���9�}�rF�max�min�largest)�op�opposerrTr��AxisInt | None�skipnac�>�|j}tj|��tj|||��}t	|t
��r||sf|������r@tj	dt|��j�d�tt�����dS|���Stj||���}|dkr>tj	dt|��j�d�tt�����|S)ab
        Return int position of the {value} value in the Series.

        If the {op}imum is achieved in multiple locations,
        the first row position is returned.

        Parameters
        ----------
        axis : {{None}}
            Unused. Parameter needed for compatibility with DataFrame.
        skipna : bool, default True
            Exclude NA/null values when showing the result.
        *args, **kwargs
            Additional arguments and keywords for compatibility with NumPy.

        Returns
        -------
        int
            Row position of the {op}imum value.

        See Also
        --------
        Series.arg{op} : Return position of the {op}imum value.
        Series.arg{oppose} : Return position of the {oppose}imum value.
        numpy.ndarray.arg{op} : Equivalent method for numpy arrays.
        Series.idxmax : Return index label of the maximum values.
        Series.idxmin : Return index label of the minimum values.

        Examples
        --------
        Consider dataset containing cereal calories

        >>> s = pd.Series({{'Corn Flakes': 100.0, 'Almond Delight': 110.0,
        ...                'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}})
        >>> s
        Corn Flakes              100.0
        Almond Delight           110.0
        Cinnamon Toast Crunch    120.0
        Cocoa Puff               110.0
        dtype: float64

        >>> s.argmax()
        2
        >>> s.argmin()
        0

        The maximum cereal calories is the third element and
        the minimum cereal calories is the first element,
        since series is zero-indexed.
        �The behavior of �x.argmax/argmin with skipna=False and NAs, or with all-NAs is deprecated. In a future version this will raise ValueError.��
stacklevelr��r�)r�r��validate_minmax_axis�validate_argmax_with_skipnar{r*r#�any�warnings�warnrAra�
FutureWarningr�argmaxr&�	nanargmax�rCr�r�r�r��delegater�s       rDr�zIndexOpsMixin.argmax�s6��l�<��
���%�%�%��/���f�E�E���h��/�/�	��

)�h�m�m�o�o�1�1�3�3�

)��
�F�t�D�z�z�':�F�F�F�"�/�1�1������r����(�(�(��%�h�v�>�>�>�F���|�|��
�F�t�D�z�z�':�F�F�F�"�/�1�1������MrF�smallestc�>�|j}tj|��tj|||��}t	|t
��r||sf|������r@tj	dt|��j�d�tt�����dS|���Stj||���}|dkr>tj	dt|��j�d�tt�����|S)Nr�r�r�r�r�)r�r�r��validate_argmin_with_skipnar{r*r#r�r�r�rArar�r�argminr&�	nanargminr�s       rDr�zIndexOpsMixin.argmins5���<��
���%�%�%��/���f�E�E���h��/�/�	��

)�h�m�m�o�o�1�1�3�3�

)��
�F�t�D�z�z�':�F�F�F�"�/�1�1������r����(�(�(��%�h�v�>�>�>�F���|�|��
�F�t�D�z�z�':�F�F�F�"�/�1�1������MrFc�4�|j���S)a�
        Return a list of the values.

        These are each a scalar type, which is a Python scalar
        (for str, int, float) or a pandas scalar
        (for Timestamp/Timedelta/Interval/Period)

        Returns
        -------
        list

        See Also
        --------
        numpy.ndarray.tolist : Return the array as an a.ndim-levels deep
            nested list of Python scalars.

        Examples
        --------
        For Series

        >>> s = pd.Series([1, 2, 3])
        >>> s.to_list()
        [1, 2, 3]

        For Index:

        >>> idx = pd.Index([1, 2, 3])
        >>> idx
        Index([1, 2, 3], dtype='int64')

        >>> idx.to_list()
        [1, 2, 3]
        )r�r�rBs rDr�zIndexOpsMixin.tolist"s��D�|�"�"�$�$�$rFr.c���t|jtj��st	|j��St|jjt|jj����S)a�
        Return an iterator of the values.

        These are each a scalar type, which is a Python scalar
        (for str, int, float) or a pandas scalar
        (for Timestamp/Timedelta/Interval/Period)

        Returns
        -------
        iterator

        Examples
        --------
        >>> s = pd.Series([1, 2, 3])
        >>> for x in s:
        ...     print(x)
        1
        2
        3
        )	r{r�r~rr��mapr��ranger�rBs rD�__iter__zIndexOpsMixin.__iter__HsM��,�$�,��
�3�3�	D����%�%�%��t�|�(�%���0A�*B�*B�C�C�CrFc�^�tt|�������S)ak
        Return True if there are any NaNs.

        Enables various performance speedups.

        Returns
        -------
        bool

        Examples
        --------
        >>> s = pd.Series([1, 2, 3, None])
        >>> s
        0    1.0
        1    2.0
        2    3.0
        3    NaN
        dtype: float64
        >>> s.hasnans
        True
        )r�r#r�rBs rD�hasnanszIndexOpsMixin.hasnansds"��2�D��J�J�N�N�$�$�%�%�%rF�convertc��|j}t|t��r|�||���St	j||||���S)a�
        An internal function that maps values using the input
        correspondence (which can be a dict, Series, or function).

        Parameters
        ----------
        mapper : function, dict, or Series
            The input correspondence object
        na_action : {None, 'ignore'}
            If 'ignore', propagate NA values, without passing them to the
            mapping function
        convert : bool, default True
            Try to find better dtype for elementwise function results. If
            False, leave as dtype=object. Note that the dtype is always
            preserved for some extension array dtypes, such as Categorical.

        Returns
        -------
        Union[Index, MultiIndex], inferred
            The output of the mapping function applied to the index.
            If the function returns a tuple with more than one element
            a MultiIndex will be returned.
        )�	na_action)rr)r�r{r*r�r%�	map_array)rC�mapperrr�arrs     rD�_map_valueszIndexOpsMixin._map_valuessM��2�l���c�>�*�*�	8��7�7�6�Y�7�7�7�7��#�C��9�g�V�V�V�VrF�	normalize�sort�	ascending�dropnar5c�6�tj||||||���S)a=	
        Return a Series containing counts of unique values.

        The resulting object will be in descending order so that the
        first element is the most frequently-occurring element.
        Excludes NA values by default.

        Parameters
        ----------
        normalize : bool, default False
            If True then the object returned will contain the relative
            frequencies of the unique values.
        sort : bool, default True
            Sort by frequencies when True. Preserve the order of the data when False.
        ascending : bool, default False
            Sort in ascending order.
        bins : int, optional
            Rather than count values, group them into half-open bins,
            a convenience for ``pd.cut``, only works with numeric data.
        dropna : bool, default True
            Don't include counts of NaN.

        Returns
        -------
        Series

        See Also
        --------
        Series.count: Number of non-NA elements in a Series.
        DataFrame.count: Number of non-NA elements in a DataFrame.
        DataFrame.value_counts: Equivalent method on DataFrames.

        Examples
        --------
        >>> index = pd.Index([3, 1, 2, 3, 4, np.nan])
        >>> index.value_counts()
        3.0    2
        1.0    1
        2.0    1
        4.0    1
        Name: count, dtype: int64

        With `normalize` set to `True`, returns the relative frequency by
        dividing all values by the sum of values.

        >>> s = pd.Series([3, 1, 2, 3, 4, np.nan])
        >>> s.value_counts(normalize=True)
        3.0    0.4
        1.0    0.2
        2.0    0.2
        4.0    0.2
        Name: proportion, dtype: float64

        **bins**

        Bins can be useful for going from a continuous variable to a
        categorical variable; instead of counting unique
        apparitions of values, divide the index in the specified
        number of half-open bins.

        >>> s.value_counts(bins=3)
        (0.996, 2.0]    2
        (2.0, 3.0]      2
        (3.0, 4.0]      1
        Name: count, dtype: int64

        **dropna**

        With `dropna` set to `False` we can also see NaN index values.

        >>> s.value_counts(dropna=False)
        3.0    2
        1.0    1
        2.0    1
        4.0    1
        NaN    1
        Name: count, dtype: int64
        )r
rr	�binsr)r%�value_counts_internal)rCr	r
rrrs      rD�value_countszIndexOpsMixin.value_counts�s1��n�/�������

�
�
�	
rFc��|j}t|tj��s|���}ntj|��}|Sr_)r�r{r~rr;r%�unique1d)rCr�r�s   rDr;zIndexOpsMixin.unique�sA������&�"�*�-�-�	1��]�]�_�_�F�F��(��0�0�F��
rFc�j�|���}|rt|��}t|��S)a�
        Return number of unique elements in the object.

        Excludes NA values by default.

        Parameters
        ----------
        dropna : bool, default True
            Don't include NaN in the count.

        Returns
        -------
        int

        See Also
        --------
        DataFrame.nunique: Method nunique for DataFrame.
        Series.count: Count non-NA/null observations in the Series.

        Examples
        --------
        >>> s = pd.Series([1, 3, 5, 7, 7])
        >>> s
        0    1
        1    3
        2    5
        3    7
        4    7
        dtype: int64

        >>> s.nunique()
        4
        )r;r$r�)rCr�uniqss   rD�nuniquezIndexOpsMixin.nuniques3��F���
�
���	/�'��.�.�E��5�z�z�rFc�P�|�d���t|��kS)a.
        Return boolean if values in the object are unique.

        Returns
        -------
        bool

        Examples
        --------
        >>> s = pd.Series([1, 2, 3])
        >>> s.is_unique
        True

        >>> s = pd.Series([1, 2, 3, 1])
        >>> s.is_unique
        False
        F)r)rr�rBs rD�	is_uniquezIndexOpsMixin.is_unique0s#��&�|�|�5�|�)�)�S��Y�Y�6�6rFc�.�ddlm}||��jS)aY
        Return boolean if values in the object are monotonically increasing.

        Returns
        -------
        bool

        Examples
        --------
        >>> s = pd.Series([1, 2, 2])
        >>> s.is_monotonic_increasing
        True

        >>> s = pd.Series([3, 2, 1])
        >>> s.is_monotonic_increasing
        False
        r�r4)�pandasr4�is_monotonic_increasing�rCr4s  rDrz%IndexOpsMixin.is_monotonic_increasingE�'��&	!� � � � � ��u�T�{�{�2�2rFc�.�ddlm}||��jS)a\
        Return boolean if values in the object are monotonically decreasing.

        Returns
        -------
        bool

        Examples
        --------
        >>> s = pd.Series([3, 2, 2, 1])
        >>> s.is_monotonic_decreasing
        True

        >>> s = pd.Series([1, 2, 3])
        >>> s.is_monotonic_decreasing
        False
        rr)rr4�is_monotonic_decreasingrs  rDrz%IndexOpsMixin.is_monotonic_decreasing\rrFrXc�$�t|jd��r|j�|���S|jj}|rQt	|j��r=ts6ttj	|j
��}|tj|��z
}|S)a�
        Memory usage of the values.

        Parameters
        ----------
        deep : bool, default False
            Introspect the data deeply, interrogate
            `object` dtypes for system-level memory consumption.

        Returns
        -------
        bytes used

        See Also
        --------
        numpy.ndarray.nbytes : Total bytes consumed by the elements of the
            array.

        Notes
        -----
        Memory usage does not include memory consumed by elements that
        are not components of the array if deep=False or if used on PyPy

        Examples
        --------
        >>> idx = pd.Index([1, 2, 3])
        >>> idx.memory_usage()
        24
        rVrW)
rPr�rVr�rr�rrr~rr�r�memory_usage_of_objects)rCrX�vr�s    rD�
_memory_usagezIndexOpsMixin._memory_usagess���>�4�:�~�.�.�	��:�*�*��+���
�
�J����	5�O�D�J�/�/�	5��	5��"�*�d�l�3�3�F�
��,�V�4�4�4�A��rFr8z�            sort : bool, default False
                Sort `uniques` and shuffle `codes` to maintain the
                relationship.
            )r��order�	size_hintr
�use_na_sentinel�"tuple[npt.NDArray[np.intp], Index]c�p�tj|j||���\}}|jtjkr|�tj��}t|t��r|�
|��}n5ddlm}	|||j���}n#t$r||��}YnwxYw||fS)N)r
r&rrr�)r%�	factorizer�r�r~�float16�astype�float32r{r!rErr4�NotImplementedError)rCr
r&�codes�uniquesr4s      rDr)zIndexOpsMixin.factorize�s���$$�-��L�t�_�
�
�
���w��=�B�J�&�&��n�n�R�Z�0�0�G��d�M�*�*�	)��'�'��0�0�G�G�$�$�$�$�$�$�
)��%��t�z�:�:�:����&�
)�
)�
)� �%��.�.����
)�����g�~�s�B�B1�0B1a
        Find indices where elements should be inserted to maintain order.

        Find the indices into a sorted {klass} `self` such that, if the
        corresponding elements in `value` were inserted before the indices,
        the order of `self` would be preserved.

        .. note::

            The {klass} *must* be monotonically sorted, otherwise
            wrong locations will likely be returned. Pandas does *not*
            check this for you.

        Parameters
        ----------
        value : array-like or scalar
            Values to insert into `self`.
        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 `self` into ascending
            order. They are typically the result of ``np.argsort``.

        Returns
        -------
        int or array of int
            A scalar or array of insertion points with the
            same shape as `value`.

        See Also
        --------
        sort_values : Sort by the values along either axis.
        numpy.searchsorted : Similar method from NumPy.

        Notes
        -----
        Binary search is used to find the required insertion points.

        Examples
        --------
        >>> ser = pd.Series([1, 2, 3])
        >>> ser
        0    1
        1    2
        2    3
        dtype: int64

        >>> ser.searchsorted(4)
        3

        >>> ser.searchsorted([0, 4])
        array([0, 3])

        >>> ser.searchsorted([1, 3], side='left')
        array([0, 2])

        >>> ser.searchsorted([1, 3], side='right')
        array([1, 3])

        >>> ser = pd.Series(pd.to_datetime(['3/11/2000', '3/12/2000', '3/13/2000']))
        >>> ser
        0   2000-03-11
        1   2000-03-12
        2   2000-03-13
        dtype: datetime64[ns]

        >>> ser.searchsorted('3/14/2000')
        3

        >>> ser = pd.Categorical(
        ...     ['apple', 'bread', 'bread', 'cheese', 'milk'], ordered=True
        ... )
        >>> ser
        ['apple', 'bread', 'bread', 'cheese', 'milk']
        Categories (4, object): ['apple' < 'bread' < 'cheese' < 'milk']

        >>> ser.searchsorted('bread')
        1

        >>> ser.searchsorted(['bread'], side='right')
        array([3])

        If the values are not monotonically sorted, wrong locations
        may be returned:

        >>> ser = pd.Series([2, 1, 3])
        >>> ser
        0    2
        1    1
        2    3
        dtype: int64

        >>> ser.searchsorted(1)  # doctest: +SKIP
        0  # wrong result, correct would be 1
        �searchsorted.rrr2�side�Literal['left', 'right']�sorterr0�np.intpc��dSr_rs�rCrrr1r3s    rDr0zIndexOpsMixin.searchsorted,�	��	�rF�npt.ArrayLike | ExtensionArray�npt.NDArray[np.intp]c��dSr_rsr6s    rDr0zIndexOpsMixin.searchsorted5r7rFr4)r9�left�$NumpyValueArrayLike | ExtensionArray�NumpySorter | None�npt.NDArray[np.intp] | np.intpc��t|t��r'dt|��j�d�}t	|���|j}t|tj��s|�|||���Stj||||���S)Nz(Value must be 1-D array-like or scalar, z is not supported)r1r3)
r{rrArar�r�r~rr0r%)rCrrr1r3�msgr�s      rDr0zIndexOpsMixin.searchsorted>s����e�\�*�*�	"�;���;�;�'�;�;�;�
��S�/�/�!�����&�"�*�-�-�	H��&�&�u�4��&�G�G�G��&�����	
�
�
�	
rF�first��keeprCr/c�@�|�|���}||S�NrB)�_duplicated)rCrCr<s   rD�drop_duplicateszIndexOpsMixin.drop_duplicatesXs%���%�%�4�%�0�0�
��Z�K� � rF�npt.NDArray[np.bool_]c��|j}t|t��r|�|���St	j||���SrE)r�r{r*r<r%)rCrCrs   rDrFzIndexOpsMixin._duplicated]sE���l���c�>�*�*�	-��>�>�t�>�,�,�,��$�S�t�4�4�4�4rFc���tj||��}|j}t|dd���}tj||j��}t
|��}t|t��r%tj
|j|j|j
��}tjd���5tj|||��}ddd��n#1swxYwY|�||���S)NT)�
extract_numpy�
extract_range�ignore)�all)r�)r'�get_op_result_namer�r,�maybe_prepare_scalar_for_opr�r+r{r�r~�arange�start�stop�step�errstate�
arithmetic_op�_construct_result)rC�otherr��res_name�lvalues�rvaluesr�s       rD�
_arith_methodzIndexOpsMixin._arith_methodds���)�$��6�6���,����T��N�N�N���1�'�7�=�I�I��0��9�9���g�u�%�%�	K��i��
�w�|�W�\�J�J�G�
�[�X�
&�
&�
&�	=�	=��&�w���<�<�F�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=��%�%�f�8�%�<�<�<s�'C
�
C�Cc� �t|���)z~
        Construct an appropriately-wrapped result from the ArrayLike result
        of an arithmetic-like operation.
        r)rCr�r�s   rDrWzIndexOpsMixin._construct_resultss��
"�$�'�'�'rF)rGr)rGr�)rGr)rGrr`)rGr*)r�r�r�r�r�rJrGr�)rGr�)NT)r�r�r�r�rGrT)rGr.)rr�)FTFNT)
r	r�r
r�rr�rr�rGr5)T)rr�rGrT)F)rXr�rGrT)FT)r
r�r&r�rGr')..)rrr2r1r2r3r0rGr4)rrr8r1r2r3r0rGr9)r;N)rrr<r1r2r3r=rGr>)rCr/)rA)rCr/rGrH)4rarbrcrd�__array_priority__�	frozensetr�rerfr�r�r	r��Tr�r�r�r�r�r�r�rr�r�r�rr�r�r��to_listr�rrrrr;rrrrr#r%r)�textwrap�dedentr6r
r0rGrFr\rWrsrFrDr7r7sp���������
��$-�I�	�
�%�%�M������(�(�(��X�(��(�(�(��X�(��	�	�	��U�	�	���
�	�	�	�A�:�
"�
"�
"��X�
"�(�(�(�(������X��2�S�S��U�S�<�#�#�#��X�#�6�!�!�!��X�!�6�>(�>(�>(��X�>(�@�'+���>�	C�C�C�C��U�C�J�
�����X��U��	�S�E�%�y�1�1�1�:>�Q�Q�Q�Q�2�1�Q�f	�S��E�%�z�:�:�:�:>�����;�:��B"%�"%�"%�H�G�D�D�D�D�8�&�&�&��^�&�4�W�W�W�W��U�W�>� ���
��
]
�]
�]
�]
��U�]
�~����%�%�%�%��U�%�N�7�7�7��X�7�(�3�3�3��X�3�,�3�3�3��X�3�,�'�'�'�'��U�'�R	�S������
�X�_�
�
�
����� $��������6`	����R�*-�!�	�����X���*-�!�	�����X��	�S��n�	%�W�5�5�5�*0�%)�	
�
�
�
�6�5�
�23:�!�!�!�!�!�!�
�5�5�5�5��U�5�
=�
=�
=�(�(�(�(�(rF)Urd�
__future__rrb�typingrrrrrr	r
r��numpyr~�pandas._configr�pandas._libsr�pandas._typingr
rrrrrr�
pandas.compatr�pandas.compat.numpyrr��
pandas.errorsr�pandas.util._decoratorsrr�pandas.util._exceptionsr�pandas.core.dtypes.castr�pandas.core.dtypes.commonrr�pandas.core.dtypes.dtypesr�pandas.core.dtypes.genericrr r!r"�pandas.core.dtypes.missingr#r$�pandas.corer%r&r'�pandas.core.accessorr(�pandas.core.arrayliker)�pandas.core.arraysr*�pandas.core.constructionr+r,�collections.abcr-r.r/r0r1r2rr3r4r5r6re�_indexops_doc_kwargsr>rirur7rsrFrD�<module>r{sn�����#�"�"�"�"�"�������������������������������.�.�.�.�.�.�������������������������������.�.�.�.�.�.�-�-�-�-�-�-���������5�4�4�4�4�4�4�4�4�4�4�4���������5�4�4�4�4�4���������������������
����������
/�.�.�.�.�.�*�*�*�*�*�*�-�-�-�-�-�-���������
����������
���������������������� "��!�!�!�!�
���!�	���,$�,$�,$�,$�,$�=�,$�,$�,$�^-�-�-�-�-�-�-�-�Dd�d�d�d�d�W�X�&�d�d�d�N[(�[(�[(�[(�[(�H�[(�[(�[(�[(�[(rF