
    `Vg                        U d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
mZmZmZ ddlZddlZddlmc mZ ddlmZmZmZmZmZmZ ddlmZ ddlmZ ddl m!Z! dd	l"m#Z#m$Z$ dd
l%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZCmDZDmEZE erddlmFZFmGZGmHZH ddlImJZJmKZK i ZLdeMd<   dddddZN e
dd      ZO G d de9      ZP G d d       ZQ G d! d"ee         ZR G d# de?      ZSy)$z.
Base and utility classes for pandas objects.
    )annotationsN)	TYPE_CHECKINGAnyGenericHashableLiteralTypeVarcastfinaloverload)	ArrayLikeDtypeObj
IndexLabelNDFrameTShapenpt)PYPY)functionAbstractMethodError)cache_readonlydoc)find_stack_level)is_categorical_dtypeis_dict_likeis_extension_array_dtypeis_object_dtype	is_scalar)ABCDataFrameABCIndex	ABCSeries)isnaremove_na_arraylike)
algorithmsnanopsops)DirNamesMixin)
duplicatedunique1dvalue_counts)OpsMixin)ExtensionArray)!create_series_with_explicit_dtypeensure_wrapped_if_datetimelikeextract_array)NumpySorterNumpyValueArrayLikeScalarLike_co)CategoricalSerieszdict[str, str]_shared_docsIndexOpsMixin )klassinplaceuniquer(   _T)boundc                  R     e Zd ZU dZded<   ed        ZddZd	d
dZd fdZ	 xZ
S )PandasObjectz/
    Baseclass for various pandas objects.
    zdict[str, Any]_cachec                    t        |       S )zJ
        Class constructor (for this class it's just `__class__`.
        )typeselfs    Q/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/pandas/core/base.py_constructorzPandasObject._constructorn   s    
 Dz    c                ,    t         j                  |       S )zI
        Return a string representation for a particular object.
        )object__repr__rB   s    rD   rI   zPandasObject.__repr__u   s    
 t$$rF   c                    t        | d      sy|| j                  j                          y| j                  j                  |d       y)zV
        Reset cached properties. If ``key`` is passed, only clears that key.
        r?   N)hasattrr?   clearpop)rC   keys     rD   _reset_cachezPandasObject._reset_cache|   s8     tX&;KKKKOOC&rF   c                    t        | dd      }|r3 |d      }t        t        |      r|      S |j                               S t        |          S )zx
        Generates the total memory usage for an object that returns
        either a value or Series of values
        memory_usageNTdeep)getattrintr   sumsuper
__sizeof__)rC   rQ   mem	__class__s      rD   rX   zPandasObject.__sizeof__   sO    
 t^T:D)Cins<<#'')<< w!##rF   )returnstrN)rN   z
str | Noner[   Noner[   rU   )__name__
__module____qualname____doc____annotations__propertyrE   rI   rO   rX   __classcell__)rZ   s   @rD   r>   r>   f   s6    
  %	'$ $rF   r>   c                      e Zd ZdZd ZddZy)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)`.
    c                2    t         j                  | dd       y)z9
        Prevents setting additional attributes.
        __frozenTN)rH   __setattr__rB   s    rD   _freezezNoNewAttributesMixin._freeze   s     	4T2rF   c                    t        | dd      r8|dk(  s3|t        |       j                  v st        | |d       t        d| d      t        j                  | ||       y )Nrj   Fr?   z"You cannot add any new attribute '')rT   rA   __dict__AttributeErrorrH   rk   )rC   rN   values      rD   rk   z NoNewAttributesMixin.__setattr__   s_     4U+8Od4j)))tS$'3 #EcU!!LMM4e,rF   N)rN   r\   r[   r^   )r`   ra   rb   rc   rl   rk    rF   rD   rh   rh      s    	3-rF   rh   c                      e Zd ZU dZded<   dZded<   ded<   d	d
gZ ee      Ze	e
d               Zed        Ze	edd              Ze	ed               Zd ZdddZd ZeZy)SelectionMixinz
    mixin implementing the selection & aggregation interface on a group-like
    object sub-classes need to define: obj, exclusions
    r   objNzIndexLabel | None
_selectionzfrozenset[Hashable]
exclusionsr?   __setstate__c                    t        | j                  t        t        t        t
        t        j                  f      s| j                  gS | j                  S r]   )
isinstancerv   listtupler!   r    npndarrayrB   s    rD   _selection_listzSelectionMixin._selection_list   s=     OOdE9h

K
 OO$$rF   c                    | j                   t        | j                  t              r| j                  S | j                  | j                      S r]   )rv   rz   ru   r!   rB   s    rD   _selected_objzSelectionMixin._selected_obj   s5    ??"j9&E88O88DOO,,rF   c                .    | j                   j                  S r]   )r   ndimrB   s    rD   r   zSelectionMixin.ndim   s     !!&&&rF   c                   | j                   3t        | j                  t              r| j                  | j                     S t        | j                        dkD  r(| j                  j                  | j                  dd      S | j                  S )Nr      T)axis
only_slice)rv   rz   ru   r   r   lenrw   
_drop_axisrB   s    rD   _obj_with_exclusionsz#SelectionMixin._obj_with_exclusions   sl     ??&:dhh+M88D0011t!#
 88&&tQ4&PP88OrF   c                ,   | j                   t        d| j                    d      t        |t        t        t
        t        t        j                  f      rt        | j                  j                  j                  |            t        t        |            k7  rQt        t        |      j                  | j                  j                              }t        dt!        |      dd        | j#                  t        |      d      S t%        | dd	      s9|| j                  j                  vrt        d
|       | j#                  |d      S || j                  vrt        d
|       | j                  |   }|j&                  }| j#                  |||      S )Nz
Column(s) z already selectedzColumns not found: r      )r   as_indexFzColumn not found: )r   subset)rv   
IndexErrorrz   r{   r|   r!   r    r}   r~   r   ru   columnsintersectionset
differenceKeyErrorr\   _gotitemrT   r   )rC   rN   bad_keysr   r   s        rD   __getitem__zSelectionMixin.__getitem__   sR   ??&z$//)::KLMMcD%HbjjIJ488##0056#c#h-GC 3 3DHH4D4D EF!4S]1R5H4IJKK==c=33z51$((***!3C59::==1=-- $(("!3C59::XXc]F;;D==4=??rF   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   )rC   rN   r   r   s       rD   r   zSelectionMixin._gotitem   s     "$''rF   c                    t        |       r]   r   )rC   funcargskwargss       rD   	aggregatezSelectionMixin.aggregate  s    !$''rF   r_   r]   )r   rU   )r`   ra   rb   rc   rd   rv   _internal_namesr   _internal_names_setr   re   r   r   r   r   r   r   r   r   aggrr   rF   rD   rt   rt      s    
 
M$(J!(##0Oo.
   - - '  '   @,(( CrF   rt   c            	         e Zd ZU dZdZ edg      Zded<   ed?d       Z	ed@d       Z
dAdZ eed	
      ZedBd       ZdCdZedDd       Zd ZedCd       ZedCd       ZedEd       Zddej*                  f	 	 	 	 	 	 	 dFdZedGd       ZdHdIdZ eddd      dHdJd       ZdHdIdZ eeddd      dHdCd       Zd  ZeZd! Ze dGd"       Z!dKd#Z"d$dddd%	 dLd&Z#e$dMd'       Z%	 	 	 	 	 dN	 	 	 	 	 	 	 	 	 dOd(Z&d) Z'dPdQd*Z(edGd+       Z)edGd,       Z*edGd-       Z+edGd.       Z,dRdSd/Z- ee.j^                  d0d0d0 e0jb                  d1      2      dej*                  ej*                  f	 	 	 	 	 dTd3       Z/d4e2d5<   e3	 	 dU	 	 	 	 	 	 	 dVd6       Z4e3	 	 dU	 	 	 	 	 	 	 dWd7       Z4 ee2d5   d89      	 	 dX	 	 	 	 	 	 	 dYd:       Z4dZd;Z5e$	 dZ	 	 	 d[d<       Z6d= Z7d> Z8y)\r6   zS
    Common ops mixin to support a unified interface / docs for Series / Index
    i  tolistzfrozenset[str]_hidden_attrsc                    t        |       r]   r   rB   s    rD   dtypezIndexOpsMixin.dtype       "$''rF   c                    t        |       r]   r   rB   s    rD   _valueszIndexOpsMixin._values"  r   rF   c                2    t        j                  ||       | S )zw
        Return the transpose, which is by definition self.

        Returns
        -------
        %(klass)s
        )nvvalidate_transpose)rC   r   r   s      rD   	transposezIndexOpsMixin.transpose'  s     	dF+rF   zD
        Return the transpose, which is by definition self.
        )r   c                .    | j                   j                  S )zE
        Return a tuple of the shape of the underlying data.
        )r   shaperB   s    rD   r   zIndexOpsMixin.shape9  s    
 ||!!!rF   c                    t        |       r]   r   rB   s    rD   __len__zIndexOpsMixin.__len__@  s    !$''rF   c                     y)zO
        Number of dimensions of the underlying data, by definition 1.
        r   rr   rB   s    rD   r   zIndexOpsMixin.ndimD  s    
 rF   c                \    t        |       dk(  rt        t        |             S t        d      )a  
        Return the first element of the underlying data as a Python scalar.

        Returns
        -------
        scalar
            The first element of %(klass)s.

        Raises
        ------
        ValueError
            If the data is not length-1.
        r   z6can only convert an array of size 1 to a Python scalar)r   nextiter
ValueErrorrB   s    rD   itemzIndexOpsMixin.itemK  s*     t9>T
##QRRrF   c                .    | j                   j                  S )zD
        Return the number of bytes in the underlying data.
        )r   nbytesrB   s    rD   r   zIndexOpsMixin.nbytes]  s    
 ||"""rF   c                ,    t        | j                        S )zG
        Return the number of elements in the underlying data.
        )r   r   rB   s    rD   sizezIndexOpsMixin.sized  s    
 4<<  rF   c                    t        |       )aM  
        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 ``.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 PandasArray
        is returned.

        >>> pd.Series([1, 2, 3]).array
        <PandasArray>
        [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']
        r   rB   s    rD   arrayzIndexOpsMixin.arrayk  s    ~ "$''rF   NFc                   t        | j                        r  | j                  j                  |f||d|S |r+t	        |j                               d   }t        d| d      t        j                  | j                  |      }|s|t        j                  urH|j                         }|t        j                  ur&||t        j                  | j                               <   |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.

            .. versionadded:: 1.0.0

        **kwargs
            Additional keywords passed through to the ``to_numpy`` method
            of the underlying array (for extension arrays).

            .. versionadded:: 1.0.0

        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]')
        )copyna_valuer   z/to_numpy() got an unexpected keyword argument 'rn   )r   )r   r   r   to_numpyr{   keys	TypeErrorr}   asarrayr   lib
no_defaultr   
asanyarrayr"   )rC   r   r   r   r   r   results          rD   r   zIndexOpsMixin.to_numpy  s    F $DJJ/&4::&&uU4(UfUUFKKM*1-HA(1M  DLL683>>1[[]Fs~~-5=r}}TYY[12rF   c                    | j                    S r]   )r   rB   s    rD   emptyzIndexOpsMixin.empty  s    99}rF   Tc                    t        j                  |       t        j                  ||       t        j                  | j
                  |      S )a  
        Return the maximum value of the Index.

        Parameters
        ----------
        axis : int, optional
            For compatibility with NumPy. Only 0 or None are allowed.
        skipna : bool, default True
            Exclude NA/null values when showing the result.
        *args, **kwargs
            Additional arguments and keywords for compatibility with NumPy.

        Returns
        -------
        scalar
            Maximum value.

        See Also
        --------
        Index.min : Return the minimum value in an Index.
        Series.max : Return the maximum value in a Series.
        DataFrame.max : Return the maximum values in a DataFrame.

        Examples
        --------
        >>> idx = pd.Index([3, 2, 1])
        >>> idx.max()
        3

        >>> idx = pd.Index(['c', 'b', 'a'])
        >>> idx.max()
        'c'

        For a MultiIndex, the maximum is determined lexicographically.

        >>> idx = pd.MultiIndex.from_product([('a', 'b'), (2, 1)])
        >>> idx.max()
        ('b', 2)
        skipna)r   validate_minmax_axisvalidate_maxr%   nanmaxr   rC   r   r   r   r   s        rD   maxzIndexOpsMixin.max#  6    P 	%
f%}}T\\&99rF   r   minlargest)opopposerq   c                "   | j                   }t        j                  |       t        j                  |||      }t	        |t
              r1|s|j                         j                         ry|j                         S t        j                  ||      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.
        r   r   )r   r   r   validate_argmax_with_skipnarz   r,   r"   anyargmaxr%   	nanargmaxrC   r   r   r   r   delegates         rD   r   zIndexOpsMixin.argmaxO  sx    h <<
%//fEh/hmmo113(( ## rF   c                    t        j                  |       t        j                  ||       t        j                  | j
                  |      S )a  
        Return the minimum value of the Index.

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

        Returns
        -------
        scalar
            Minimum value.

        See Also
        --------
        Index.max : Return the maximum value of the object.
        Series.min : Return the minimum value in a Series.
        DataFrame.min : Return the minimum values in a DataFrame.

        Examples
        --------
        >>> idx = pd.Index([3, 2, 1])
        >>> idx.min()
        1

        >>> idx = pd.Index(['c', 'b', 'a'])
        >>> idx.min()
        'a'

        For a MultiIndex, the minimum is determined lexicographically.

        >>> idx = pd.MultiIndex.from_product([('a', 'b'), (2, 1)])
        >>> idx.min()
        ('a', 1)
        r   )r   r   validate_minr%   nanminr   r   s        rD   r   zIndexOpsMixin.min  r   rF   smallestc                "   | j                   }t        j                  |       t        j                  |||      }t	        |t
              r1|s|j                         j                         ry|j                         S t        j                  ||      S )Nr   r   )r   r   r   validate_argmin_with_skipnarz   r,   r"   r   argminr%   	nanargminr   s         rD   r   zIndexOpsMixin.argmin  su    <<
%//fEh/hmmo113(( ## rF   c                6    | j                   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.
        )r   r   rB   s    rD   r   zIndexOpsMixin.tolist  s    " ||""$$rF   c                    t        | j                  t        j                        st	        | j                        S t        | j                  j                  t        | j                  j                              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
        )	rz   r   r}   r~   r   mapr   ranger   rB   s    rD   __iter__zIndexOpsMixin.__iter__  sK     $,,

3%%t||((%0A0A*BCCrF   c                F    t        t        |       j                               S )zc
        Return True if there are any NaNs.

        Enables various performance speedups.
        )boolr"   r   rB   s    rD   hasnanszIndexOpsMixin.hasnans  s     DJNN$%%rF   c                ,    t        | j                        S r]   )r"   r   rB   s    rD   r"   zIndexOpsMixin.isna  s    DLL!!rF   r   )r   r   numeric_onlyfilter_typec               z    t        | |d      }|#t        t        |       j                   d|        |dd|i|S )zA
        Perform the reduction type operation if we can.
        Nz cannot perform the operation r   rr   )rT   r   rA   r`   )	rC   r   namer   r   r   r   kwdsr   s	            rD   _reducezIndexOpsMixin._reduce  sS     tT4(<:&&''EdVL  *6*T**rF   c                d  	 t        |      r?t        |t              rt        |d      r|		fd}nt	        |t
        j                        }t        |t              r|dvrd| d}t        |      |dk(  r||j                  j                            }t        | j                        r't        d| j                        }|j                  |      S | j                  }|j                  j!                  |      }t#        j$                  |j                  |      }|S t'        | j                        r.t        | j                  d	      r| j                  }|t(        d
 }nL| j                  j+                  t,              }|dk(  rd }n$|t.        j0                  }nd| d}t        |       |||      }|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

        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.
        __missing__c                    |    S r]   rr   )xdict_with_defaults    rD   <lambda>z+IndexOpsMixin._map_values.<locals>.<lambda>9  s    #4Q#7 rF   )dtype_if_empty)Nignorez+na_action must either be 'ignore' or None, z was passedr   r3   r   c                $    | j                  |      S r]   )r   valuesfs     rD   r   z+IndexOpsMixin._map_values.<locals>.<lambda>i  s    fjjm rF   c                |    t        j                  | |t        |       j                  t        j
                              S r]   )r   map_infer_maskr"   viewr}   uint8r   s     rD   r   z+IndexOpsMixin._map_values.<locals>.<lambda>m  s+    #*<*<AtF|00:+ rF   )r   rz   dictrK   r-   r}   float64r!   r   indexnotnar   r   r
   r   r   get_indexerr$   take_ndr   NotImplementedErrorastyperH   r   	map_infer)
rC   mapper	na_actionmsgcatr   indexer
new_valuesmap_fr   s
            @rD   _map_valueszIndexOpsMixin._map_values  s   0 &$'GFM,J %+!7 ;2:: fi( 00A k.  !o%H$ 2 2 45 $DJJ/ =$,,7wwv&\\Fll..v6G#++FNNGDJ $DJJ/GDLL%4P\\F$))3E\\((0FH$ " B k.  !o% 66*
rF   c                $    t        | |||||      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.
        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
        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
        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
        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
        dtype: int64
        )sort	ascending	normalizebinsdropna)r*   )rC   r  r  r  r  r  s         rD   r*   zIndexOpsMixin.value_counts~  s$    l 
 	
rF   c                N   | j                   }t        |t        j                        ss|j	                         }t        | j
                  t        j
                        r=| j
                  j                  dv r%t        | t              rt        j                  |      }|S t        |      }|S )N)mM)
r   rz   r}   r~   r:   r   kindr!   r   r)   )rC   r   r   s      rD   r:   zIndexOpsMixin.unique  sw    &"**- &F4::rxx0TZZ__
5RT9- F+  f%FrF   c                R    | j                         }|rt        |      }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   )rC   r  uniqss      rD   nuniquezIndexOpsMixin.nunique  s'    D '.E5zrF   c                >    | j                  d      t        |       k(  S )zr
        Return boolean if values in the object are unique.

        Returns
        -------
        bool
        F)r  )r#  r   rB   s    rD   	is_uniquezIndexOpsMixin.is_unique  s     ||5|)SY66rF   c                b    t        j                  dt        t                      | j                  S )a$  
        Return boolean if values in the object are monotonically increasing.

        .. deprecated:: 1.5.0
            is_monotonic is deprecated and will be removed in a future version.
            Use is_monotonic_increasing instead.

        Returns
        -------
        bool
        zhis_monotonic is deprecated and will be removed in a future version. Use is_monotonic_increasing instead.)
stacklevel)warningswarnFutureWarningr   is_monotonic_increasingrB   s    rD   is_monotoniczIndexOpsMixin.is_monotonic  s,     	3')		
 +++rF   c                2    ddl m}  ||       j                  S )z
        Return boolean if values in the object are monotonically increasing.

        Returns
        -------
        bool
        r   Index)pandasr/  r+  rC   r/  s     rD   r+  z%IndexOpsMixin.is_monotonic_increasing4       	!T{222rF   c                2    ddl m}  ||       j                  S )z
        Return boolean if values in the object are monotonically decreasing.

        Returns
        -------
        bool
        r   r.  )r0  r/  is_monotonic_decreasingr1  s     rD   r4  z%IndexOpsMixin.is_monotonic_decreasingA  r2  rF   c                4   t        | j                  d      r| j                  j                  |      S | j                  j                  }|rMt	        |       rBt
        s<t        t        j                  | j                        }|t        j                  |      z  }|S )aN  
        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
        rQ   rR   )rK   r   rQ   r   r   r   r
   r}   r~   r   r   memory_usage_of_objects)rC   rS   vr   s       rD   _memory_usagezIndexOpsMixin._memory_usageN  su    0 4::~. ::***55JJOD)$"**dll3F,,V44ArF   r7   z            sort : bool, default False
                Sort `uniques` and shuffle `codes` to maintain the
                relationship.
            )r   order	size_hintr  c                4    t        j                  | |||      S )N)r  na_sentineluse_na_sentinel)r$   	factorize)rC   r  r<  r=  s       rD   r>  zIndexOpsMixin.factorizeq  s     & ##to
 	
rF   a  
        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
        searchsortedc                     y r]   rr   rC   rq   sidesorters       rD   r?  zIndexOpsMixin.searchsorted  s     	rF   c                     y r]   rr   rA  s       rD   r?  zIndexOpsMixin.searchsorted  s     	rF   r/  )r8   c                    | j                   }t        |t        j                        s|j	                  |||      S t        j                  ||||      S )N)rB  rC  )r   rz   r}   r~   r?  r$   )rC   rq   rB  rC  r   s        rD   r?  zIndexOpsMixin.searchsorted  sR     &"**-&&u4&GG&&	
 	
rF   c                2    | j                  |      }| |    S N)keep)_duplicated)rC   rH  r(   s      rD   drop_duplicateszIndexOpsMixin.drop_duplicates  s"    %%4%0
ZK  rF   c                0    t        | j                  |      S rG  )r(   r   )rC   rH  s     rD   rI  zIndexOpsMixin._duplicated  s     $,,T22rF   c                b   t        j                  | |      }| j                  }t        |dd      }t        j                  ||j
                        }t        |      }t        j                  d      5  t        j                  |||      }d d d        | j                  |      S # 1 sw Y   xY w)NT)extract_numpyextract_ranger   )all)r   )r&   get_op_result_namer   r/   maybe_prepare_scalar_for_opr   r.   r}   errstatearithmetic_op_construct_result)rC   otherr   res_namelvaluesrvaluesr   s          rD   _arith_methodzIndexOpsMixin._arith_method$  s    ))$6,,TN11'7==I09[[X& 	=&&w<F	= %%f8%<<	= 	=s   2B%%B.c                    t        |       )z~
        Construct an appropriately-wrapped result from the ArrayLike result
        of an arithmetic-like operation.
        r   )rC   r   r   s      rD   rT  zIndexOpsMixin._construct_result1  s    
 "$''rF   )r[   r   )r[   zExtensionArray | np.ndarray)rC   r;   r[   r;   )r[   r   r_   )r[   z
Literal[1])r[   r,   )r   znpt.DTypeLike | Noner   r   r   rH   r[   z
np.ndarray)r[   r   )NT)r   r   )r   r   r[   rU   )r[   npt.NDArray[np.bool_])r   r\   r]   )FTFNT)
r  r   r  r   r  r   r  r   r[   r4   )T)r  r   r[   rU   )F)rS   r   r[   rU   )r  r   r<  zint | lib.NoDefaultr=  zbool | lib.NoDefault)..)rq   r2   rB  Literal['left', 'right']rC  r0   r[   znp.intp)rq   znpt.ArrayLike | ExtensionArrayrB  r\  rC  r0   r[   znpt.NDArray[np.intp])leftN)rq   z$NumpyValueArrayLike | ExtensionArrayrB  r\  rC  r0   r[   znpt.NDArray[np.intp] | np.intp)first)rH  zLiteral['first', 'last', False]r[   r[  )9r`   ra   rb   rc   __array_priority__	frozensetr   rd   re   r   r   r   Tr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   to_listr   r   r   r"   r   r   r  r*   r:   r#  r%  r,  r+  r4  r8  r$   r>  textwrapdedentr5   r   r?  rJ  rI  rY  rT  rr   rF   rD   r6   r6     s   
 $-	
%M>  ( ( ( (	 		A " "(  S$ # # ! ! >( >(D '+>>	q#q q 	q 
qf  *:X 	E%y1A 2AF*:X 	E%z: ;"%& GD& & &" + +* _ _F  ]
]
 ]
 	]
 ]
 
]
~ %N 7 7 , ,( 
3 
3 
3 
3!F 	X__
 +.>>03	

 )
 .	

`	 N  *-!	 ' 	
 
 
  *-!	- ' 	
 
  	n	%W5 *0"	
3
 '
 	

 
(
 6
&!
 6=333	3 3
=(rF   )Trc   
__future__r   rc  typingr   r   r   r   r   r	   r
   r   r   r(  numpyr}   pandas._libs.lib_libsr   pandas._typingr   r   r   r   r   r   pandas.compatr   pandas.compat.numpyr   r   pandas.errorsr   pandas.util._decoratorsr   r   pandas.util._exceptionsr   pandas.core.dtypes.commonr   r   r   r   r   pandas.core.dtypes.genericr   r    r!   pandas.core.dtypes.missingr"   r#   pandas.corer$   r%   r&   pandas.core.accessorr'   pandas.core.algorithmsr(   r)   r*   pandas.core.arrayliker+   pandas.core.arraysr,   pandas.core.constructionr-   r.   r/   r0   r1   r2   r0  r3   r4   r5   rd   _indexops_doc_kwargsr;   r>   rh   rt   r6   rr   rF   rD   <module>rz     s   # 
 
 
       . - 5  

 
 / 
 + -     "n !!	  T),$= ,$^- -DXWX& Xvd(H d(rF   