ó
    Ñ]jMÖ  ã                  óÞ  • S r SSKJr  SSKrSSKrSSKJrJrJrJ	r	J
r
  SSKrSSKrSSKJrJrJrJr  SSKJr  SSKJrJrJrJrJrJrJr  SSKJr  SS	K J!r!  SS
K"J#r#J$r$  SSK%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5  SSK6J7r7  SSK8J9r9J:r:J;r;J<r<  SSK=J>r>J?r?J@r@JArAJBrBJCrCJDrD  SSKEJFrFJGrG  SSKHJIrI  SSKJJKrLJMrMJNrN  SSKOJPrP  \(       a)  SSKJQrQJRrRJSrS  SSKTJUrUJVrVJWrW  SSKXJYrYJZrZ  \" S\V\U-  \Z-  S9r[S7S jr\        S8S jr]S9S jr^\R¾                  \RÀ                  \RÂ                  \RÄ                  \RÆ                  \RÈ                  \RÊ                  \RÌ                  \RÎ                  \RÐ                  \RÒ                  \RÔ                  \RÖ                  \RØ                  S.rm    S:S jrnS;S jro\
S<S j5       rp\
S=S j5       rp\" S 5      S! 5       rpS>S" jrqS?S@S# jjrr\prsS$rtSAS% jru    SB           SCS& jjrv\" S 5         SD       SES' jj5       rw     SF         SGS( jjrx S?       SHS) jjry  SI       SJS* jjrz SK       SLS+ jjr{      SM               SNS, jjr|\" S-5         SO     SPS. jj5       r}  SQ         SRS/ jjr~1 S0krSSSTS1 jjr€    SU           SVS2 jjr�SWS3 jr‚SXS4 jrƒ      SYS5 jr„ S?     SZS6 jjr…g)[zl
Generic data algorithms. This module is experimental at the moment and not
intended for public consumption
é    )ÚannotationsN)ÚTYPE_CHECKINGÚLiteralÚTypeVarÚcastÚoverload)ÚalgosÚ	hashtableÚiNaTÚlib©ÚNA)ÚAnyArrayLikeÚ	ArrayLikeÚ
ArrayLikeTÚAxisIntÚDtypeObjÚTakeIndexerÚnpt)Ú
set_module)Úfind_stack_level)Ú'construct_1d_object_array_from_listlikeÚnp_find_common_type)Úensure_float64Úensure_objectÚensure_platform_intÚis_bool_dtypeÚis_complex_dtypeÚis_dict_likeÚis_dtype_equalÚis_extension_array_dtypeÚis_floatÚ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ÚABCNumpyExtensionArrayÚ	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ÚT)Úboundc                ó:  • [        U [        5      (       d
  [        U SS9n [        U R                  5      (       a  [        [        R                  " U 5      5      $ [        U R                  [        5      (       aH  [        SU 5      n U R                  (       d  [        U R                  5      $ [        R                  " U 5      $ [        U R                  [        5      (       a  [        SU 5      n U R                  $ [        U R                  5      (       ah  [        U [        R                   5      (       a%  [        R                  " U 5      R#                  S5      $ [        R                  " U 5      R%                  SSS9$ ['        U R                  5      (       a  [        R                  " U 5      $ [)        U R                  5      (       a;  U R                  R*                  S;   a  [-        U 5      $ [        R                  " U 5      $ [/        U R                  5      (       a  [        [        R                   U 5      $ [1        U R                  5      (       a-  U R#                  S	5      n[        [        R                   U5      nU$ [        R                  " U [2        S
9n [        U 5      $ )aD  
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_numpyrC   r@   Úuint8F©Úcopy)é   é   é   Úi8©Údtype)Ú
isinstancer2   r;   r'   rR   r   ÚnpÚasarrayr+   r   Ú_hasnaÚ_ensure_dataÚ_datar,   Úcodesr   ÚndarrayÚviewÚastyper%   r#   Úitemsizer   r   r)   Úobject)ÚvaluesÚnpvaluess     ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pandas/core/algorithms.pyrW   rW   r   sÖ  € ô, �fœm×,Ñ,ä˜v°TÑ:ˆä�v—|‘|×$Ñ$ÜœRŸZšZ¨Ó/Ó0Ð0ä	�F—L‘L¤/×	2Ñ	2äÐ'¨Ó0ˆØ�}�}ô   §¡Ó-Ð-Ü�zŠz˜&Ó!Ð!ä	�F—L‘LÔ"2×	3Ñ	3ô �m VÓ,ˆØ�|‰|Ðä	�v—|‘|×	$Ñ	$Ü�fœbŸj™j×)Ñ)ä—:’:˜fÓ%×*Ñ*¨7Ó3Ð3ô —:’:˜fÓ%×,Ñ,¨W¸5Ð,ÐAÐAä	˜&Ÿ,™,×	'Ñ	'Ü�zŠz˜&Ó!Ð!ä	˜Ÿ™×	%Ñ	%ð �<‰<× Ñ  KÓ/ä! &Ó)Ð)Ü�zŠz˜&Ó!Ð!ä	˜&Ÿ,™,×	'Ñ	'Ü”B—J‘J Ó'Ð'ô 
˜VŸ\™\×	*Ñ	*Ø—;‘;˜tÓ$ˆÜœŸ
™
 HÓ-ˆØˆô �ZŠZ˜¤fÑ-€FÜ˜Ó Ð ó    c                óì   • [        U [        5      (       a  U R                  U:X  a  U $ [        U[        R                  5      (       d  UR	                  5       nUR                  XS9$ U R                  USS9$ )z¿
reverse of _ensure_data

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

Returns
-------
ExtensionArray or np.ndarray
rQ   FrK   )rS   r0   rR   rT   Úconstruct_array_typeÚ_from_sequencer\   )r_   rR   ÚoriginalÚclss       ra   Ú_reconstruct_datarh   À   sn   € ô  �&Ô+×,Ñ,°·±ÀÓ1Fàˆä�eœRŸX™X×&Ñ&ð ×(Ñ(Ó*ˆð
 ×!Ñ! &Ð!Ð6Ð6ð
 �=‰=˜ Uˆ=Ð+Ð+rb   c                ó~  • [        U [        [        [        [        R
                  [        45      (       dˆ  US:w  a$  [        U S[        U 5      R                   S35      e[        R                  " U SS9nUS;   a-  [        U [        5      (       a  [        U 5      n [        U 5      n U $ [        R                  " U 5      n U $ )z-
ensure that we are arraylike if not already
úisin-targetszQ requires a Series, Index, ExtensionArray, np.ndarray or NumpyExtensionArray got Ú.F©Úskipna)ÚmixedÚstringúmixed-integer)rS   r1   r4   r0   rT   rZ   r3   Ú	TypeErrorÚtypeÚ__name__r   Úinfer_dtypeÚtupleÚlistr   rU   )r_   Ú	func_nameÚinferreds      ra   Ú_ensure_arraylikery   ä   s·   € ô ØÜ	”9Ô/´·±Ô=SÐT÷ñ ð
 ˜Ó&äØ�+ð ä˜F“|×,Ñ,Ð-¨Qð0óð ô —?’? 6°%Ñ8ˆØÐ;Ó;ä˜&¤%×(Ñ(Ü˜f›�Ü<¸VÓDˆFð €Mô —Z’Z Ó'ˆFØ€Mrb   )Ú
complex128Ú	complex64Úfloat64Úfloat32Úuint64Úuint32Úuint16rJ   Úint64Úint32Úint16Úint8ro   r^   c                óF   • [        U 5      n [        U 5      n[        U   nX 4$ )zi
Parameters
----------
values : np.ndarray

Returns
-------
htable : HashTable subclass
values : ndarray
)rW   Ú_check_object_for_stringsÚ_hashtables)r_   Úndtyper
   s      ra   Ú_get_hashtable_algor‰     s+   € ô ˜&Ó!€Fä& vÓ.€FÜ˜FÑ#€IØÐÐrb   c                óv   • U R                   R                  nUS:X  a  [        R                  " U SS9(       a  SnU$ )z€
Check if we can use string hashtable instead of object hashtable.

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

Returns
-------
str
r^   Frl   ro   )rR   Únamer   Úis_string_array)r_   rˆ   s     ra   r†   r†   &  s7   € ð �\‰\×Ñ€FØ�Óô ×Ò˜v¨e×4ØˆFØ€Mrb   c                ó   • g ©N© ©r_   s    ra   Úuniquer‘   A  s   € Ørb   c                ó   • g rŽ   r�   r�   s    ra   r‘   r‘   C  s   € Ø7:rb   Úpandasc                ó   • [        U 5      $ )ay
  
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
    The input array-like object containing values from which to extract
    unique values.

Returns
-------
numpy.ndarray, ExtensionArray or NumpyExtensionArray

    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, ExtensionArray or NumpyExtensionArray.

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.000000'], dtype='datetime64[us]')

>>> pd.unique(
...     pd.Series(
...         [
...             pd.Timestamp("20160101", tz="US/Eastern"),
...             pd.Timestamp("20160101", tz="US/Eastern"),
...         ],
...         dtype="M8[ns, 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"),
...         ],
...         dtype="M8[ns, 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, str): ['a', 'b', 'c']

>>> pd.unique(pd.Series(pd.Categorical(list("baabc"), categories=list("abc"))))
['b', 'a', 'c']
Categories (3, str): ['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, str): ['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)

A NumpyExtensionArray of complex

>>> pd.unique(pd.array([1 + 1j, 2, 3]))
<NumpyExtensionArray>
[(1+1j), (2+0j), (3+0j)]
Length: 3, dtype: complex128
)Úunique_with_maskr�   s    ra   r‘   r‘   G  s   € ôT ˜FÓ#Ð#rb   c                óÄ   • [        U 5      S:X  a  g[        U 5      n [        R                  " U R	                  5       R                  S5      5      S:g  R                  5       nU$ )a   
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)ÚlenrW   rT   ÚbincountÚravelr\   Úsum)r_   Úresults     ra   Únunique_intsr�   ´  sO   € ô ˆ6ƒ{�aÓØÜ˜&Ó!€Fä�kŠk˜&Ÿ,™,›.×/Ñ/°Ó7Ó8¸AÑ=×BÑBÓD€FØ€Mrb   c                óÒ  • [        U SS9n [        U R                  [        5      (       a  U R	                  5       $ [        U [
        5      (       a  U R	                  5       $ U n[        U 5      u  p0U" [        U 5      5      nUc)  UR	                  U 5      n[        XRR                  U5      nU$ UR	                  XS9u  pQ[        XRR                  U5      nUc   eXQR                  S5      4$ )z?See algorithms.unique for docs. Takes a mask for masked arrays.r‘   ©rw   ©ÚmaskÚbool)
ry   rS   rR   r-   r‘   r1   r‰   r˜   rh   r\   )r_   r¡   rf   r
   ÚtableÚuniquess         ra   r•   r•   Ë  sÎ   € ä˜v°Ñ:€Fä�&—,‘,¤×/Ñ/à�}‰}‹Ðä�&œ(×#Ñ#à�}‰}‹Ðà€HÜ+¨FÓ3Ñ€Iá”c˜&“kÓ"€EØ�|Ø—,‘,˜vÓ&ˆÜ# G¯^©^¸XÓFˆØˆð Ÿ™ V˜Ð7‰ˆÜ# G¯^©^¸XÓFˆØÑÐÐØŸ™ FÓ+Ð+Ð+rb   i@B c                ó´  • [        U 5      (       d"  [        S[        U 5      R                   S35      e[        U5      (       d"  [        S[        U5      R                   S35      e[	        U[
        [        [        [        R                  45      (       dj  [        U5      n[        USS9n[        U5      S:”  aE  UR                  R                  S;   a+  [        U 5      (       d  [!        X5      (       d  [#        U5      nO7[	        U[$        5      (       a  [        R&                  " U5      nO[)        USSS9n[        U S	S9n[)        USS
9n[	        U[        R                  5      (       d  UR+                  U5      $ [-        UR                  5      (       a  [/        U5      R+                  U5      $ [-        UR                  5      (       a=  [1        UR                  5      (       d#  [        R2                  " UR4                  [6        S9$ [-        UR                  5      (       a  [+        X1R9                  [:        5      5      $ [	        UR                  [<        5      (       a4  [+        [        R>                  " U5      [        R>                  " U5      5      $ [        U5      [@        :”  a`  [        U5      S::  aQ  UR                  [:        :w  a=  [C        S U 5       5      (       d&  [E        U5      RC                  5       (       a  S nOTS nOP[G        UR                  UR                  5      nUR9                  USS9nUR9                  USS9n[H        RJ                  nU" X15      $ )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 `Ú`rj   rŸ   r   ÚiufcbT)rI   Úextract_rangeÚisinrH   rQ   é   c              3  ó0   #   • U  H  o[         L v •  M     g 7frŽ   r   )Ú.0Úvs     ra   Ú	<genexpr>Úisin.<locals>.<genexpr>9  s   é € Ð,¢V œ•G¢Vùs   ‚c                óœ   • [         R                  " [         R                  " X5      R                  5       [         R                  " U 5      5      $ rŽ   )rT   Ú
logical_orr©   rš   Úisnan)Úcr­   s     ra   ÚfÚisin.<locals>.f?  s,   € Ü—}’}¤R§W¢W¨Q£]×%8Ñ%8Ó%:¼B¿HºHÀQ»KÓHÐHrb   c                óJ   • [         R                  " X5      R                  5       $ rŽ   )rT   r©   rš   )ÚaÚbs     ra   Ú<lambda>Úisin.<locals>.<lambda>C  s   € œRŸWšW Q›]×0Ñ0Ô2rb   FrK   )&r&   rq   rr   rs   rS   r1   r4   r0   rT   rZ   rv   ry   r˜   rR   Úkindr(   r    r   r2   r9   r;   r©   r)   Úpd_arrayr'   ÚzerosÚshaper¢   r\   r^   r-   rU   Ú_MINIMUM_COMP_ARR_LENÚanyr6   r   ÚhtableÚismember)Úcompsr_   Úorig_valuesÚcomps_arrayr´   Úcommons         ra   r©   r©   í  s§  € ô ˜×ÑÜð(Ü(,¨U«×(<Ñ(<Ð'=¸Qð@ó
ð 	
ô ˜×ÑÜð(Ü(,¨V«×(=Ñ(=Ð'>¸aðAó
ð 	
ô
 �fœx¬Ô4EÄrÇzÁzÐR×SÑSÜ˜6“lˆÜ" ;¸.ÑIˆô �‹K˜!‹OØ—‘×!Ñ! WÓ,Ü+¨E×2Ñ2Ü" 6×1Ñ1ô =¸[ÓIˆFøä	�FœM×	*Ñ	*ä—’˜&Ó!‰ä˜v°TÈÑNˆä# E°VÑ<€KÜ ¸4Ñ@€KÜ�k¤2§:¡:×.Ñ.à×Ñ Ó'Ð'ä	˜[×.Ñ.×	/Ñ	/ä˜Ó$×)Ñ)¨&Ó1Ð1Ü	˜VŸ\™\×	*Ñ	*´?À;×CTÑCT×3UÑ3Uä�xŠx˜×)Ñ)´Ñ6Ð6ä	˜VŸ\™\×	*Ñ	*Ü�K§¡¬vÓ!6Ó7Ð7ä	�F—L‘L¤.×	1Ñ	1Ü”B—J’J˜{Ó+¬R¯ZªZ¸Ó-?Ó@Ð@ô 	ˆKÓÔ0Ó0Ü�‹K˜2ÓØ×Ñ¤Ó'ÜÑ,¡VÓ,×,Ñ,ô �‹<×Ñ×ÑóIñ 3‰Aô % V§\¡\°;×3DÑ3DÓEˆØ—‘˜v¨E�Ð2ˆØ!×(Ñ(¨°eÐ(Ð<ˆÜ�O‰Oˆáˆ[Ó!Ð!rb   c                ó  • U nU R                   R                  S;   a  [        n[        U 5      u  p`U" U=(       d    [	        U 5      5      nUR                  U SUUUS9u  p‰[        X…R                   U5      n[        U	5      n	X˜4$ )aÄ  
Factorize a numpy array to codes and uniques.

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

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

Returns
-------
codes : ndarray[np.intp]
uniques : ndarray
ÚmMéÿÿÿÿ)Úna_sentinelÚna_valuer¡   Ú	ignore_na)rR   r»   r   r‰   r˜   Ú	factorizerh   r   )
r_   Úuse_na_sentinelÚ	size_hintrË   r¡   rf   Ú
hash_klassr£   r¤   rY   s
             ra   Úfactorize_arrayrÑ   N  s‹   € ðH €HØ‡|�|×Ñ˜DÓ ô
 ˆä,¨VÓ4Ñ€Já�y×/¤C¨£KÓ0€EØ—_‘_ØØØØØ!ð %ð �N€Gô   ¯©¸ÓB€Gä Ó&€EØˆ>Ðrb   c                óÖ  • [        U [        [        45      (       a  U R                  XS9$ [	        U SS9n U n[        U [
        [        45      (       a!  U R                  b  U R                  US9u  pVXV4$ [        U [        R                  5      (       d  U R                  US9u  pVO‰[        R                  " U 5      n U(       d_  U R                  [        :X  aK  [        U 5      nUR                  5       (       a+  [        U R                  SS9n[        R                   " XxU 5      n [#        U UUS9u  pVU(       a  [%        U5      S	:”  a  ['        UUUS
SS9u  pe[)        XdR                  U5      nXV4$ )a¥  
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 : sequence
    A 1-D sequence. Sequences that aren't pandas objects are
    coerced to ndarrays before factorization.
sort : bool, default False
    Sort `uniques` and shuffle `codes` to maintain the
    relationship.
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
    Hint to the hashtable sizer.

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, str): ['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='str')

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])
)ÚsortrÎ   rÍ   rŸ   )rÓ   )rÎ   F)Úcompat)rÎ   rÏ   r   T)rÎ   Úassume_uniqueÚverify)rS   r1   r4   rÍ   ry   r/   r5   ÚfreqrT   rZ   rU   rR   r^   r6   rÀ   r7   ÚwhererÑ   r˜   Ú	safe_sortrh   )	r_   rÓ   rÎ   rÏ   rf   rY   r¤   Ú	null_maskrË   s	            ra   rÍ   rÍ   Œ  sQ  € ôP �&œ8¤YÐ/×0Ñ0Ø×Ñ TÐÐKÐKä˜v°Ñ=€FØ€Hô 	�6Ô,Ô.?Ð@×AÑAØ�K‰KÑ#ð  ×)Ñ)¨tÐ)Ð4‰ˆØˆ~Ðä˜¤§
¡
×+Ñ+à×)Ñ)¸/Ð)ÐJ‰ˆˆwô —’˜FÓ#ˆæ 6§<¡<´6Ó#9ô
 ˜V›ˆIØ�}‰}�‰Ü-¨f¯l©lÀ5ÑI�äŸš )°vÓ>�ä(ØØ+Øñ
‰ˆö ”�G“˜qÓ Ü"ØØØ+ØØñ
‰ˆô   ¯©¸ÓB€Gàˆ>Ðrb   c                ó”  • SSK JnJnJnJn	  [        U SS 5      n
U(       a  SOSnUbÐ  SSKJn  [        X5      (       a  U R                  n  U" XSS9nUR                  US
9nX¿l        XÿR                  R                  5          nUR                  R                  S5      Ul        UR!                  5       nU(       a1  UR                  S:H  R#                  5       (       a  UR$                  SS n['        U5      nGOxS n[)        U 5      (       a6  U" U SS9R                  R                  US
9nX¿l        X¯R                  l        GO0[        U [*        5      (       a\  [-        [/        U R0                  5      5      nU" XS9R3                  UUS9R5                  5       nU R6                  UR                  l        O¿[9        U SS9n [;        X5      u  nnnUR<                  [>        R@                  :X  a  UR                  [>        RB                  5      nU" UUR<                  U
SS9nU(       dF  [        XU	45      (       a4  URE                  U 5      (       a  U RF                  b  U RF                  Ul$        U" UUUSS9nU(       a  URK                  USS9nU(       a  Ub  UU-  nU$ XÿRM                  5       -  nU$ ! [         a  n[        S	5      UeS nAff = f)Nr   )ÚDatetimeIndexrA   rB   ÚTimedeltaIndexr‹   Ú
proportionÚcount)ÚcutT)Úinclude_lowestz+bins argument only works with numeric data.©ÚdropnaÚintervalFrK   )Úindexr‹   )Úlevelrã   Úvalue_countsrŸ   )rR   r‹   rL   )rå   r‹   rL   Ústable)Ú	ascendingr»   )'r“   rÜ   rA   rB   rÝ   ÚgetattrÚpandas.core.reshape.tilerà   rS   Ú_valuesrq   rç   r‹   rå   Únotnar\   Ú
sort_indexÚallÚilocr˜   r!   r2   rv   ÚrangeÚnlevelsÚgroupbyÚsizeÚnamesry   Úvalue_counts_arraylikerR   rT   Úfloat16r}   ÚequalsÚinferred_freqr×   Úsort_valuesr›   )r_   rÓ   ré   Ú	normalizeÚbinsrã   rÜ   rA   rB   rÝ   Ú
index_namer‹   rà   ÚiiÚerrrœ   Únormalize_denominatorÚlevelsÚkeysÚcountsÚ_Úidxs                         ra   Úvalue_counts_internalr  I  sƒ  € ÷ó ô ˜ ¨Ó.€JÞ$‰<¨'€DàÑÝ0ä�f×%Ñ%Ø—^‘^ˆFð	TÙ�V°$Ñ7ˆBð
 —‘¨�Ð/ˆØŒØŸ™×*Ñ*Ó,Ñ-ˆØ—|‘|×*Ñ*¨:Ó6ˆŒØ×"Ñ"Ó$ˆö �v—~‘~¨Ñ*×/Ñ/×1Ñ1Ø—[‘[  1Ð%ˆFô !$ B£Òð !%ÐÜ# F×+Ñ+á˜F¨Ñ/×7Ñ7×DÑDÈFÐDÐSˆFØŒKØ *�L‰LÖä˜¤×.Ñ.äœ% §¡Ó/Ó0ˆFá˜VÑ/ß‘˜v¨f�Ð5ß‘“ð ð
 "(§¡ˆF�L‰LÕô ' v¸ÑHˆFÜ4°VÓD‰OˆD�&˜!Ø�z‰zœRŸZ™ZÓ'Ø—{‘{¤2§:¡:Ó.�ñ ˜ D§J¡J°ZÀeÑLˆCö Ü˜v°~Ð'F×GÑGØ—J‘J˜v×&Ñ&Ø×(Ñ(Ñ4ð "×/Ñ/�”á˜F¨#°D¸uÑEˆFæØ×#Ñ#¨i¸hÐ#ÐGˆæØ Ñ,ØÐ3Ñ3ˆFð €Mð Ÿj™j›lÑ*ˆFà€MøôC ó 	TÜÐIÓJÐPSÐSûð	Tús   ÁJ, Ê,
KÊ6KËKc                óâ   • U n[        U 5      n [        R                  " XUS9u  pEn[        UR                  5      (       a  U(       a  U[
        :g  nXB   XR   pT[        XCR                  U5      nXuU4$ )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    )rW   rÁ   Úvalue_countr)   rR   r   rh   )r_   rã   r¡   rf   r  r  Ú
na_counterÚres_keyss           ra   rö   rö   ¨  sm   € ð €HÜ˜&Ó!€Fä%×1Ò1°&ÀtÑLÑ€D�*ä˜8Ÿ>™>×*Ñ*ö Øœ4‘<ˆDØ™: v¡|�&ä  §~¡~°xÓ@€HØ˜ZÐ'Ð'rb   c                óB   • [        U 5      n [        R                  " XUS9$ )a4  
Return boolean ndarray denoting duplicate values.

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

Returns
-------
duplicated : ndarray[bool]
)Úkeepr¡   )rW   rÁ   Ú
duplicated)r_   r  r¡   s      ra   r  r  Ç  s!   € ô2 ˜&Ó!€FÜ×Ò˜V°TÑ:Ð:rb   c                óþ  • [        U SS9n U n[        U R                  5      (       a&  [        U 5      n [	        SU 5      n U R                  US9$ [        U 5      n [        R                  " XUS9u  pEUc.  [        R                  " UR                  [        R                  S9nOXE4$  [        U5      n[%        XCR                  U5      nXu4$ ! [         a*  n[        R                   " SU 3[#        5       S	9   SnANHSnAff = f)
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
-------
Union[Tuple[np.ndarray, npt.NDArray[np.bool_]], ExtensionArray]
ÚmoderŸ   rD   râ   )rã   r¡   NrQ   zUnable to sort modes: )Ú
stacklevel)ry   r)   rR   r:   r   Ú_moderW   rÁ   r  rT   r½   r¾   Úbool_rÙ   rq   ÚwarningsÚwarnr   rh   )r_   rã   r¡   rf   ÚnpresultÚres_maskrÿ   rœ   s           ra   r  r  ä  sè   € ô" ˜v°Ñ8€FØ€Hä˜6Ÿ<™<×(Ñ(ä/°Ó7ˆÜÐ&¨Ó/ˆØ�|‰| 6ˆ|Ð*Ð*ä˜&Ó!€FäŸš VÀÑFÑ€HØÑÜ—8’8˜HŸN™N´"·(±(Ñ;‰àÐ!Ð!ð
Ü˜XÓ&ˆô ˜x¯©¸ÓB€FØÐÐøô ó 
Ü�ŠØ$ S EÐ*Ü'Ó)÷	
ûð
ús   Â$C Ã
C<Ã C7Ã7C<c           
     ó  • [        U R                  5      n[        U 5      n U R                  S:X  a  [        R
                  " U UUUUUUS9nU$ U R                  S:X  a!  Ub   e[        R                  " U UUUUUUS9nU$ [        S5      e)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).
mask : bool ndarray, optional
    Boolean array indicating which elements to exclude from ranking.
é   )Úis_datetimelikeÚties_methodré   Ú	na_optionÚpctr¡   rM   )Úaxisr  r  ré   r  r  z&Array with ndim > 2 are not supported.)r)   rR   rW   Úndimr	   Úrank_1dÚrank_2drq   )	r_   r  Úmethodr  ré   r  r¡   r  Úrankss	            ra   Úrankr#    s£   € ôD *¨&¯,©,Ó7€OÜ˜&Ó!€Fà‡{�{�aÓÜ—’ØØ+ØØØØØñ
ˆð. €Lð 
�‰˜Ó	Ø‰|Ðˆ|Ü—’ØØØ+ØØØØñ
ˆð €Lô Ð@ÓAÐArb   zpandas.api.extensionsc                óB  • [        U [        R                  [        [        [
        [        45      (       d"  [        S[        U 5      R                   S35      e[        U5      nU(       a'  [        XR                  U   5        [        U UUSUS9nU$ U R                  XS9nU$ )aÇ  
Take elements from an array.

Parameters
----------
arr : numpy.ndarray, ExtensionArray, Index, or Series
    Input array.
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])
zkpd.api.extensions.take requires a numpy.ndarray, ExtensionArray, Index, Series, or NumpyExtensionArray got rk   T)r  Ú
allow_fillÚ
fill_value)r  )rS   rT   rZ   r0   r1   r4   r3   rq   rr   rs   r   r<   r¾   r8   Útake)ÚarrÚindicesr  r%  r&  rœ   s         ra   r'  r'  W  s­   € ôb ØÜ	�‰Ô&¬´)Ô=SÐT÷ñ ô
 ð9Ü9=¸c»×9KÑ9KÐ8LÈAðOó
ð 	
ô
 " 'Ó*€Gæä˜§)¡)¨D¡/Ô2ô ØØØØØ!ñ
ˆð €Mð —‘˜'�Ð-ˆØ€Mrb   c                ó"  • Ub  [        U5      n[        U [        R                  5      (       GaG  U R                  R
                  S;   Ga,  [        U5      (       d  [        U5      (       Ga  [        R                  " U R                  R                  5      n[        U5      (       a  [        R                  " U/5      O[        R                  " U5      nXTR                  :¬  R                  5       (       a.  XTR                  :*  R                  5       (       a  U R                  nOUR                  n[        U5      (       a   [        [        UR                  U5      5      nO$[!        [        ["        U5      US9nO[%        U 5      n U R'                  XUS9$ )ao  
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.
ÚiurQ   )ÚsideÚsorter)r   rS   rT   rZ   rR   r»   r$   r%   Úiinforr   r9   Úminrï   Úmaxr   Úintr¼   r   r:   Úsearchsorted)r(  Úvaluer,  r-  r.  Ú	value_arrrR   s          ra   r2  r2  Í  s   € ð` ÑÜ$ VÓ,ˆô 	�3œŸ
™
×#Ò#Ø�I‰I�N‰N˜dÔ"Ü˜×ÑÔ"2°5×"9Ò"9ô —’˜Ÿ™Ÿ™Ó(ˆÜ)3°E×):Ñ):”B—H’H˜e˜WÔ%ÄÇÂÈÃˆ	ØŸ™Ñ"×'Ñ'×)Ñ)¨y¿I¹IÑ/E×.JÑ.J×.LÑ.Lð —I‘I‰Eà—O‘OˆEä�e×Ñäœ˜eŸj™j¨Ó/Ó0‰EäœT¤)¨UÓ3¸5ÑA‰Eô -¨SÓ1ˆð ×Ñ˜E°VÐÐ<Ð<rb   >   r„   rƒ   r‚   r�   r}   r|   c                óB  • [         R                  " U5      (       d;  [        U5      (       a  UR                  5       (       d  [        S5      e[	        U5      n[
        R                  nU R                  n[        U5      nU(       a  [        R                  nO[        R                  n[        U[        5      (       a  U R                  5       n U R                  n[        U [
        R                  5      (       d�  [!        U SUR"                   S35      (       aA  US:w  a$  [        S[%        U 5      R"                   SU 35      eU" X R'                  U5      5      $ [)        [%        U 5      R"                   S35      eSnU R                  R*                  S;   a*  [
        R,                  nU R/                  S	5      n [0        nS
nOcU(       a  [
        R2                  nOKUR*                  S;   a;  U R                  R4                  S;   a  [
        R6                  nO[
        R8                  nU R:                  nUS:X  a  U R=                  SS5      n [
        R                  " U5      n[
        R>                  " U R@                  US9n	[C        S5      /S-  n
US:¼  a  [C        SU5      O[C        US5      X¢'   X9[E        U
5      '   U R                  R4                  [F        ;   a   [H        RJ                  " X	[	        U5      X'S9  O…[C        S5      /S-  nUS:¼  a  [C        US5      O[C        SU5      X²'   [E        U5      n[C        S5      /S-  nUS:”  a  [C        SU* 5      O[C        U* S5      XÒ'   [E        U5      nU" X   X   5      Xœ'   U(       a  U	R/                  S5      n	US:X  a	  U	SS2S4   n	U	$ )a  
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
zperiods must be an integerÚ__r   zcannot diff z	 on axis=zK has no 'diff' method. Convert to a suitable dtype prior to calling 'diff'.FrÈ   rP   Tr+  )r„   rƒ   r  rÉ   rQ   NrM   )Údatetimelikeztimedelta64[ns])&r   r$   r"   Ú
ValueErrorr1  rT   ÚnanrR   r   ÚoperatorÚxorÚsubrS   r.   Úto_numpyrZ   Úhasattrrs   rr   Úshiftrq   r»   r�   r[   r   Úobject_r‹   r}   r|   r  ÚreshapeÚemptyr¾   Úsliceru   Ú_diff_specialr	   Údiff_2d)r(  Únr  ÚnarR   Úis_boolÚopÚis_timedeltaÚ	orig_ndimÚout_arrÚ
na_indexerÚ_res_indexerÚres_indexerÚ_lag_indexerÚlag_indexers                  ra   ÚdiffrR  (  sæ  € ô, �>Š>˜!×ÑÜ˜—‘ §¡§¡ÜÐ9Ó:Ð:Ü�‹FˆÜ	�‰€BØ�I‰I€Eä˜EÓ"€GÞÜ�\‰\‰ä�\‰\ˆä�%œ×&Ñ&à�l‰l‹nˆØ—	‘	ˆä�cœ2Ÿ:™:×&Ñ&ä�3˜"˜RŸ[™[˜M¨Ð,×-Ñ-Ø�q‹yÜ  <´°S³	×0BÑ0BÐ/CÀ9ÈTÈFÐ!SÓTÐTÙ�cŸ9™9 Q›<Ó(Ð(äÜ˜“9×%Ñ%Ð&ð 'Gð Góð ð
 €LØ
‡y�y‡~�~˜ÓÜ—‘ˆØ�h‰h�t‹nˆÜˆØ‰æ	ä—
‘
‰à	�‰�tÓ	ð
 �9‰9�>‰>Ð.Ó.Ü—J‘J‰Eä—J‘JˆEà—‘€IØ�Aƒ~à�k‰k˜"˜aÓ ˆô �HŠH�U‹O€EÜ�hŠh�s—y‘y¨Ñ.€Gä˜“+� Ñ"€JØ)*¨a«”u˜T 1”~´U¸1¸d³^€JÑØ!#ŒE�*ÓÑà
‡y�y‡~�~œÓ&ô 	�Š�c¤C¨£F¨DÓLô ˜d›�} qÑ(ˆØ/0°A«vœU 1 dœ^¼5ÀÀq»>ˆÑÜ˜LÓ)ˆä˜d›�} qÑ(ˆØ01°A³œU 4¨!¨œ_¼5À!ÀÀT»?ˆÑÜ˜LÓ)ˆá! #Ñ"2°CÑ4DÓEˆÑæØ—,‘,Ð0Ó1ˆà�Aƒ~Øš!˜Q˜$‘-ˆØ€Nrb   c                óð  • [        U [        R                  [        [        45      (       d  [        S5      eSn[        U R                  [        5      (       d%  [        R                  " U SS9S:X  a  [        U 5      nO" U R                  5       nU R                  U5      nUc  U$ [%        U5      (       d  [        S5      e['        [        R(                  " U5      5      nU(       d,  [+        [-        U 5      5      [+        U 5      :X  d  [/        S5      eUcI  [1        U 5      u  ppU" [+        U 5      5      nUR3                  U 5        ['        UR5                  U5      5      nU(       aD  UR                  5       n	U(       a"  U[+        U 5      * :  U[+        U 5      :¬  -  n
S	X'   [7        X‘S	S
9nOa[        R8                  " [+        U5      [:        S9nUR=                  U[        R>                  " [+        U5      5      5        UR                  USS9nU['        U5      4$ ! [
        [        R                  4 aF    U R                  (       a&  [        U S   [         5      (       a  [#        U 5      n GNÈ[        U 5      n GNÖf = f)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 valuesNFrl   rp   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&  rQ   Úwrap)r  ) rS   rT   rZ   r0   r1   rq   rR   r-   r   rt   Ú_sort_mixedÚargsortr'  ÚdecimalÚInvalidOperationrô   ru   Ú_sort_tuplesr&   r   rU   r˜   r‘   r8  r‰   Úmap_locationsÚlookupr8   rB  r1  ÚputÚarange)r_   rY   rÎ   rÕ   rÖ   r-  ÚorderedrÐ   ÚtÚorder2r¡   Ú	new_codesÚreverse_indexers                ra   rÙ   rÙ   ž  s  € ô` �fœrŸz™zÔ+<¼hÐG×HÑHÜð/ó
ð 	
ð
 €Fô �v—|‘|¤^×4Ñ4Ü�OŠO˜F¨5Ñ1°_ÓDä˜fÓ%‰ð	.Ø—^‘^Ó%ˆFØ—k‘k &Ó)ˆGð �}Øˆä˜×ÑÜð.ó
ð 	
ô  ¤§
¢
¨5Ó 1Ó2€Eæ¤¤V¨F£^Ó!4¼¸F»Ó!CÜÐGÓHÐHà�~ô
 1°Ó8Ñˆ
Ù”s˜6“{Ó#ˆØ	�‰˜Ôô % Q§X¡X¨gÓ%6Ó7ˆæà—‘Ó!ˆÞØœS ›[˜LÑ(¨U´c¸&³kÑ-AÑBˆDØˆE‰KÜ˜F°bÑ9‰	äŸ(š(¤3 v£;´cÑ:ˆØ×Ñ˜F¤B§I¢I¬c°&«kÓ$:Ô;ð $×(Ñ(¨°VÐ(Ð<ˆ	àÔ'¨	Ó2Ð2Ð2øôk œ7×3Ñ3Ð4ó 
	.ð �{�{œz¨&°©)´U×;Ñ;ô ' vÓ.“ä% fÓ-“ð
	.ús   Á=!H ÈAI5É&I5É4I5c           	     óZ  • [         R                  " U  Vs/ s H  n[        U[        5      PM     sn[        S9n[         R                  " U  Vs/ s H  n[        U5      PM     sn[        S9nU) U) -  n[         R                  " X   5      n[         R                  " X   5      nUR                  5       S   R                  U5      nUR                  5       S   R                  U5      nUR                  5       S   n	[         R                  " X‡U	/5      n
U R                  U
5      $ s  snf s  snf )z3order ints before strings before nulls in 1d arraysrQ   r   )
rT   r9   rS   Ústrr¢   r6   rW  Únonzeror'  Úconcatenate)r_   ÚxÚstr_posÚnull_posÚnum_posÚstr_argsortÚnum_argsortÚstr_locsÚnum_locsÚ	null_locsÚlocss              ra   rV  rV    sî   € ä�hŠh±FÓ;²F¨qœ
 1¤cÖ*±FÑ;Ä4ÑH€GÜ�xŠx©&Ó1ª& Qœ˜až©&Ñ1¼Ñ>€HØˆh˜(˜Ñ"€GÜ—*’*˜V™_Ó-€KÜ—*’*˜V™_Ó-€Kà�‰Ó  Ñ#×(Ñ(¨Ó5€HØ�‰Ó  Ñ#×(Ñ(¨Ó5€HØ× Ñ Ó" 1Ñ%€IÜ�>Š>˜8¨yÐ9Ó:€DØ�;‰;�tÓÐùò <ùÚ1s   •D#ÁD(c                óF   • SSK Jn  SSKJn  U" U S5      u  p4U" USS9nX   $ )zð
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.constructionrs  Úpandas.core.sortingrt  )r_   rs  rt  Úarraysr  Úindexers         ra   rZ  rZ  '  s,   € õ =Ý3á˜& $Ó'�I€FÙ˜f¨TÑ2€GØ‰?Ðrb   c                ó’  • SSK Jn  [        U SS9n[        USS9nUR                  USS9u  p4[        R
                  " UR                  UR                  5      nU" XSR                  SSS9n[        U [        5      (       a5  [        U[        5      (       a   U R                  U5      R                  5       nOd[        U [        5      (       a  U R                  n [        U[        5      (       a  UR                  n[        X/5      n[        U5      n[        U5      nUR!                  U5      R                  n[        R"                  " Xh5      $ )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   ©rB   Frâ   rT  r1  )rå   rR   rL   )r“   rB   r  ÚalignrT   Úmaximumr_   rå   rS   r2   Úappendr‘   r1   rì   r*   r:   ÚreindexÚrepeat)	ÚlvalsÚrvalsrB   Úl_countÚr_countÚfinal_countÚunique_valsÚcombinedÚrepeatss	            ra   Úunion_with_duplicatesr‰  6  s  € õ. ä# E°%Ñ8€GÜ# E°%Ñ8€GØ—}‘} W¸�}Ð;Ñ€GÜ—*’*˜WŸ^™^¨W¯^©^Ó<€KÙ˜¯M©MÀÈUÑS€KÜ�%œ×'Ñ'¬J°u¼m×,LÑ,LØ—l‘l 5Ó)×0Ñ0Ó2‰ä�eœX×&Ñ&Ø—M‘MˆEÜ�eœX×&Ñ&Ø—M‘MˆEô ! % Ó0ˆÜ˜XÓ&ˆÜ4°[ÓAˆØ×!Ñ! +Ó.×5Ñ5€GÜ�9Š9�[Ó*Ð*rb   c                ó‚  ^	• SSK Jn  US;  a  SU S3n[        U5      e[        U5      (       a   [	        U[
        5      (       a  [        US5      (       a	  Um	U	4S jnOqSSK Jn  [        U5      S:X  a  U" U[        R                  S	9nOF[	        U[
        5      (       a)  U" UR                  5       U" UR                  5       S
S9S9nOU" U5      n[	        U[        5      (       aU  US:X  a  XR                  R                  5          nUR                  R!                  U 5      n[#        UR$                  U5      nU$ [        U 5      (       d  U R'                  5       $ U R)                  [*        S
S9nUc  [,        R.                  " X�5      $ [,        R0                  " X�[3        U5      R5                  [        R6                  5      S9$ )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.

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.
r   )rA   )NÚignorez+na_action must either be 'ignore' or None, z was passedÚ__missing__c                ó’   >• T[        U [        5      (       a-  [        R                  " U 5      (       a  [        R                     $ U    $ rŽ   )rS   ÚfloatrT   r²   r9  )rh  Údict_with_defaults    €ra   r¹   Úmap_array.<locals>.<lambda>Š  s2   ø€ Ð0Ü$ Q¬×.Ñ.´2·8²8¸A·;±;”—‘ò ØDEò rb   r{  rQ   F)Útupleize_cols)rå   r‹  rK   r    )r“   rA   r8  r   rS   Údictr>  rB   r˜   rT   r|   r_   r  r4   rå   rí   Úget_indexerr8   rì   rL   r\   r^   r   Ú	map_inferÚmap_infer_maskr6   r[   rJ   )
r(  ÚmapperÚ	na_actionrA   ÚmsgrB   ry  Ú
new_valuesr_   r�  s
            @ra   Ú	map_arrayrš  e  ss  ø€ õ. àÐ(Ó(Ø;¸I¸;ÀkÐRˆÜ˜‹oÐô
 �F×ÑÜ�fœd×#Ñ#¬°¸×(FÑ(Fð !'Ðô‰Fõ &ä�6‹{˜aÓÙ ¬b¯j©jÑ9‘Ü˜F¤D×)Ñ)ÙØ—M‘M“O©5°·±³ÈeÑ+Tñ‘ñ   ›�ä�&œ)×$Ñ$Ø˜Ó ØŸL™L×.Ñ.Ó0Ñ1ˆFð —,‘,×*Ñ*¨3Ó/ˆÜ˜VŸ^™^¨WÓ5ˆ
àÐäˆs�8‰8Ø�x‰x‹zÐð �Z‰Zœ UˆZÐ+€FØÑÜ�}Š}˜VÓ,Ð,ä×!Ò! &´t¸F³|×7HÑ7HÌÏÉÓ7RÑSÐSrb   )r_   r   Úreturnú
np.ndarray)r_   r   rR   r   rf   r   r›  r   )rw   re  r›  r   )r_   rœ  r›  z)tuple[type[htable.HashTable], np.ndarray])r_   rœ  r›  re  )r_   rE   r›  rE   )r_   znp.ndarray | Seriesr›  rœ  )r_   r   r›  r1  rŽ   )r¡   únpt.NDArray[np.bool_] | None)rÃ   r=   r_   r=   r›  únpt.NDArray[np.bool_])TNNN)r_   rœ  rÎ   r¢   rÏ   ú
int | NonerË   r^   r¡   r�  r›  z'tuple[npt.NDArray[np.intp], np.ndarray])FTN)rÓ   r¢   rÎ   r¢   rÏ   rŸ  r›  z%tuple[np.ndarray, np.ndarray | Index])TFFNT)
rÓ   r¢   ré   r¢   rû   r¢   rã   r¢   r›  rB   )r_   rœ  rã   r¢   r¡   r�  r›  z,tuple[ArrayLike, npt.NDArray[np.int64], int])ÚfirstN)r_   r   r  zLiteral['first', 'last', False]r¡   r�  r›  rž  )TN)r_   r   rã   r¢   r¡   r�  r›  z9tuple[np.ndarray, npt.NDArray[np.bool_]] | ExtensionArray)r   Úaverager  TFN)r_   r   r  r   r!  re  r  re  ré   r¢   r  r¢   r¡   r�  r›  znpt.NDArray[np.float64])r   FN)r)  r   r  r   r%  r¢   )ÚleftN)
r(  r   r3  z$NumpyValueArrayLike | ExtensionArrayr,  zLiteral['left', 'right']r-  zNumpySorter | Noner›  znpt.NDArray[np.intp] | np.intp)r   )rF  z&int | float | np.integer | np.floatingr  r   )NTFT)r_   zIndex | ArrayLikerY   znpt.NDArray[np.intp] | NonerÎ   r¢   rÕ   r¢   rÖ   r¢   r›  z.AnyArrayLike | tuple[AnyArrayLike, np.ndarray])r›  r   )r_   rœ  r›  rœ  )r�  úArrayLike | Indexr‚  r£  r›  r£  )r(  r   r—  zLiteral['ignore'] | Noner›  z#np.ndarray | ExtensionArray | Index)†Ú__doc__Ú
__future__r   rX  r:  Útypingr   r   r   r   r   r  ÚnumpyrT   Úpandas._libsr	   r
   rÁ   r   r   Úpandas._libs.missingr   Úpandas._typingr   r   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(   r)   Úpandas.core.dtypes.concatr*   Úpandas.core.dtypes.dtypesr+   r,   r-   r.   Úpandas.core.dtypes.genericr/   r0   r1   r2   r3   r4   r5   Úpandas.core.dtypes.missingr6   r7   Úpandas.core.array_algos.taker8   Úpandas.core.constructionr9   r¼   r:   r;   Úpandas.core.indexersr<   r=   r>   r?   r“   r@   rA   rB   Úpandas.core.arraysrC   rD   rE   rW   rh   ry   Ú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'  r2  rD  rR  rÙ   rV  rZ  r‰  rš  r�   rb   ra   Ú<module>rÆ     s  ðñõ
 #ã Û ÷õ ó ã ÷ó õ $÷÷ ñ õ /Ý 4÷÷÷ ÷ ÷ ó õ$ 4÷ó ÷÷ ñ ÷õ
 1÷ñ õ
 2æ÷ñ ÷ñ ÷
ñ
 	�˜5 ;Ñ.°Ñ?Ñ@€AôK!ð\!,Øð!,Ø'ð!,Ø3?ð!,àô!,ôHð: ×,Ñ,Ø×*Ñ*Ø×&Ñ&Ø×&Ñ&Ø×$Ñ$Ø×$Ñ$Ø×$Ñ$Ø×"Ñ"Ø×"Ñ"Ø×"Ñ"Ø×"Ñ"Ø× Ñ Ø×$Ñ$Ø×&Ñ&ñ€ð$Øðà.ôô(ð6 
Û ó 
Ø Ø	Û :ó 
Ø :ñ ˆHÓñi$ó ði$ôXö.,ð8 €ð "Ð ô^"ðF !Ø ØØ)-ð;Øð;àð;ð ð;ð ð	;ð
 'ð;ð -õ;ñ| ˆHÓð Ø Ø ð	yà
ðyð ðyð ð	yð
 +ôyó ðyð| ØØØ	Øð[à
ð[ð ð[ð ð	[ð ð[ð õ[ð@ LPð(Øð(Ø $ð(Ø,Hð(à1õ(ðB -4Ø)-ð;Øð;à
)ð;ð 'ð;ð õ	;ð< RVð+Øð+Ø#ð+Ø2Nð+à>õ+ð` ØØØØØ)-ð=Øð=à
ð=ð ð=ð ð	=ð
 ð=ð 
ð=ð 'ð=ð õ=ñJ Ð#Ó$ð ØØðmàðmð ðmð ô	mó %ðmðp &,Ø!%ð	Q=Ø	ðQ=à/ðQ=ð #ðQ=ð ð	Q=ð
 $õQ=òp J€ölðp *.Ø ØØðw3Øðw3à&ðw3ð ðw3ð ð	w3ð
 ðw3ð 4õw3ôtôð,+Øð,+Ø%6ð,+àô,+ðd +/ðPTØ	ðPTð (ðPTð )ö	PTrb   