
    I j/%                    p   S SK Jr  S SKJrJr  S SKrS SKJrJ	r	  S SK
Jr  S SKJr  S SKJr  S SK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  S SKJr  S SKJ r   S SK!J"r"  S SK#J$r$  \(       a  S SK%J&r&  / SQr'   S       SS jjr(SS jr)  S       SS jjr*SS jr+S S!S jjr,S r-S"S jr.S#S jr/g)$    )annotations)TYPE_CHECKINGcastN)NaTlib)InvalidIndexError)find_common_type)	safe_sort)Index
_new_Indexensure_indexensure_index_from_sequencesget_unanimous_namesmaybe_sequence_to_range)CategoricalIndex)DatetimeIndex)IntervalIndex)
MultiIndex)PeriodIndex)
RangeIndex)TimedeltaIndex)Axis)r   r   r   r   r   r   r   r   r   r   r   all_indexes_samedefault_indexr   r   get_objs_combined_axisr   r   safe_sort_indexunion_indexesc                `    U  Vs/ s H  oDR                  U5      PM     nn[        XQUS9$ s  snf )a  
Extract combined index: return intersection or union (depending on the
value of "intersect") of indexes on given axis, or None if all objects
lack indexes (e.g. they are numpy arrays).

Parameters
----------
objs : list
    Series or DataFrame objects, may be mix of the two.
intersect : bool, default False
    If True, calculate the intersection between indexes. Otherwise,
    calculate the union.
axis : {0 or 'index', 1 or 'outer'}, default 0
    The axis to extract indexes from.
sort : bool, default True
    Whether the result index should come out sorted or not. NoDefault
    use for deprecation in GH#57335.

Returns
-------
Index
)	intersectsort)	_get_axis_get_combined_index)objsr   axisr    obj	obs_idxess         h/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pandas/core/indexes/api.pyr   r   ?   s1    8 155t$I5yDII 6s   +c                    [        5       n/ nU  H?  n[        U5      U;  d  M  UR                  [        U5      5        UR                  U5        MA     U$ )zR
Return a list with distinct elements of "objs" (different ids).
Preserves order.
)setidaddappend)r#   idsresr%   s       r'   _get_distinct_objsr/   _   sH    
 EC
Cc7#GGBsGJJsO  J    c                l   [        U 5      n [        U 5      S:X  a  [        S5      nOh[        U 5      S:X  a  U S   nOSU(       a#  U S   nU SS  H  nUR                  U5      nM     O)[	        X[
        R                  L a  UOSS9n[        U5      nU(       a  U[
        R                  La  [        U5      nU$ )a  
Return the union or intersection of indexes.

Parameters
----------
indexes : list of Index or list objects
    When intersect=True, do not accept list of lists.
intersect : bool, default False
    If True, calculate the intersection between indexes. Otherwise,
    calculate the union.
sort : bool, default False
    Whether the result index should come out sorted or not. NoDefault
    used for deprecation of GH#57335

Returns
-------
Index
r      NFr    )	r/   lenr   intersectionr   r   
no_defaultr   r   )indexesr   r    indexothers        r'   r"   r"   m   s    0 !)G
7|q$Q'	W	
	
QR[E&&u-E ! gCNN4JDPUVU#CNN*&Lr0   c                p   U R                   (       a  U $  [        U 5      n[        U[        5      (       a  U$ [	        [
        R                  U5      n[        U [        5      (       a   [        R                  " XR                  S9n U $ [        XR                  U R                  S9n  U $ ! [         a     U $ f = f)z
Returns the sorted index

We keep the dtypes and the name attributes.

Parameters
----------
index : an Index

Returns
-------
Index
)names)namedtype)is_monotonic_increasingr
   
isinstancer   r   npndarrayr   from_tuplesr;   r<   r=   	TypeError)r8   array_sorteds     r'   r   r      s     $$L ' lE**BJJ5eZ((**<{{KE L ,ZZu{{KEL   Ls   B' '
B54B5c                <   [        U 5      S:X  a  [        S5      e[        U 5      S:X  aW  U S   n[        U[        5      (       a;  U(       a  U[        R
                  L a  [        U5      nU$ [        [        U5      5      nU$ [        U 5      u  pUS:X  a  U S   nSnSnU  H3  n[        U[        5      (       d  M  US-  nUR                  c  M.  US-  nM5     USU4;  a  [        S5      eU[        U 5      :X  a  U[        R
                  L a  SnU S   nO0US:  a*  SnU  Vs/ s H  owR                  [        SS	9PM     n nU S   nU SS  H  nUR                  X(       a  SOSS
9nM     U$ US:X  Ga  [        U 5      (       d  [!        U  Vs/ s H  ofR"                  PM     sn5      n	U  V
s/ s H  oR                  U	SS	9PM     nn
US   R%                  5       nUS   R'                  USS 5      nXR)                  U5      S:H     n[        U5      (       a  UR'                  UR%                  5       5      nU(       a  UR+                  5       nOU S   n[-        U 6 S   nXR.                  :w  a  UR1                  U5      nU$ US:X  aw  U  Vs/ s H&  n[        U[        5      (       d  M  UR"                  PM(     nnU(       a  [!        U5      n	OSn	S U  5       n[        [        R2                  " U[5        U5      S
9U	S9$ [7        SU< S35      es  snf s  snf s  sn
f s  snf )a-  
Return the union of indexes.

The behavior of sort and names is not consistent.

Parameters
----------
indexes : list of Index or list objects
sort : bool, default True
    Whether the result index should come out sorted or not. NoDefault
    used for deprecation of GH#57335.

Returns
-------
Index
r   z#Must have at least 1 Index to unionr2   specialNz0Cannot join tz-naive with tz-aware DatetimeIndexTF)copyr3   array   listc              3  p   #    U  H,  n[        U[        5      (       a  UR                  5       OUv   M.     g 7fN)r?   r   tolist).0idxs     r'   	<genexpr> union_indexes.<locals>.<genexpr>  s)     XPWZU%;%;SZZ\DPWs   46)r=   zkind=z& must be 'special', 'array' or 'list'.)r4   AssertionErrorr?   rK   r   r6   r   sorted_sanitize_and_checkr   tzrC   astypeobjectunionr   r	   r=   uniquer,   get_indexer_forsort_valuesr   r<   renamefast_unique_multiple_list_genbool
ValueError)r7   r    resultkindnum_dtisnum_dti_tzsrP   xr9   r=   indindsr8   diffr<   dtypes	all_listss                    r'   r   r      s   " 7|qBCC
7|qfd##43>>1v  vf~.'0MGyC#}--A66%1$K	 
 q(m+
 NOOs7|#s~~%QZF\ D >EEWxxUx3WGEQZFQR[E\\%dd\FF !	(($7%C7Cii7%CDE=DEWcJJu5J1WDEGNN$EGNN48,E..u5;<D4yyT[[]3))+AJE"G,Q/::LL&E	'.Iw*S%2H)#))wI$V,EEXPWX	--id4jI
 	

 ED7"HIJJK F &DE  Js   L
	L)LL$Lc                T   U  Vs1 s H  n[        U5      iM     nn[        U;   aY  [        U5      S:  aF  U  Vs/ s H.  n[        U[        5      (       d  [	        [        U5      5      OUPM0     n nU[        1-  nOU S4$ [        U5      S:  d
  [        U;  a  U S4$ U S4$ s  snf s  snf )a  
Verify the type of indexes and convert lists to Index.

Cases:

- [list, list, ...]: Return ([list, list, ...], 'list')
- [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...])
    Lists are sorted and converted to Index.
- [Index, Index, ...]: Return ([Index, Index, ...], TYPE)
    TYPE = 'special' if at least one special type, 'array' otherwise.

Parameters
----------
indexes : list of Index or list objects

Returns
-------
sanitized_indexes : list of Index or list objects
type : {'list', 'array', 'special'}
r2   rK   rF   rH   )typerK   r4   r?   r   )r7   r8   kindsre   s       r'   rU   rU     s    * '..gUT%[gE.u}u:>KRKRajE&:&:d1gA7   dVOEF?"
5zA~e+	!! /s
   B 5B%c                Z   ^ [        U 5      n[        U5      m[        U4S jU 5       5      $ )z
Determine if all indexes contain the same elements.

Parameters
----------
indexes : iterable of Index objects

Returns
-------
bool
    True if all indexes contain the same elements, False otherwise.
c              3  F   >#    U  H  nTR                  U5      v   M     g 7frM   )equals)rO   r8   firsts     r'   rQ   #all_indexes_same.<locals>.<genexpr>Q  s     4uu||E""s   !)iternextall)r7   itrrq   s     @r'   r   r   B  s(     w-CIE4444r0   c                B    [        U 5      n[        R                  " US S9$ )N)r<   )ranger   _simple_new)nrngs     r'   r   r   T  s    
(C!!#D11r0   )Fr   T)r   r_   r$   r   r    bool | lib.NoDefaultreturnr   )r#   list[Index]r}   r~   )FF)r7   r~   r   r_   r    r|   r}   r   )r8   r   r}   r   )T)r    r|   r}   r   )r}   r_   )rz   intr}   r   )0
__future__r   typingr   r   numpyr@   pandas._libsr   r   pandas.errorsr   pandas.core.dtypes.castr	   pandas.core.algorithmsr
   pandas.core.indexes.baser   r   r   r   r   r   pandas.core.indexes.categoryr   pandas.core.indexes.datetimesr   pandas.core.indexes.intervalr   pandas.core.indexes.multir   pandas.core.indexes.periodr   pandas.core.indexes.ranger   pandas.core.indexes.timedeltasr   pandas._typingr   __all__r   r/   r"   r   r   rU   r   r    r0   r'   <module>r      s    "
  , 4 ,  : 7 6 0 2 0 9#4 !%	JJ J 	J
 J@  !&''' ' 	'TD`KF# L5$2r0   