
    Mh(                       S SK Jr  S SK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  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&  \RN                  " S5      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r0S$S jr1g)%    )annotationsN)TYPE_CHECKINGcast)NaTlib)InvalidIndexError)find_common_type)	safe_sort)Index
_new_Indexensure_indexensure_index_from_sequencesget_unanimous_names)CategoricalIndex)DatetimeIndex)IntervalIndex)
MultiIndex)PeriodIndex)
RangeIndex)TimedeltaIndex)AxiszSorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.
)r   r   r   r   r   r   r   r   r   r   r   r   r   get_objs_combined_axisunion_indexesr   all_indexes_samedefault_indexsafe_sort_indexc                `    U  Vs/ s H  oUR                  U5      PM     nn[        XaX4S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.
copy : bool, default False
    If True, return a copy of the combined index.

Returns
-------
Index
)	intersectsortcopy)	_get_axis_get_combined_index)objsr   axisr   r    obj	obs_idxess          I/var/www/html/env/lib/python3.13/site-packages/pandas/core/indexes/api.pyr   r   H   s1    < 155t$I5yDTT 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/   j   sH    
 EC
Cc7#GGBsGJJsO  J    c                L   [        U 5      n [        U 5      S:X  a  [        / 5      nOT[        U 5      S:X  a  U S   nO?U(       a#  U S   nU SS  H  nUR                  U5      nM     O[	        U SS9n[        U5      nU(       a  [        U5      nU(       a  UR                  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.
copy : bool, default False
    If True, return a copy of the combined index.

Returns
-------
Index
r      NFr   )r/   lenr   intersectionr   r   r   r    )indexesr   r   r    indexothers         r'   r"   r"   x   s    4 !)G
7|qb		W	
	
QR[E&&u-E ! gE2U#&

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)r7   array_sorteds     r'   r   r      s     $$L ' lE**BJJ5eZ((**<{{KE L ,ZZu{{KEL   Ls   B' '
B54B5c                  ^ ^^ [        T 5      S:X  a  [        S5      e[        T 5      S:X  aD  T S   n[        U[        5      (       a(  T(       d  [	        U5      nU$ [	        [        U5      5      nU$ [        T 5      u  m nSU4S jjnU 4S jnUS:X  a  T S   nT  Vs/ s H  n[        U[        5      (       d  M  UPM     nnU Vs/ s H  ofR                  c  M  UPM     nn[        U5      S[        U5      4;  a  [        S5      e[        U5      [        T 5      :X  a  S	mT S   nO:[        U5      S:  a+  S
mT  Vs/ s H  ofR                  [        S
S9PM     snm T S   nT SS  H  n	UR                  U	T(       a  SOS
S9nM     U$ US:X  aa  U" T 5      n
T S   m[        U4S jT SS  5       5      (       d	  U" T U
5      m[        T 6 S   nUTR                  :w  a  TR!                  U5      mT$ U" T 5      n
U" T U
5      $ s  snf s  snf s  snf )z
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.

Returns
-------
Index
r   z#Must have at least 1 Index to unionr2   c           
        > [        S U  5       5      (       a  U  Vs/ s H  o"R                  USS9PM     n nU S   R                  5       nU S   R                  U SS 5      nXCR	                  U5      S:H     n[        U5      (       a  UR                  UR                  5       5      nT(       a  UR                  5       nU$ S	 n[        [        R                  " U  Vs/ s H
  ov" U5      PM     snTS
9US9$ s  snf s  snf )z
Concatenate indices and remove duplicates.

Parameters
----------
inds : list of Index or list objects
dtype : dtype to set for the resulting Index

Returns
-------
Index
c              3  B   #    U  H  n[        U[        5      v   M     g 7fN)r>   r   ).0inds     r'   	<genexpr>9union_indexes.<locals>._unique_indices.<locals>.<genexpr>   s     6#z#u%%s   Fr    r   r2      Nc                P    [        U [        5      (       a  U R                  5       n U $ rG   )r>   r   tolist)is    r'   conv4union_indexes.<locals>._unique_indices.<locals>.conv   s    !U##HHJHr0   r3   )r<   )
allastypeuniquer,   get_indexer_forr4   sort_valuesr   r   fast_unique_multiple_list)	indsr<   rI   resultr8   diffrR   rQ   r   s	           r'   _unique_indices&union_indexes.<locals>._unique_indices   s     6666=ABTcJJu5J1TDB!W^^%FGNN48,E//6"<=D4yyt{{}5++-M	
 ))D*ADq47D*AM
 	
 C  +Bs   C6C;c                   > T Vs/ s H&  n[        U[        5      (       d  M  UR                  PM(     nnU(       a  [        U5      nU$ SnU$ s  snf )z
Finds a common type for the indexes to pass through to resulting index.

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

Returns
-------
The common type or None if no indexes were given
N)r>   r   r<   r	   )rZ   idxdtypesr<   r6   s       r'   _find_common_index_dtype/union_indexes.<locals>._find_common_index_dtype	  sN     (/Iw*S%2H)#))wI$V,E  E Js
   AAspecialNz0Cannot join tz-naive with tz-aware DatetimeIndexTFrL   r3   arrayc              3  F   >#    U  H  nTR                  U5      v   M     g 7frG   equals)rH   r8   r7   s     r'   rJ    union_indexes.<locals>.<genexpr>>  s     @K55<<&&K   !)returnr   )r4   AssertionErrorr>   listr   sorted_sanitize_and_checkr   tzrB   rU   objectunionrT   r   r;   rename)r6   r   r[   kindr]   rb   xdtisdti_tzsr8   r<   r;   r7   s   ``          @r'   r   r      s     7|qBCC
7|qfd##v  vf~.'0MGT 
D( y"C7ajM&B7C"7ddd1d7w<3t9~-
 NOOt9G$DQZFY] D >EEWxxUx3WEGQZFQR[E\\%dd\FF !	(1
@GABK@@@#GU3E"G,Q/5::LL&E(1w..O D7& Fs   G?9G?HH;H	c                ~   [        U  Vs1 s H  n[        U5      iM     sn5      n[         U;   ad  [        U5      S:  aQ  U  Vs/ s H.  n[        U[        5      (       d  [	        [        U5      5      OUPM0     n nUR                  [         5        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   rm   rd   re   )rm   typer4   r>   r   remove)r6   r7   kindsru   s       r'   ro   ro   J  s    * 737%$u+734Eu}u:>KRKRajE&:&:d1gA7   LLF?"
5zA~e+	!! 4s   B5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rG   rg   )rH   r7   firsts     r'   rJ   #all_indexes_same.<locals>.<genexpr>  s     4uu||E""rj   )iternextrT   )r6   itrr~   s     @r'   r   r   p  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     s    
(C!!#D11r0   )Fr   TF)
r   boolr$   r   r   r   r    r   rk   r   )r#   list[Index]rk   r   )FFF)
r6   r   r   r   r   r   r    r   rk   r   )r7   r   rk   r   )T)r   zbool | Nonerk   r   )rk   r   )r   intrk   r   )2
__future__r   textwraptypingr   r   numpyr?   pandas._libsr   r   pandas.errorsr   pandas.core.dtypes.castr	   pandas.core.algorithmsr
   pandas.core.indexes.baser   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   dedent	_sort_msg__all__r   r/   r"   r   r   ro   r   r    r0   r'   <module>r      s   " 
  , 4 ,  : 7 6 0 2 0 9#OO		2 UU U 	U
 U UD  	--- - 	-
 -`D}/@# L5$2r0   