§
    Ï! h�×  ã                  óþ  — d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	m
Z
 ddlZddlZddlmZmZmZ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 m!Z! ddl"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/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? ddl@mAZAmBZB ddlCmDZD ddlEmFZGmHZHmIZI ddlJmKZK erddlmLZLmMZMmNZN ddlOmPZPmQZQmRZR ddlSmTZTmUZU dzd„ZVd{d„ZWd|d"„ZXejY        ejZ        ej[        ej\        ej]        ej^        ej_        ej`        eja        ejb        ejc        ejd        eje        ejf        d#œZgd}d$„Zhd~d%„Zid&„ Zjdd(„Zkd€d�d+„ZlejZmd,Znd‚d0„Zo	 	 	 	 dƒd„d9„Zp e ed:¦  «         ed;¦  «         ed<¦  «        ¬=¦  «        	 	 	 d…d†dA„¦   «         Zq	 	 	 	 	 d‡dˆdF„Zr	 	 	 	 	 d‡dˆdG„Zs	 d€d‰dI„Zt	 	 dŠd‹dM„Zu	 dŒd�dN„Zv	 	 	 	 	 dŽd�dV„Zw	 	 	 d�d‘dZ„Zx	 	 d’d“dd„Zyh de£Zzd”d•dg„Z{	 	 	 	 d–d—dn„Z|d˜do„Z}d™dp„Z~dšdt„Z	 	 d›dœdy„Z€dS )�zl
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ÚExtensionArrayÚvaluesr   Úreturnú
np.ndarrayc                óÜ  — t          | t          ¦  «        st          | d¬¦  «        } t          | j        ¦  «        r!t          t          j        | ¦  «        ¦  «        S t          | j        t          ¦  «        r?t          d| ¦  «        } | j
        st          | j        ¦  «        S t          j        | ¦  «        S t          | j        t          ¦  «        rt          d| ¦  «        } | j        S t          | j        ¦  «        rjt          | t          j        ¦  «        r't          j        | ¦  «                             d¦  «        S t          j        | ¦  «                             dd¬¦  «        S t'          | j        ¦  «        rt          j        | ¦  «        S t)          | j        ¦  «        r1| j        j        dv rt-          | ¦  «        S t          j        | ¦  «        S t/          | j        ¦  «        rt          t          j        | ¦  «        S t1          | j        ¦  «        r1|                      d	¦  «        }t          t          j        |¦  «        }|S t          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-   r5   r"   rM   r   ÚnpÚasarrayr&   r   Ú_hasnaÚ_ensure_dataÚ_datar'   Úcodesr   ÚndarrayÚviewÚastyper    r   Úitemsizer   r   r$   Úobject)r?   Únpvaluess     úPc:\xampp_lite_8_4\www\timesheet\venv\Lib\site-packages\pandas/core/algorithms.pyrR   rR   j   s!  € õ, �f�mÑ,Ô,ð ;å˜v°TÐ:Ñ:Ô:ˆå�v”|Ñ$Ô$ð -Ý�RœZ¨Ñ/Ô/Ñ0Ô0Ð0å	�F”L¥/Ñ	2Ô	2ð *åÐ'¨Ñ0Ô0ˆØŒ}ð 	.õ   ¤Ñ-Ô-Ð-ÝŒz˜&Ñ!Ô!Ð!å	�F”LÕ"2Ñ	3Ô	3ð !õ �m VÑ,Ô,ˆØŒ|Ðå	�v”|Ñ	$Ô	$ð Ý�f�bœjÑ)Ô)ð 	Bå”:˜fÑ%Ô%×*Ò*¨7Ñ3Ô3Ð3õ ”:˜fÑ%Ô%×,Ò,¨W¸5Ð,ÑAÔAÐAå	˜&œ,Ñ	'Ô	'ð ÝŒz˜&Ñ!Ô!Ð!å	˜œÑ	%Ô	%ð ð Œ<Ô  KÐ/Ð/å! &Ñ)Ô)Ð)ÝŒz˜&Ñ!Ô!Ð!å	˜&œ,Ñ	'Ô	'ð Ý•B”J Ñ'Ô'Ð'õ 
˜Vœ\Ñ	*Ô	*ð Ø—;’;˜tÑ$Ô$ˆÝ�œ
 HÑ-Ô-ˆØˆõ ŒZ˜¥fÐ-Ñ-Ô-€FÝ˜Ñ Ô Ð ó    rM   r   Úoriginalr   c                ó  — t          | t          ¦  «        r| j        |k    r| S t          |t          j        ¦  «        s,|                     ¦   «         }|                     | |¬¦  «        } n|                      |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
    rL   FrF   )rN   r+   rM   rO   Úconstruct_array_typeÚ_from_sequencerW   )r?   rM   r]   Úclss       r[   Ú_reconstruct_datarb   ¸   s…   € õ  �&Õ+Ñ,Ô,ð °´ÀÒ1FÐ1Fàˆå�e�RœXÑ&Ô&ð 2ð ×(Ò(Ñ*Ô*ˆà×#Ò# F°%Ð#Ñ8Ô8ˆˆð —’˜u¨5�Ñ1Ô1ˆà€Mr\   Ú	func_nameÚstrc                ó†  — t          | t          t          t          t          j        f¦  «        s“|dk    r+t          j        |› d�t          t          ¦   «         ¬¦  «         t          j        | d¬¦  «        }|dv r4t          | t          ¦  «        rt          | ¦  «        } t          | ¦  «        } nt	          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)rN   r,   r.   r+   rO   rU   ÚwarningsÚwarnÚFutureWarningr   r   Úinfer_dtypeÚtupleÚlistr   rP   )r?   rc   Úinferreds      r[   Ú_ensure_arraylikeru   Ù   sÈ   € õ �f�x­Õ4EÅrÄzÐRÑSÔSð (à˜Ò&Ð&åŒMØð "ð "ð "õ Ý+Ñ-Ô-ðñ ô ð õ ”? 6°%Ð8Ñ8Ô8ˆØÐ;Ð;Ð;å˜&¥%Ñ(Ô(ð &Ý˜f™œ�Ý<¸VÑDÔDˆFˆFå”Z Ñ'Ô'ˆFØ€Mr\   )Ú
complex128Ú	complex64Úfloat64Úfloat32Úuint64Úuint32Úuint16rE   Úint64Úint32Úint16Úint8rl   rY   c                ó`   — t          | ¦  «        } t          | ¦  «        }t          |         }|| fS )z‰
    Parameters
    ----------
    values : np.ndarray

    Returns
    -------
    htable : HashTable subclass
    values : ndarray
    )rR   Ú_check_object_for_stringsÚ_hashtables)r?   Úndtyper	   s      r[   Ú_get_hashtable_algor…     s3   € õ ˜&Ñ!Ô!€Få& vÑ.Ô.€FÝ˜FÔ#€IØ�fÐÐr\   c                óZ   — | j         j        }|dk    rt          j        | d¬¦  «        rd}|S )z 
    Check if we can use string hashtable instead of object hashtable.

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

    Returns
    -------
    str
    rY   Fri   rl   )rM   Únamer   Úis_string_array)r?   r„   s     r[   r‚   r‚     s=   € ð Œ\Ô€FØ�ÒÐõ Ô˜v¨eÐ4Ñ4Ô4ð 	ØˆFØ€Mr\   c                ó    — 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)r?   s    r[   Úuniquer‹   3  s   € õ| ˜FÑ#Ô#Ð#r\   Úintc                óì   — t          | ¦  «        dk    rdS t          | ¦  «        } t          j        |                      ¦   «                              d¦  «        ¦  «        dk                         ¦   «         }|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)ÚlenrR   rO   ÚbincountÚravelrW   Úsum)r?   Úresults     r[   Únunique_intsr”   ”  sb   € õ ˆ6�{„{�aÒÐØˆqÝ˜&Ñ!Ô!€FåŒk˜&Ÿ,š,™.œ.×/Ò/°Ñ7Ô7Ñ8Ô8¸AÒ=×BÒBÑDÔD€FØ€Mr\   Úmaskúnpt.NDArray[np.bool_] | Nonec                óÌ  — t          | d¬¦  «        } t          | j        t          ¦  «        r|                      ¦   «         S | }t          | ¦  «        \  }}  |t          | ¦  «        ¦  «        }|€-|                     | ¦  «        }t          ||j        |¦  «        }|S |                     | |¬¦  «        \  }}t          ||j        |¦  «        }|€J ‚||                     d¦  «        fS )z?See algorithms.unique for docs. Takes a mask for masked arrays.r‹   ©rc   N©r•   Úbool)	ru   rN   rM   r(   r‹   r…   r�   rb   rW   )r?   r•   r]   r	   ÚtableÚuniquess         r[   rŠ   rŠ   «  sá   € å˜v°Ð:Ñ:Ô:€Få�&”,¥Ñ/Ô/ð à�}Š}‰ŒÐà€HÝ+¨FÑ3Ô3Ñ€IˆvàˆI•c˜&‘k”kÑ"Ô"€EØ€|Ø—,’,˜vÑ&Ô&ˆÝ# G¨X¬^¸XÑFÔFˆØˆð Ÿš V°$˜Ñ7Ô7‰ˆ�Ý# G¨X¬^¸XÑFÔFˆØÐÐÐØ˜Ÿš FÑ+Ô+Ð+Ð+r\   i@B Úcompsr7   únpt.NDArray[np.bool_]c                óž  — t          | ¦  «        s%t          dt          | ¦  «        j        › d�¦  «        ‚t          |¦  «        s%t          dt          |¦  «        j        › d�¦  «        ‚t	          |t
          t          t          t          j	        f¦  «        s`t          |¦  «        }t          |d¬¦  «        }t          |¦  «        dk    r,|j        j        dv rt          | ¦  «        st!          |¦  «        }n<t	          |t"          ¦  «        rt          j        |¦  «        }nt'          |dd¬¦  «        }t          | d	¬¦  «        }t'          |d¬
¦  «        }t	          |t          j	        ¦  «        s|                     |¦  «        S t+          |j        ¦  «        r"t-          |¦  «                             |¦  «        S t+          |j        ¦  «        r4t/          |j        ¦  «        s t          j        |j        t4          ¬¦  «        S t+          |j        ¦  «        r(t)          ||                     t8          ¦  «        ¦  «        S t	          |j        t:          ¦  «        r4t)          t          j        |¦  «        t          j        |¦  «        ¦  «        S t          |¦  «        t>          k    rLt          |¦  «        dk    r9|j        t8          k    r)tA          |¦  «         !                    ¦   «         rd„ }nXd„ }nTtE          |j        |j        ¦  «        }|                     |d¬¦  «        }|                     |d¬¦  «        }tF          j$        } |||¦  «        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 `ú`rf   r˜   r   ÚiufcbT)rD   Úextract_rangeÚisinrC   rL   é   c                óš   — t          j        t          j        | |¦  «                             ¦   «         t          j        | ¦  «        ¦  «        S ©N)rO   Ú
logical_orr£   r‘   Úisnan)ÚcÚvs     r[   Úfzisin.<locals>.f  s2   € Ý”}¥R¤W¨Q°¡]¤]×%8Ò%8Ñ%:Ô%:½B¼HÀQ¹K¼KÑHÔHÐHr\   c                óP   — t          j        | |¦  «                             ¦   «         S r¦   )rO   r£   r‘   )ÚaÚbs     r[   ú<lambda>zisin.<locals>.<lambda>  s   € �RœW Q¨™]œ]×0Ò0Ñ2Ô2€ r\   FrF   )%r!   Ú	TypeErrorÚtypeÚ__name__rN   r,   r.   r+   rO   rU   rs   ru   r�   rM   Úkindr#   r   r-   r3   r5   r£   r$   Úpd_arrayr"   ÚzerosÚshaperš   rW   rY   r(   rP   Ú_MINIMUM_COMP_ARR_LENr0   Úanyr   ÚhtableÚismember)r�   r?   Úorig_valuesÚcomps_arrayr«   Úcommons         r[   r£   r£   É  s=  € õ ˜ÑÔð 
Ýð@Ý(,¨U©¬Ô(<ð@ð @ð @ñ
ô 
ð 	
õ ˜ÑÔð 
ÝðAÝ(,¨V©¬Ô(=ðAð Að Añ
ô 
ð 	
õ
 �f�x­Õ4EÅrÄzÐRÑSÔSð OÝ˜6‘l”lˆÝ" ;¸.ÐIÑIÔIˆõ �‰KŒK˜!ŠOˆOØ”Ô! WÐ,Ð,Ý+¨EÑ2Ô2ð -õ
 =¸[ÑIÔIˆFøå	�F�MÑ	*Ô	*ð Oå”˜&Ñ!Ô!ˆˆå˜v°TÈÐNÑNÔNˆå# E°VÐ<Ñ<Ô<€KÝ ¸4Ð@Ñ@Ô@€KÝ�k¥2¤:Ñ.Ô.ð Aà×Ò Ñ'Ô'Ð'å	˜[Ô.Ñ	/Ô	/ð Aå˜Ñ$Ô$×)Ò)¨&Ñ1Ô1Ð1Ý	˜Vœ\Ñ	*Ô	*ð Aµ?À;ÔCTÑ3UÔ3Uð AåŒx˜Ô)µÐ6Ñ6Ô6Ð6å	˜Vœ\Ñ	*Ô	*ð AÝ�K §¢­vÑ!6Ô!6Ñ7Ô7Ð7å	�F”L¥.Ñ	1Ô	1ð AÝ•B”J˜{Ñ+Ô+­R¬Z¸Ñ-?Ô-?Ñ@Ô@Ð@õ 	ˆKÑÔÕ0Ò0Ð0Ý�‰KŒK˜2ÒÐØÔ¥Ò'Ð'õ �‰<Œ<×ÒÑÔð 	3ðIð Ið Ið Ið 3Ð2ˆAˆAõ % V¤\°;Ô3DÑEÔEˆØ—’˜v¨E�Ñ2Ô2ˆØ!×(Ò(¨°eÐ(Ñ<Ô<ˆÝŒOˆàˆ1ˆ[˜&Ñ!Ô!Ð!r\   TÚuse_na_sentinelrš   Ú	size_hintú
int | NoneÚna_valuerY   ú'tuple[npt.NDArray[np.intp], np.ndarray]c                ó  — | }| j         j        dv rt          }t          | ¦  «        \  }}  ||pt	          | ¦  «        ¦  «        }|                     | d|||¬¦  «        \  }}	t          ||j         |¦  «        }t          |	¦  «        }	|	|fS )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_sentinelrÁ   r•   Ú	ignore_na)rM   r³   r
   r…   r�   Ú	factorizerb   r   )
r?   r¾   r¿   rÁ   r•   r]   Ú
hash_klassr›   rœ   rT   s
             r[   Úfactorize_arrayrÊ   $  s¤   € ðH €HØ„|Ô˜DÐ Ð õ
 ˆå,¨VÑ4Ô4Ñ€J�àˆJ�yÐ/¥C¨¡K¤KÑ0Ô0€EØ—_’_ØØØØØ!ð %ñ ô �N€GˆUõ   ¨¬¸ÑBÔB€Gå Ñ&Ô&€EØ�'ˆ>Ðr\   z�    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.
    )r?   Úsortr¿   FrË   ú%tuple[np.ndarray, np.ndarray | Index]c                ó  — t          | t          t          f¦  «        r|                      ||¬¦  «        S t	          | d¬¦  «        } | }t          | t
          t          f¦  «        r$| j        �|                      |¬¦  «        \  }}||fS t          | t          j	        ¦  «        s|                      |¬¦  «        \  }}nŠt          j
        | ¦  «        } |s_| j        t          k    rOt          | ¦  «        }|                     ¦   «         r,t          | j        d¬¦  «        }t          j        ||| ¦  «        } t#          | ||¬	¦  «        \  }}|r*t%          |¦  «        d
k    rt'          |||dd¬¦  «        \  }}t)          ||j        |¦  «        }||fS )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˜   N)rË   )r¾   F)Úcompat)r¾   r¿   r   T)r¾   Úassume_uniqueÚverify)rN   r,   r.   rÈ   ru   r*   r/   ÚfreqrO   rU   rP   rM   rY   r0   r¸   r1   ÚwhererÊ   r�   Ú	safe_sortrb   )	r?   rË   r¾   r¿   r]   rT   rœ   Ú	null_maskrÁ   s	            r[   rÈ   rÈ   b  s°  € õp �&�8¥YÐ/Ñ0Ô0ð LØ×Ò T¸?ÐÑKÔKÐKå˜v°Ð=Ñ=Ô=€FØ€Hõ 	�6Õ,Õ.?Ð@ÑAÔAð
àŒKÐ#ð  ×)Ò)¨tÐ)Ñ4Ô4‰ˆˆwØ�gˆ~Ðå˜¥¤
Ñ+Ô+ð 
à×)Ò)¸/Ð)ÑJÔJ‰ˆˆwˆwõ ”˜FÑ#Ô#ˆàð 		? 6¤<µ6Ò#9Ð#9õ
 ˜V™œˆIØ�}Š}‰Œð ?Ý-¨f¬lÀ5ÐIÑIÔI�åœ )¨X°vÑ>Ô>�å(ØØ+Øð
ñ 
ô 
‰ˆˆwð ð 
•�G‘”˜qÒ Ð Ý"ØØØ+ØØð
ñ 
ô 
‰ˆ�õ   ¨¬¸ÑBÔB€Gà�'ˆ>Ðr\   Ú	ascendingÚ	normalizeÚdropnar<   c                ó|   — t          j        dt          t          ¦   «         ¬¦  «         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.rg   )rË   rÕ   rÖ   Úbinsr×   )rn   ro   rp   r   Úvalue_counts_internal)r?   rË   rÕ   rÖ   rÙ   r×   s         r[   Úvalue_countsrÛ   /  sZ   € õ< „Mð	EåÝ#Ñ%Ô%ðñ ô ð õ !ØØØØØØðñ ô ð r\   c                óÀ  — ddl m}m} t          | dd ¦  «        }|rdnd}	|��ddlm}
 t          | |¦  «        r| j        } 	  |
| |d¬¦  «        }n"# t          $ r}t          d	¦  «        |‚d }~ww xY w| 	                    |¬
¦  «        }|	|_
        ||j                             ¦   «                  }|j                             d¦  «        |_        |                     ¦   «         }|r,|j        dk                         ¦   «         r|j        dd…         }t#          j        t'          |¦  «        g¦  «        }�nút)          | ¦  «        rp || d¬¦  «        j         	                    |¬
¦  «        }|	|_
        ||j        _
        |j        }t          |t"          j        ¦  «        st#          j        |¦  «        }�n{t          | t.          ¦  «        rnt1          t3          | j        ¦  «        ¦  «        } || |	¬¦  «                             ||¬¦  «                             ¦   «         }| j        |j        _        |j        }nøt=          | d¬¦  «        } t?          | |¦  «        \  }}}|j         t"          j!        k    r|                     t"          j"        ¦  «        } ||¦  «        }|j         tF          k    r+|j         tH          k    r|                     tH          ¦  «        }nC|j         |j         k    r3|j         dk    r(tK          j&        dtN          tQ          ¦   «         ¬¦  «         ||_
         ||||	d¬¦  «        }|r| )                    |¬¦  «        }|r|| *                    ¦   «         z  }|S )Nr   )r;   r<   r‡   Ú
proportionÚcount)ÚcutT)Úinclude_lowestz+bins argument only works with numeric data.©r×   ÚintervalFrF   )Úindexr‡   )Úlevelr×   rÛ   r˜   zstring[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()`rg   )rã   r‡   rG   )rÕ   )+Úpandasr;   r<   ÚgetattrÚpandas.core.reshape.tilerß   rN   Ú_valuesr°   rÛ   r‡   rã   ÚnotnarW   Ú
sort_indexÚallÚilocrO   r3   r�   r   rU   rP   r-   rs   ÚrangeÚnlevelsÚgroupbyÚsizeÚnamesru   Úvalue_counts_arraylikerM   Úfloat16ry   rš   rY   rn   ro   rp   r   Úsort_valuesr’   )r?   rË   rÕ   rÖ   rÙ   r×   r;   r<   Ú
index_namer‡   rß   ÚiiÚerrr“   ÚcountsÚlevelsÚkeysÚ_Úidxs                      r[   rÚ   rÚ   ^  s‘  € ðð ð ð ð ð ð ð õ
 ˜ ¨Ñ.Ô.€JØ$Ð1ˆ<ˆ<¨'€DàÑØ0Ð0Ð0Ð0Ð0Ð0å�f˜fÑ%Ô%ð 	$Ø”^ˆFð	TØ��V˜T°$Ð7Ñ7Ô7ˆBˆBøÝð 	Tð 	Tð 	TÝÐIÑJÔJÐPSÐSøøøøð	Tøøøð —’¨�Ñ/Ô/ˆØˆŒØ˜œ×*Ò*Ñ,Ô,Ô-ˆØ”|×*Ò*¨:Ñ6Ô6ˆŒØ×"Ò"Ñ$Ô$ˆð ð 	&�v”~¨Ò*×/Ò/Ñ1Ô1ð 	&Ø”[  1 Ô%ˆFõ ”�3˜r™7œ7˜)Ñ$Ô$ˆ‰õ $ FÑ+Ô+ð /	Fà�V˜F¨Ð/Ñ/Ô/Ô7×DÒDÈFÐDÑSÔSˆFØˆFŒKØ *ˆFŒLÔØ”^ˆFÝ˜f¥b¤jÑ1Ô1ð ,åœ FÑ+Ô+�ùå˜¥Ñ.Ô.ð %	Få�% ¤Ñ/Ô/Ñ0Ô0ˆFà�˜V¨$Ð/Ñ/Ô/ß’˜v¨f�Ñ5Ô5ß’‘”ð ð
 "(¤ˆFŒLÔØ”^ˆFˆFõ ' v¸ÐHÑHÔHˆFÝ4°V¸VÑDÔD‰OˆD�&˜!ØŒz�RœZÒ'Ð'Ø—{’{¥2¤:Ñ.Ô.�ð �%˜‘+”+ˆCØŒy�DÒ Ð  T¤Zµ6Ò%9Ð%9Ø—j’j¥Ñ(Ô(��à”	˜TœZÒ'Ð'Ø”IÐ!8Ò8Ð8å”ðDõ "Ý/Ñ1Ô1ðñ ô ð ð "ˆCŒHà�V˜F¨#°D¸uÐEÑEÔEˆFàð 9Ø×#Ò#¨iÐ#Ñ8Ô8ˆàð 'Ø˜&Ÿ*š*™,œ,Ñ&ˆà€Ms   ÁA Á
A/ÁA*Á*A/ú,tuple[ArrayLike, npt.NDArray[np.int64], int]c                óò   — | }t          | ¦  «        } t          j        | ||¬¦  «        \  }}}t          |j        ¦  «        r|r|t
          k    }||         ||         }}t          ||j        |¦  «        }|||fS )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™   )rR   r¹   Úvalue_countr$   rM   r
   rb   )r?   r×   r•   r]   rú   rø   Ú
na_counterÚres_keyss           r[   rò   rò   Ã  sŠ   € ð €HÝ˜&Ñ!Ô!€Få%Ô1°&¸&ÀtÐLÑLÔLÑ€Dˆ&�*å˜8œ>Ñ*Ô*ð 4ð ð 	4Ø�4’<ˆDØ œ: v¨d¤|�&ˆDå   x¤~°xÑ@Ô@€HØ�V˜ZÐ'Ð'r\   ÚfirstÚkeepúLiteral['first', 'last', False]c                óN   — t          | ¦  «        } t          j        | ||¬¦  «        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]
    )r  r•   )rR   r¹   Ú
duplicated)r?   r  r•   s      r[   r  r  â  s)   € õ2 ˜&Ñ!Ô!€FÝÔ˜V¨$°TÐ:Ñ:Ô:Ð:r\   c                óì  — t          | d¬¦  «        } | }t          | j        ¦  «        r5t          | ¦  «        } t	          d| ¦  «        } |                      |¬¦  «        S t          | ¦  «        } t          j        | ||¬¦  «        \  }}|�||fS 	 t          j
        |¦  «        }n<# t          $ r/}t          j        d|› �t          ¦   «         ¬¦  «         Y d}~nd}~ww xY wt          ||j        |¦  «        }|S )	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•   NzUnable to sort modes: rg   )ru   r$   rM   r4   r   Ú_moderR   r¹   r  rO   rË   r°   rn   ro   r   rb   )r?   r×   r•   r]   ÚnpresultÚres_maskr÷   r“   s           r[   r  r  ÿ  s,  € õ" ˜v°Ð8Ñ8Ô8€FØ€Hå˜6œ<Ñ(Ô(ð +å/°Ñ7Ô7ˆÝÐ&¨Ñ/Ô/ˆØ�|Š| 6ˆ|Ñ*Ô*Ð*å˜&Ñ!Ô!€Fåœ V°FÀÐFÑFÔFÑ€HˆhØÐØ˜Ð!Ð!ð
Ý”7˜8Ñ$Ô$ˆˆøÝð 
ð 
ð 
ÝŒØ* SÐ*Ð*Ý'Ñ)Ô)ð	
ñ 	
ô 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
øøøøð
øøøõ ˜x¨¬¸ÑBÔB€FØ€Ms   ÂB" Â"
CÂ,%CÃCÚaverageÚaxisr   ÚmethodÚ	na_optionÚpctúnpt.NDArray[np.float64]c           	     ó  — t          | j        ¦  «        }t          | ¦  «        } | j        dk    rt	          j        | |||||¬¦  «        }n6| j        dk    rt	          j        | ||||||¬¦  «        }nt          d¦  «        ‚|S )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Õ   r  r  rH   )r  r  r  rÕ   r  r  z&Array with ndim > 2 are not supported.)r$   rM   rR   Úndimr   Úrank_1dÚrank_2dr°   )r?   r  r  r  rÕ   r  r  Úrankss           r[   Úrankr  +  s©   € õ> *¨&¬,Ñ7Ô7€OÝ˜&Ñ!Ô!€Fà„{�aÒÐÝ”ØØ+ØØØØð
ñ 
ô 
ˆˆð 
Œ˜Ò	Ð	Ý”ØØØ+ØØØØð
ñ 
ô 
ˆˆõ Ð@ÑAÔAÐAà€Lr\   Úindicesr   Ú
allow_fillc                ó¦  — t          | t          j        t          t          t
          f¦  «        s(t          j        dt          t          ¦   «         ¬¦  «         t          | ¦  «        st          j        | ¦  «        } t          |¦  «        }|r0t          || j        |         ¦  «         t          | ||d|¬¦  «        }n|                      ||¬¦  «        }|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.rg   T)r  r  Ú
fill_value)r  )rN   rO   rU   r+   r,   r.   rn   ro   rp   r   r   rP   r   r6   r¶   r2   Útake)Úarrr  r  r  r  r“   s         r[   r  r  k  sÖ   € õj �c�BœJÕ(9½8ÅYÐOÑPÔPð 
åŒð8õ Ý'Ñ)Ô)ð	
ñ 	
ô 	
ð 	
õ ˜ÑÔð ÝŒj˜‰oŒoˆå! 'Ñ*Ô*€Gàð .å˜ #¤)¨D¤/Ñ2Ô2Ð2ÝØ�˜t°Àð
ñ 
ô 
ˆˆð
 —’˜'¨�Ñ-Ô-ˆØ€Mr\   Úleftr   Úvalueú$NumpyValueArrayLike | ExtensionArrayÚsideúLiteral['left', 'right']ÚsorterúNumpySorter | Noneúnpt.NDArray[np.intp] | np.intpc                óú  — |�t          |¦  «        }t          | t          j        ¦  «        �r)| j        j        dv �rt          |¦  «        st          |¦  «        rüt          j        | j        j	        ¦  «        }t          |¦  «        rt          j
        |g¦  «        nt          j
        |¦  «        }||j        k                         ¦   «         r%||j        k                         ¦   «         r| j        }n|j        }t          |¦  «        r)t          t          | 	                    |¦  «        ¦  «        }n4t!          t          t"          |¦  «        |¬¦  «        }nt%          | ¦  «        } |                      |||¬¦  «        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.
    NÚiurL   )r$  r&  )r   rN   rO   rU   rM   r³   r   r    Úiinfor±   r3   Úminrë   Úmaxr   rŒ   r´   r   r4   Úsearchsorted)r   r"  r$  r&  r+  Ú	value_arrrM   s          r[   r.  r.  à  s\  € ð` ÐÝ$ VÑ,Ô,ˆõ 	�3�œ
Ñ#Ô#ñ2àŒIŒN˜dÐ"Ñ"Ý˜ÑÔð #Ý"2°5Ñ"9Ô"9ð #õ ”˜œœÑ(Ô(ˆÝ)3°EÑ):Ô):ÐO•B”H˜e˜WÑ%Ô%Ð%ÅÄÈÁÄˆ	Ø˜œÒ"×'Ò'Ñ)Ô)ð 	$¨y¸E¼IÒ/E×.JÒ.JÑ.LÔ.Lð 	$ð ”IˆEˆEà”OˆEå�eÑÔð 	Bå�˜eŸjšj¨Ñ/Ô/Ñ0Ô0ˆEˆEå�T¥)¨UÑ3Ô3¸5ÐAÑAÔAˆEˆEõ -¨SÑ1Ô1ˆð ×Ò˜E¨°VÐÑ<Ô<Ð<r\   >   r€   r   r~   r}   ry   rx   Únc                óŠ  — t          |¦  «        }t          j        }| j        }t	          |¦  «        }|rt
          j        }nt
          j        }t          |t          ¦  «        r|  
                    ¦   «         } | j        }t          | t          j        ¦  «        s‰t          | d|j        › d�¦  «        rL|dk    r't          dt          | ¦  «        j        › d|› �¦  «        ‚ || |                      |¦  «        ¦  «        S t#          t          | ¦  «        j        › d�¦  «        ‚d}| j        j        dv r+t          j        }|                      d¦  «        } t*          }d	}n?|rt          j        }n0|j        d
v r'| j        j        dv rt          j        }nt          j        }| j        }|dk    r|                      dd¦  «        } t          j        |¦  «        }t          j        | j        |¬¦  «        }	t=          d¦  «        gdz  }
|dk    rt=          d|¦  «        nt=          |d¦  «        |
|<   ||	t?          |
¦  «        <   | j        j        t@          v rtC          j"        | |	|||¬¦  «         n³t=          d¦  «        gdz  }|dk    rt=          |d¦  «        nt=          d|¦  «        ||<   t?          |¦  «        }t=          d¦  «        gdz  }|dk    rt=          d| ¦  «        nt=          | d¦  «        ||<   t?          |¦  «        } || |         | |         ¦  «        |	|<   |r|	                     d¦  «        }	|dk    r|	dd…df         }	|	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
    Ú__r   zcannot diff z	 on axis=zK has no 'diff' method. Convert to a suitable dtype prior to calling 'diff'.FrÄ   rK   Tr*  )r€   r   r  rÅ   rL   NrH   )Údatetimelikeztimedelta64[ns])#rŒ   rO   ÚnanrM   r   ÚoperatorÚxorÚsubrN   r)   Úto_numpyrU   Úhasattrr²   Ú
ValueErrorr±   Úshiftr°   r³   r}   rV   r
   Úobject_r‡   ry   rx   r  ÚreshapeÚemptyr¶   Úslicerr   Ú_diff_specialr   Údiff_2d)r   r0  r  ÚnarM   Úis_boolÚopÚis_timedeltaÚ	orig_ndimÚout_arrÚ
na_indexerÚ_res_indexerÚres_indexerÚ_lag_indexerÚlag_indexers                  r[   ÚdiffrM  ;  s;  € õ( 	ˆA‰Œ€AÝ	Œ€BØŒI€Eå˜EÑ"Ô"€GØð ÝŒ\ˆˆåŒ\ˆå�%�Ñ&Ô&ð à�lŠl‰nŒnˆØ”	ˆå�c�2œ:Ñ&Ô&ð 
å�3Ð,˜Rœ[Ð,Ð,Ð,Ñ-Ô-ð 	Ø�qŠyˆyÝ Ð!Sµ°S±	´	Ô0BÐ!SÐ!SÈTÐ!SÐ!SÑTÔTÐTØ�2�c˜3Ÿ9š9 Q™<œ<Ñ(Ô(Ð(åÝ˜‘9”9Ô%ð Gð Gð Gñô ð ð
 €LØ
„y„~˜ÐÐÝ”ˆØ�hŠh�t‰nŒnˆÝˆØˆˆà	ð å”
ˆˆà	Œ�tÐ	Ð	ð
 Œ9Œ>Ð.Ð.Ð.Ý”JˆEˆEå”JˆEà”€IØ�A‚~€~à�kŠk˜"˜aÑ Ô ˆõ ŒH�U‰OŒO€EÝŒh�s”y¨Ð.Ñ.Ô.€Gå˜‘+”+� Ñ"€JØ)*¨aª¨•u˜T 1‘~”~�~µU¸1¸d±^´^€JˆtÑØ!#€G�E�*ÑÔÑà
„y„~�Ð&Ð&õ 	Œ�c˜7 A t¸,ÐGÑGÔGÐGÐGõ ˜d™œ�} qÑ(ˆØ/0°Aªv¨v�U 1 d™^œ^˜^½5ÀÀq¹>¼>ˆ�TÑÝ˜LÑ)Ô)ˆå˜d™œ�} qÑ(ˆØ01°A²°�U 4¨!¨™_œ_˜_½5À!ÀÀT¹?¼?ˆ�TÑÝ˜LÑ)Ô)ˆà!˜r # kÔ"2°C¸Ô4DÑEÔEˆ�Ñàð 2Ø—,’,Ð0Ñ1Ô1ˆà�A‚~€~Ø˜!˜!˜!˜Q˜$”-ˆØ€Nr\   úIndex | ArrayLikerT   únpt.NDArray[np.intp] | NonerÏ   rÐ   ú.AnyArrayLike | tuple[AnyArrayLike, np.ndarray]c                ó0  — t          | t          j        t          t          f¦  «        st          d¦  «        ‚d}t          | j        t          ¦  «        s*t          j	        | d¬¦  «        dk    rt          | ¦  «        }nˆ	 |                      ¦   «         }|                      |¦  «        }n]# t
          t          j        f$ rD | j        r+t          | d         t           ¦  «        rt#          | ¦  «        }nt          | ¦  «        }Y nw xY w|€|S t%          |¦  «        st          d¦  «        ‚t'          t          j        |¦  «        ¦  «        }|s<t+          t-          | ¦  «        ¦  «        t+          | ¦  «        k    st/          d¦  «        ‚|€at1          | ¦  «        \  }}  |t+          | ¦  «        ¦  «        }|                     | ¦  «         t'          |                     |¦  «        ¦  «        }|rY|                     ¦   «         }	|r.|t+          | ¦  «         k     |t+          | ¦  «        k    z  }
d||
<   nd}
t7          |	|d	¬
¦  «        }n©t          j        t+          |¦  «        t:          ¬¦  «        }|                     |t          j        t+          |¦  «        ¦  «        ¦  «         |                     |d¬¦  «        }|r3|d	k    }
|r+|
|t+          | ¦  «         k     z  |t+          | ¦  «        k    z  }
|r|
�t          j         ||
d	¦  «         |t'          |¦  «        fS )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 valuesNFri   rm   r   zMOnly list-like objects or None are allowed to be passed to safe_sort as codesz,values should be unique if codes is not NonerÅ   ©r  rL   Úwrap)r  )!rN   rO   rU   r+   r,   r°   rM   r(   r   rq   Ú_sort_mixedÚargsortr  ÚdecimalÚInvalidOperationrð   rr   Ú_sort_tuplesr!   r   rP   r�   r‹   r:  r…   Úmap_locationsÚlookupr2   r>  rŒ   ÚputÚarangeÚputmask)r?   rT   r¾   rÏ   rÐ   r&  ÚorderedrÉ   ÚtÚorder2r•   Ú	new_codesÚreverse_indexers                r[   rÓ   rÓ   ¬  s  € õ` �f�rœzÕ+<½hÐGÑHÔHð 
Ýð/ñ
ô 
ð 	
ð
 €Fõ �v”|¥^Ñ4Ô4ð.åŒO˜F¨5Ð1Ñ1Ô1°_ÒDÐDå˜fÑ%Ô%ˆˆð	.Ø—^’^Ñ%Ô%ˆFØ—k’k &Ñ)Ô)ˆGˆGøÝ�7Ô3Ð4ð 
	.ð 
	.ð 
	.ð Œ{ð .�z¨&°¬)µUÑ;Ô;ð .õ ' vÑ.Ô.��å% fÑ-Ô-�øøð
	.øøøð €}Øˆå˜ÑÔð 
Ýð.ñ
ô 
ð 	
õ  ¥¤
¨5Ñ 1Ô 1Ñ2Ô2€Eàð I¥¥V¨F¡^¤^Ñ!4Ô!4½¸F¹¼Ò!CÐ!CÝÐGÑHÔHÐHà€~õ
 1°Ñ8Ô8Ñˆ
�FØˆJ•s˜6‘{”{Ñ#Ô#ˆØ	�Š˜ÑÔÐÝ$ Q§X¢X¨gÑ%6Ô%6Ñ7Ô7ˆàð Nà—’Ñ!Ô!ˆØð 	Ø�S ™[œ[˜LÒ(¨Uµc¸&±k´kÒ-AÑBˆDØˆE�$‰KˆKàˆDÝ˜F E°bÐ9Ñ9Ô9ˆ	ˆ	åœ(¥3 v¡;¤;µcÐ:Ñ:Ô:ˆØ×Ò˜F¥B¤I­c°&©k¬kÑ$:Ô$:Ñ;Ô;Ð;ð $×(Ò(¨°VÐ(Ñ<Ô<ˆ	àð 	NØ˜B’;ˆDØð NØ˜u­¨F©¬ |Ò3Ñ4¸ÅÀVÁÄÒ8LÑM�àð (˜4Ð+Ý
Œ
�9˜d BÑ'Ô'Ð'àÕ'¨	Ñ2Ô2Ð2Ð2s   Á>)B( Â(ADÄDc                óL  — t          j        d„ | D ¦   «         t          ¬¦  «        }t          j        d„ | D ¦   «         t          ¬¦  «        }| | z  }t          j        | |         ¦  «        }t          j        | |         ¦  «        }|                     ¦   «         d                              |¦  «        }|                     ¦   «         d                              |¦  «        }|                     ¦   «         d         }t          j        |||g¦  «        }	|                      |	¦  «        S )z3order ints before strings before nulls in 1d arraysc                ó8   — g | ]}t          |t          ¦  «        ‘ŒS © )rN   rd   ©Ú.0Úxs     r[   ú
<listcomp>z_sort_mixed.<locals>.<listcomp>0  s"   € Ð;Ð;Ð;¨q�
 1¥cÑ*Ô*Ð;Ð;Ð;r\   rL   c                ó,   — g | ]}t          |¦  «        ‘ŒS re  )r0   rf  s     r[   ri  z_sort_mixed.<locals>.<listcomp>1  s   € Ð1Ð1Ð1 Q�˜a™œÐ1Ð1Ð1r\   r   )rO   r3   rš   rU  Únonzeror  Úconcatenate)
r?   Ústr_posÚnull_posÚnum_posÚstr_argsortÚnum_argsortÚstr_locsÚnum_locsÚ	null_locsÚlocss
             r[   rT  rT  .  sþ   € åŒhÐ;Ð;°FÐ;Ñ;Ô;Å4ÐHÑHÔH€GÝŒxÐ1Ð1¨&Ð1Ñ1Ô1½Ð>Ñ>Ô>€HØˆh˜(˜Ñ"€GÝ”*˜V Gœ_Ñ-Ô-€KÝ”*˜V Gœ_Ñ-Ô-€Kà�ŠÑ Ô  Ô#×(Ò(¨Ñ5Ô5€HØ�ŠÑ Ô  Ô#×(Ò(¨Ñ5Ô5€HØ× Ò Ñ"Ô" 1Ô%€IÝŒ>˜8 X¨yÐ9Ñ:Ô:€DØ�;Š;�tÑÔÐr\   c                ób   — ddl m} ddlm}  || 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.constructionrw  Úpandas.core.sortingrx  )r?   rw  rx  Úarraysrû   Úindexers         r[   rX  rX  =  s[   € ð =Ð<Ð<Ð<Ð<Ð<Ø3Ð3Ð3Ð3Ð3Ð3à�	˜& $Ñ'Ô'�I€FˆAØˆo˜f¨TÐ2Ñ2Ô2€GØ�'Œ?Ðr\   ÚlvalsúArrayLike | IndexÚrvalsc                óJ  — ddl m} t          j        ¦   «         5  t          j        ddt
          ¬¦  «         t          | d¬¦  «        }t          |d¬¦  «        }ddd¦  «         n# 1 swxY w Y   |                     |d¬	¦  «        \  }}t          j	        |j
        |j
        ¦  «        } |||j        d
d¬¦  «        }t          | t          ¦  «        r=t          |t          ¦  «        r(|                      |¦  «                             ¦   «         }ngt          | t           ¦  «        r| j        } t          |t           ¦  «        r|j        }t%          | |g¦  «        }t          |¦  «        }t'          |¦  «        }|                     |¦  «        j
        }t          j        ||¦  «        S )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á   NrR  rŒ   )rã   rM   rG   )rå   r<   rn   Úcatch_warningsÚfilterwarningsrp   rÚ   ÚalignrO   Úmaximumr?   rã   rN   r-   Úappendr‹   r,   rè   r%   r4   ÚreindexÚrepeat)	r~  r€  r<   Úl_countÚr_countÚfinal_countÚunique_valsÚcombinedÚrepeatss	            r[   Úunion_with_duplicatesr’  L  sÛ  € ð. ÐÐÐÐÐå	Ô	 Ñ	"Ô	"ð 	=ð 	=õ 	ÔØØJÝ"ð	
ñ 	
ô 	
ð 	
õ
 (¨°eÐ<Ñ<Ô<ˆÝ'¨°eÐ<Ñ<Ô<ˆð	=ð 	=ð 	=ñ 	=ô 	=ð 	=ð 	=ð 	=ð 	=ð 	=ð 	=øøøð 	=ð 	=ð 	=ð 	=ð —}’} W¸�}Ñ;Ô;Ñ€GˆWÝ”*˜Wœ^¨W¬^Ñ<Ô<€KØ�&˜¨G¬MÀÈUÐSÑSÔS€KÝ�%�Ñ'Ô'ð B­J°u½mÑ,LÔ,Lð BØ—l’l 5Ñ)Ô)×0Ò0Ñ2Ô2ˆˆå�e�XÑ&Ô&ð 	"Ø”MˆEÝ�e�XÑ&Ô&ð 	"Ø”MˆEõ ! %¨ Ñ0Ô0ˆÝ˜XÑ&Ô&ˆÝ4°[ÑAÔAˆØ×!Ò! +Ñ.Ô.Ô5€GÝŒ9�[ 'Ñ*Ô*Ð*s   š?A%Á%A)Á,A)Ú	na_actionúLiteral['ignore'] | NoneÚconvertú#np.ndarray | ExtensionArray | Indexc                ó0  ‡	— |dvrd|› d�}t          |¦  «        ‚t          |¦  «        rit          |t          ¦  «        rt	          |d¦  «        r|Š	ˆ	fd„}n<ddlm} t          |¦  «        dk    r ||t          j	        ¬¦  «        }n ||¦  «        }t          |t          ¦  «        rV|d	k    r||j                             ¦   «                  }|j                             | ¦  «        }t          |j        |¦  «        }|S t          | ¦  «        s|                      ¦   «         S |                      t$          d
¬¦  «        }|€t'          j        |||¬¦  «        S t'          j        ||t-          |¦  «                             t          j        ¦  «        |¬¦  «        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.
    )Nrƒ  z+na_action must either be 'ignore' or None, z was passedÚ__missing__c                ó~   •— ‰t          | t          ¦  «        r t          j        | ¦  «        rt          j        n|          S r¦   )rN   ÚfloatrO   r¨   r4  )rh  Údict_with_defaults    €r[   r¯   zmap_array.<locals>.<lambda>ª  s2   ø€ Ð0Ý$ Q­Ñ.Ô.ÐEµ2´8¸A±;´;ÐE•”�ÀAô € r\   r   r‚  rL   rƒ  FrF   N)r•  )r•   r•  )r:  r   rN   Údictr9  rå   r<   r�   rO   rx   r.   rã   ré   Úget_indexerr2   rè   rG   rW   rY   r   Ú	map_inferÚmap_infer_maskr0   rV   rE   )
r   Úmapperr“  r•  Úmsgr<   r}  Ú
new_valuesr?   r›  s
            @r[   Ú	map_arrayr£  ƒ  s¸  ø€ ð6 Ð(Ð(Ð(ØR¸IÐRÐRÐRˆÝ˜‰oŒoÐõ
 �FÑÔð (Ý�f�dÑ#Ô#ð 	(­°¸Ñ(FÔ(Fð 	(ð !'Ððð ð ð ˆFˆFð &Ð%Ð%Ð%Ð%Ð%å�6‰{Œ{˜aÒÐØ˜ ­b¬jÐ9Ñ9Ô9��à˜ ™œ�å�&�)Ñ$Ô$ð 	Ø˜Ò Ð Ø˜FœL×.Ò.Ñ0Ô0Ô1ˆFð ”,×*Ò*¨3Ñ/Ô/ˆÝ˜Vœ^¨WÑ5Ô5ˆ
àÐåˆs‰8Œ8ð Ø�xŠx‰zŒzÐð �ZŠZ� UˆZÑ+Ô+€FØÐÝŒ}˜V V°WÐ=Ñ=Ô=Ð=åÔ!Ø�F¥ f¡¤×!2Ò!2µ2´8Ñ!<Ô!<Àgð
ñ 
ô 
ð 	
r\   )r?   r   r@   rA   )r?   r   rM   r   r]   r   r@   r   )rc   rd   r@   r   )r?   rA   )r?   rA   r@   rd   )r?   r   r@   rŒ   r¦   )r•   r–   )r�   r7   r?   r7   r@   rž   )TNNN)r?   rA   r¾   rš   r¿   rÀ   rÁ   rY   r•   r–   r@   rÂ   )FTN)rË   rš   r¾   rš   r¿   rÀ   r@   rÌ   )TFFNT)
rË   rš   rÕ   rš   rÖ   rš   r×   rš   r@   r<   )r?   rA   r×   rš   r•   r–   r@   rý   )r  N)r?   r   r  r  r•   r–   r@   rž   )TN)r?   r   r×   rš   r•   r–   r@   r   )r   r  r  TF)r?   r   r  r   r  rd   r  rd   rÕ   rš   r  rš   r@   r  )r   FN)r  r   r  r   r  rš   )r!  N)
r   r   r"  r#  r$  r%  r&  r'  r@   r(  )r   )r0  rŒ   r  r   )NTFT)r?   rN  rT   rO  r¾   rš   rÏ   rš   rÐ   rš   r@   rP  )r@   r   )r?   rA   r@   rA   )r~  r  r€  r  r@   r  )NT)r   r   r“  r”  r•  rš   r@   r–  )�Ú__doc__Ú
__future__r   rV  r5  Útextwrapr   Útypingr   r   r   rn   ÚnumpyrO   Úpandas._libsr   r	   r¹   r
   r   Úpandas._typingr   r   r   r   r   r   Úpandas.util._decoratorsr   Úpandas.util._exceptionsr   Úpandas.core.dtypes.castr   r   Úpandas.core.dtypes.commonr   r   r   r   r   r   r   r   r   r   r    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.missingr0   r1   Úpandas.core.array_algos.taker2   Úpandas.core.constructionr3   r´   r4   r5   Úpandas.core.indexersr6   r7   r8   r9   rå   r:   r;   r<   Úpandas.core.arraysr=   r>   rR   rb   ru   ÚComplex128HashTableÚComplex64HashTableÚFloat64HashTableÚFloat32HashTableÚUInt64HashTableÚUInt32HashTableÚUInt16HashTableÚUInt8HashTableÚInt64HashTableÚInt32HashTableÚInt16HashTableÚInt8HashTableÚStringHashTableÚPyObjectHashTablerƒ   r…   r‚   r‹   r”   rŠ   Úunique1dr·   r£   rÊ   rÈ   rÛ   rÚ   rò   r  r  r  r  r.  r@  rM  rÓ   rT  rX  r’  r£  re  r\   r[   ú<module>rÆ     s³  ððð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð
 €€€à Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð (Ð 'Ð 'Ð 'Ð 'Ð 'Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4ðð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð" 4Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð
 1Ð 0Ð 0Ð 0Ð 0Ð 0ðð ð ð ð ð ð ð ð ð ð
 2Ð 1Ð 1Ð 1Ð 1Ð 1àð ðð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð
ð ð ð ð ð ð ð ðK!ð K!ð K!ð K!ð\ð ð ð ðBð ð ð ð8 Ô,ØÔ*ØÔ&ØÔ&ØÔ$ØÔ$ØÔ$ØÔ"ØÔ"ØÔ"ØÔ"ØÔ ØÔ$ØÔ&ðð €ð$ð ð ð ð$ð ð ð ð6^$ð ^$ð ^$ðBð ð ð ð.,ð ,ð ,ð ,ð ,ð0 €ð "Ð ðX"ð X"ð X"ð X"ðz !Ø ØØ)-ð;ð ;ð ;ð ;ð ;ð| €Øˆ6ð	ñô ð 
ˆð	ñ
ô 
ð ˆfð	ñô ðñ ô ð0 Ø Ø ð	tð tð tð tñ-ô ð,tðr ØØØ	Øð,ð ,ð ,ð ,ð ,ðb ØØØ	Øðað að að að aðL LPð(ð (ð (ð (ð (ðB -4Ø)-ð;ð ;ð ;ð ;ð ;ð< RVð)ð )ð )ð )ð )ð\ ØØØØð8ð 8ð 8ð 8ð 8ðF ØØðmð mð mð mð mðp &,Ø!%ð	Q=ð Q=ð Q=ð Q=ð Q=ðp JÐIÐI€ðgð gð gð gð gðf *.Ø ØØð3ð 3ð 3ð 3ð 3ðDð ð ð ðð ð ð ð4+ð 4+ð 4+ð 4+ðt +/Øð	P
ð P
ð P
ð P
ð P
ð P
ð P
r\   