o
    d                     @   s  d dl Zd dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZmZ d dlmZ d;ddZG dd dZd<ddZdd Zdd Zdd Zd=ddZdd Zejddddgfdddgfgdd Zdd  Zejd!d"d#gg d$fd%d&gg d'fd(d)gg d*fe
d+e
d,ge
d+e
d,e
d,gfgd-d. Zejd/g d0d1d2 Zejd3d4g d5fd6g d5fd	g d5fd7g d8fgd9d: ZdS )>    N)Categorical	DataFrameIndex
MultiIndexSeries	Timestampconcatmerge   2   c                 C   s`   t t| }tt|||  }t||k r(tt ||d |t|   }tj| |S N)listrangenpasarraytilelenrandomshuffle)ngroupsnunique_groupsarr r   i/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/pandas/tests/reshape/merge/test_join.pyget_test_data   s   "r   c                
   @   s~  e Zd Zejdd Zejdd Zejdd Zdd Zd	d
 Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zejddddedd ggd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Z d7d8 Z!d9d: Z"d;d< Z#d=d> Z$d?d@ Z%dAdB Z&dCdD Z'dEdF Z(dGdH Z)dIdJ Z*dKdL Z+dMdN Z,dOdP Z-dQdR Z.dSdT Z/dUdV Z0dS )WTestJoinc                 C   s:   t t t tjdtjdd}||d dk }|S )Nr   )key1key2data1data2r      r   r   r   r   randn)selfdfr   r   r   r%      s   


zTestJoin.dfc                 C   s&   t tddtdddtjddS )N
   )r      )r   r   )r   r   valuer"   )r$   r   r   r   df2.   s   

zTestJoin.df2c                 C   s>   t  \}}t||d}t|d |d d|d d}||fS )NindexAD)MergedAMergedDC)tmgetMixedTypeDictr   )r$   r+   datatargetsourcer   r   r   target_source8   s   zTestJoin.target_sourcec                 C   sF   t ||dd}t|||dgdd t ||}t|||ddgdd d S )Nr   onlefthowr   r	   _check_joinr$   r%   r)   joined_key2joined_bothr   r   r   test_left_outer_joinD   s   
zTestJoin.test_left_outer_joinc                 C   L   t ||ddd}t|||dgdd t ||dd}t|||ddgdd d S )Nr   rightr8   r;   r:   r   r<   r>   r   r   r   test_right_outer_joinK      zTestJoin.test_right_outer_joinc                 C   rB   )Nr   outerrD   r:   r   r<   r>   r   r   r   test_full_outer_joinR   rF   zTestJoin.test_full_outer_joinc                 C   rB   )Nr   innerrD   r:   r   r<   r>   r   r   r   test_inner_joinY   rF   zTestJoin.test_inner_joinc                 C   s,   t ||ddd}d|v sJ d|v sJ d S )Nr   z.fooz.bar)r8   suffixeskey1.foozkey1.barr	   r$   r%   r)   joinedr   r   r   test_handle_overlap`   s   zTestJoin.test_handle_overlapc                 C   s.   t ||dddd}d|v sJ d|v sJ d S )Nr   r   rK   )left_onright_onrL   rM   zkey2.barrN   rO   r   r   r   !test_handle_overlap_arbitrary_keyf   s   z*TestJoin.test_handle_overlap_arbitrary_keyc                 C   s  |\}}|j |dd}tj|d |d dd tj|d |d dd td	g d
i}tdg dig dd}|j |d	d}tg d
g dd}t|| tdgdgdggg ddgd}	tdgdggddgdgd}
tdgdggddgdgd}|	j |
dd}|j |dd}t|d d sJ t|d d sJ tjt	dd |j |dd W d    n1 sw   Y  |
 }d|d< d}tjt|d |j |dd W d    d S 1 sw   Y  d S ) Nr0   r7   r.   r,   F)check_namesr/   r-   keyarX   brY   cr(   r   r!      rX   rY   rZ   r*   )r   r   r!   r!   r\   rV   r(   r!   r\      oner+   columnsfoobartwothreerZ   z^'E'$matchEr   zfYou are trying to merge on float64 and object columns. If you wish to proceed you should use pd.concat)joinr1   assert_series_equalr   assert_frame_equalr   isnanpytestraisesKeyErrorcopy
ValueError)r$   r6   r4   r5   mergedr%   r)   rP   expecteddf_adf_bdf_csource_copymsgr   r   r   test_join_onq   s8    "zTestJoin.test_join_onc                 C   s   t tjjddgddtjdd}t tjjddgddtjddtddd}d	}tjt	|d
 t
||ddd W d    d S 1 sIw   Y  d S )Nmfr_   sizerX   rY   r&   r\   r*   Flen\(left_on\) must equal the number of levels in the index of "right"rg   rX   TrR   right_indexr   r   r   choicer#   r1   makeCustomIndexrn   ro   rr   r	   r$   r%   r)   ry   r   r   r   -test_join_on_fails_with_different_right_index   s     
"z6TestJoin.test_join_on_fails_with_different_right_indexc                 C   s   t tjjddgddtjddtddd}t tjjddgddtjdd}d	}tjt	|d
 t
||ddd W d    d S 1 sIw   Y  d S )Nr{   r|   r_   r}   r   r\   r*   r&   zFlen\(right_on\) must equal the number of levels in the index of "left"rg   rY   T)rS   
left_indexr   r   r   r   r   ,test_join_on_fails_with_different_left_index   s    
 "z5TestJoin.test_join_on_fails_with_different_left_indexc                 C   s   t tjjddgddtjdd}t tjjddgddtjddtddd}d	}tjt	|d
 t
||dddgd W d    d S 1 sKw   Y  d S )Nr{   r|   r_   r}   r   r&   r\   r*   z)len\(right_on\) must equal len\(left_on\)rg   rX   rY   )rS   rR   r   r   r   r   r   /test_join_on_fails_with_different_column_counts   s     
"z8TestJoin.test_join_on_fails_with_different_column_counts
wrong_typer\   strNr   r!   c                 C   s   t dddgi}dt| d}tjt|d t||ddd W d    n1 s*w   Y  tjt|d t||ddd W d    d S 1 sJw   Y  d S )NrX   r!   z.Can only merge Series or DataFrame objects, a z was passedrg   )rR   rS   )r   typern   ro   	TypeErrorr	   )r$   r   r%   ry   r   r   r   )test_join_on_fails_with_wrong_object_type   s   "z2TestJoin.test_join_on_fails_with_wrong_object_typec                 C   sD   |\}}|j |dd}|d= |d}|j ||d}t|| d S )Nr0   r7   )rj   popr1   rl   )r$   r6   r4   r5   rt   join_colresultr   r   r   test_join_on_pass_vector   s   
z!TestJoin.test_join_on_pass_vectorc                 C   s   |\}}|j |g dd}|D ]}||v sJ ||   s"J q|j |g ddd}t|j|j t|dks>J d S )Nr0   r7   rI   rD   r   )rj   reindexisnaallr1   assert_index_equalrb   r   )r$   r6   r4   r5   rs   colmerged2r   r   r   test_join_with_len0   s   zTestJoin.test_join_with_len0c                 C   s   t dg di}t dddgiddgd}|j|dd	d
}|j|dd}||d   }t|d |d  tj|d |d dd t|j|j d S )NrV   )rX   rX   drY   rY   rZ   r(   r   r!   rX   rY   r*   rI   rD   r7   F)check_dtype)r   rj   notnar1   rk   r   r+   r$   r%   r)   rP   rt   r   r   r   test_join_on_inner   s   zTestJoin.test_join_on_innerc                 C   sV   t dg di}t dg dig dd}|j|dgd}|j|dd}t|| d S )NrV   rW   r(   r[   r]   r*   r7   r   rj   r1   rl   r   r   r   r   test_join_on_singlekey_list   s
   z$TestJoin.test_join_on_singlekey_listc                 C   s>   |\}}|j |d dd}|j |dg dd}t|| d S )Nr.   r0   r7   rj   r1   rl   )r$   r6   r4   r5   r   rt   r   r   r   test_join_on_series   s   zTestJoin.test_join_on_seriesc                 C   s\   t dddgi}tdgdgdd}|j|dd}t ddgddgd|jd}t|| d S )	NrX   r!   r\   rY   r+   namer7   r   r*   )r   r   rj   r+   r1   rl   )r$   r%   dsr   rt   r   r   r   test_join_on_series_buglet   s
   z#TestJoin.test_join_on_series_bugletc                 C   s   t tdd}d|d< d|d< t tddd}d	|d
< d|d< |j||d}t|||d}t|| |j||d}t|||d}t|| d S )Nr&   r*   Tboolrc   string      r!   int      ?floatr:   )r   r   arangerj   _join_by_handr1   rl   )r$   	join_typedf1r)   rP   rt   r   r   r   test_join_index_mixed  s   zTestJoin.test_join_index_mixedc                 C   s   t dddddtdg dd}|d jtjksJ |d	 jtjks%J t dddddtd
ddg dd}|j|ddd}g d}|d d |_|dd  |_t||}t	
|| d S )Nr   r\   rc   Tr,   Br0   r-   r&   ra   r   r-   r   _one_twolsuffixrsuffix)A_oneB_oneC_oneD_oneA_twoB_twoC_twoD_twor'   )r   r   r   dtypeint64bool_rj   rb   r   r1   rl   )r$   r   r)   rP   expected_columnsrt   r   r   r   test_join_index_mixed_overlap  s$   

z&TestJoin.test_join_index_mixed_overlapc                 C   s(   t  }|jt dgdgdgddd d S )Nr_   r   r,   ra   rG   r:   )r   rj   )r$   xr   r   r   test_join_empty_bug8  s   "zTestJoin.test_join_empty_bugc                 C   sb   t tjddddgd}ttjd}||d< t tjdddgd}|| || d S )	N   r\   rX   rY   rb   rZ   r!   q)r   r   r   r#   r   rj   )r$   rX   rZ   r   r   r   r   test_join_unconsolidated=  s   
z!TestJoin.test_join_unconsolidatedc                 C   sl  t jg dg dgddgd}t jg dg dgddgd}ttjd|dgd	}ttjd|d
gd	}|jdd}|jdd}|j|dd}t|j	
t|j	}||||}|j|j_t|| |jj|jkssJ |jdd}|jdd}|j|ddjdd}t|j	
t|j	}||||}|j|j_t|| |jj|jksJ d S )N)rX   rX   rX   rY   rY   rY   )r!   r\   r_   r!   r\   r_   firstsecondnames)rY   rY   rY   rZ   rZ   rZ      zvar X)r3   r+   rb   zvar Yr   )levelrG   r:   r!   )r   from_arraysr   r   r   r#   
sort_indexrj   r   valuesunionr   r   r+   r1   rl   )r$   index1index2r   r)   rP   ex_indexrt   r   r   r   test_join_multiindexH  s4   

zTestJoin.test_join_multiindexc           
      C   s   g d}g d}t jt|}t|||d}|}tt jdd|g dd}|j|dd	gd
d}t|| dd	gddgd
dd}t||dd	gdd
dd}	t	||	
| t||dd	gdd
dd}	|jddgdd}|j|_|jjsvJ t	|| d S )N)
rd   rd   rd   rc   rc   bazr   quxr   snap)
re   r`   rf   r`   re   r`   re   re   rf   r`   )r   r   r3   r&   r_   )j_onej_twoj_threera   r   r   rI   rD   r   r   F)rR   rS   r;   sortT)rS   r   r;   r   r!   axis)r   r   r#   r   r   rj   r	   reset_indexr1   rl   reindex_likedropr+   is_monotonic_increasing)
r$   %lexsorted_two_level_string_multiindexr   r   r3   r+   to_joinrP   rt   	expected2r   r   r   test_join_inner_multiindexk  sL   		z#TestJoin.test_join_inner_multiindexc                 C   s   t ddgg dd}|dgdtjtjgi}t ddgg dd}|jdd	d
 tjt	j
jdd t||d	d	d W d    d S 1 sGw   Y  d S )N)r!   r\   r_   )r'   r   r   r]   r   rX   rY   )   r&   r   rX   rY   r   T)inplacez-Not allowed to merge between different levelsrg   r   r   )r   groupbyaggr   meansum	set_indexrn   ro   pderrors
MergeErrorr	   )r$   r%   new_dfother_dfr   r   r   #test_join_hierarchical_mixed_raises  s   "z,TestJoin.test_join_hierarchical_mixed_raisesc           
      C   sh  t tjddddgtjd}t tjdddgtjd}||}|jd dks+J |jd dks4J |jd d	ks=J tjd
dd	d}tjd	d}tjd	d	}t |||d}t |||d}t tjd	d	dgd}|j
|ddd}|jd dksJ |jd dksJ |jd d	ksJ |jd d	ksJ |j
|ddd}	t||	 d S )Nr&   r\   rX   rY   rb   r   r!   rZ   float64float32r   r   d   r   r]   mdr   Tr   )r   r   r   r#   r   r   rj   dtypesrandintastyper	   r1   rl   )
r$   rX   rY   rP   rZ   r%   xpdfsrsxpr   r   r   test_join_float64_float32  s&   
z"TestJoin.test_join_float64_float32c                 C   s  t ddgddgddgd}t ddgddgddgd}t ddgddgd	d
gd}|ddg}|ddg}|ddg}|j||gdd}t||ddgdd}t||ddgdd}	| }|	|j }	|	jd|	d< |	jd|	d< t	
||	 t g dg dg dd}t g dg dg dd}t g dg dg dd}|ddg}|ddg}|ddg}|j||gdd}t||ddgdd}t||ddgdd}	| }t	
||	jd d |jf  t g dg dtjdtjdd}
tttddttdddd}|
j|dd}|
j|dd}|
j|dd}|
j|dd}t	
|| t	
|| t	
|| d S ) Nr!   r&      r]   r\   r      r       )rX   rY   erX   rY   rG   r:   rD   r   )r!   r!   r!   )r&   r	  r   )r!   r!   r\   )r   r
  i,  )r  r  i  rI   )rc   rd   rc   rd   rc   rd   rc   rc   )r`   r`   re   rf   re   re   r`   rf   r
   r   TESTr   r9   rC   )r   r   rj   r	   r   rb   rX   r  rY   r1   rl   locr   r   r#   r   repeatr   )r$   r   r)   df3idf1idf2idf3r   df_partially_mergedrt   r%   r  rI   rG   r9   rC   r   r   r   test_join_many_non_unique_index  sT   


"z(TestJoin.test_join_many_non_unique_indexc                 C   s   t g dg dd}t dg dig dd}|j|dd	d
}t g dg dg ddg dd}t|| |j|ddd
}tj|jttdd	d d S )N)rc   rd   r   rc   r!   r\   r_   r'   r^   value2r]   )rd   r   rc   r*   rV   T)r8   r   )rd   r   rc   rc   )r\   r_   r!   r'   )rX   rY   rZ   rZ   )rV   r(   r  )r!   r\   r   r_   Fr'   )exact)r   rj   r1   rl   r   r+   r   r   )r$   r9   rC   rP   rt   r   r   r   test_join_sort  s   zTestJoin.test_join_sortc                 C   s   t dg dig dd}t dg dig dd}||}t g dd	tjd
dtjgdg dd}t|| t dg dig dd}t dg dig dd}||}t g dd	d
d
tjgdg dd}t|| d S )NrX   r  )r!   r\   r_   rX   r*   rY   )r   r   r   r
   )r!   r_   r_   r'   )r!   r\   r_   r_   r'   r   r   r   r   )r!   r\   r_   r_   rX   )r!   r\   r\   rX   )r   rj   r   nanr1   rl   )r$   r   r)   r   rt   r  df4r   r   r    test_join_mixed_non_unique_index  s   

z)TestJoin.test_join_mixed_non_unique_indexc                 C   s   t jdddd}tttt||dgd}t||g}|j|ddd	}tt	tj
dtjd
ddddddg| jd}t|| d S )Nz
2016-01-01   M)periodsfreqpnumra   rI   _df2)r;   r   r   r\   r!   pnum_df2rb   r+   )r   period_ranger   r   r   r   r   rj   r   r   r   r   r  reshaper   r+   r1   rl   )r$   r+   r%   r)   r   rt   r   r   r   !test_join_non_unique_period_index'  s   $z*TestJoin.test_join_non_unique_period_indexc                 C   s   t tjddg dd}|ddd |ddd	 |d}tjtd
d |	  W d    n1 s6w   Y  |j	dd}|
 }|j|dd d S )Nr	  r   )rX   rY   rZ   r   r  r|   r   r   idr   dtrc   zCould not convertrg   T)numeric_only_rightr   )r   r   r   r#   insertr   rn   ro   r   r   countrj   )r$   r%   groupedmncnr   r   r    test_mixed_type_join_with_suffix4  s   

z)TestJoin.test_mixed_type_join_with_suffixc                 C   sr  t tjddtdd}|ddg |ddg |d	d
g g}|d |dd  }t|| |ddg d d |ddg dd  |d	d
g dd g}dd }|d j|dd  dd}||||j |d |dd  }||||d j |d j|dd  dd}||||jdd  d}t	j
t|d |d j|dd  dd W d    d S 1 sw   Y  d S )Nr&   r   abcdefr   rX   rY   rZ   r   r  r|   r   r!   r\   	   c                    s8    fdd| D }|d  |dd  }t|| d S )Nc                    s   g | ]}|  qS r   )r   ).0r   	exp_indexr   r   
<listcomp>M  s    zFTestJoin.test_join_many.<locals>._check_diff_index.<locals>.<listcomp>r   r!   r   )df_listr   r;  	reindexedrt   r   r:  r   _check_diff_indexL  s   z2TestJoin.test_join_many.<locals>._check_diff_indexrG   r:   rI   r
   z?Joining multiple DataFrames only supported for joining on indexrg   r7   )r   r   r   r#   r   rj   r1   rl   r+   rn   ro   rr   )r$   r%   r=  rP   r?  ry   r   r   r   test_join_manyC  s    ":"zTestJoin.test_join_manyc                 C   s   t tjddg dd}ddgd |d< |jd d dd	gf }|jd d d
dgf }|jd d dgf }|||g}t|| d S )Nr
   r'   r   r   rc   rd   rV   r,   r   r0   r-   )r   r   r   r#   r  rj   r1   rl   )r$   r%   r   r)   r  r   r   r   r   test_join_many_mixed_  s   zTestJoin.test_join_many_mixedc           	      C   sH  t ttjddg ddttjjddddddd	d
gdgdd}t ||gdd}|j|dd}|j|_t	
|| ttjddddgd}ttjddddgd}ttjddddgd}ttjddddgd}|j|dddj|dddd}tjtjjdd |j|ddd W d    d S 1 sw   Y  d S )Nr&   r'   )r,   r,   r   r   r   r   r	  r}   r\   r,   r0   r!   r   _2r/  r   yTr   rG   )r   r   r;   z0Passing 'suffixes' which cause duplicate columnsrg   )r   r   r   r   r#   r  r)  rj   rb   r1   rl   r	   rn   ro   r   r   r   )	r$   r%   rt   r   wr   rC  zdtar   r   r   test_join_dupsi  s2   
"zTestJoin.test_join_dupsc           	      C   sF  t jtdtdddggg dd}tdtdi|d	}t jtdtdgddgd}td
dd tddD i|d	}|j|ddg|d}| j| ddg|dg d}t	
|| d}tjt|d |j|d|d W d    n1 szw   Y  tjt|d |j|ddg|d W d    d S 1 sw   Y  d S )Nabcxyr!   r\   )rH  rI  numr   v1   r*   v2c                 S   s   g | ]}d | qS )r   r   )r9  ir   r   r   r<        z5TestJoin.test_join_multi_to_multi.<locals>.<listcomp>r   rD   r   rg   )r   from_productr   r   r   rj   r   r	   r   r1   rl   rn   ro   rr   )	r$   r   	leftindexr9   
rightindexrC   r   rt   ry   r   r   r   test_join_multi_to_multi  s,    
"z!TestJoin.test_join_multi_to_multic                 C   s   t tjddddtdd}t tjddddtdd	}|j|d
d
d}| }ttj	gd td t
d|d< t|| d S )Nz
2018-01-01r   zAmerica/Chicago)startr   tzabcde)datevalsz
2018-01-03tuvwx)rW  vals_2rW  r7   r\   tuvr$  rZ  )r   r   
date_ranger   rj   r   rq   r   r   r  objectr1   rl   )r$   r   r)   r   rt   r   r   r   #test_join_on_tz_aware_datetimeindex  s$   	 z,TestJoin.test_join_on_tz_aware_datetimeindexc                 C   s   t g dg dg dg dgg dd}t|d |d< t g dg d	gg d
ddgd}t|d |d< |j|ddgddgd}t tddddgtddddggddgg dd}t|| d S )N)
2012-08-02Lr&   )r_  Jr   )
2013-04-06r`  r	  )rb  ra     )r   rC  rX   r   r   )r_  ra  r!   )rb  r`  r\   )r   rC  rE  r\   r'   r'  rC  r7   z2012-08-02 00:00:00ra  r!   r   z2013-04-06 00:00:00r`  r	  )r   rC  rE  rX   ra   )r   r   to_datetimerj   r   r   r1   rl   )r$   dfadfbr   rt   r   r   r   test_join_datetime_string  s0   	z"TestJoin.test_join_datetime_stringc                 C   s   ddg}t j||d}t jt|t|d}td|i|d}tdt|i|d}||}tddgddgdt jddgddgdd}t|| d S )NrX   rY   
categoriesc1r*   c2)rj  rk  )r   CategoricalIndexreversedr   rj   r1   rl   )r$   ixid1id2r   r)   r   rt   r   r   r    test_join_with_categorical_index  s   
z)TestJoin.test_join_with_categorical_index)1__name__
__module____qualname__rn   fixturer%   r)   r6   rA   rE   rH   rJ   rQ   rT   rz   r   r   r   markparametrizer   arrayr   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r*  r5  r@  rA  rG  rS  r^  rg  rq  r   r   r   r   r      sZ    

	
'
	
 #<6
!r   r9   _x_yc                 C   sF  |D ]}||    sJ q| |}||}	|t|dkr#|n|d D ]x\}
}t|| j|}t||j|}z||
}W n& tyg } z|dv rVtd|
 d|t	|| j| W Y d }~n
d }~ww t
|| z|	|
}W n& ty } z|dv rtd|
 d|t	||j| W Y d }~q(d }~ww t
|| q(d S )Nr!   r   )r9   rI   zkey z! should not have been in the join)rC   rI   )r   r   r   r   _restrict_to_columnsrb   	get_grouprp   AssertionError_assert_all_na_assert_same_contents)r9   rC   r   r   r;   r   r   rZ   left_groupedright_grouped	group_keygroupl_joinedr_joinedlgrouperrrgroupr   r   r   r=     sH   




r=   c                    sR    fdd| j D }| jd d |f } | jfddd} | jd d  f } | S )Nc                    s(   g | ]}| v s| d  v r|qS ) replace)r9  rZ   rb   suffixr   r   r<    s    z(_restrict_to_columns.<locals>.<listcomp>c                    s   |   dS )Nr  r  )r   )r  r   r   <lambda>  s    z&_restrict_to_columns.<locals>.<lambda>r   )rb   r  rename)r  rb   r  foundr   r  r   r{    s   r{  c                    sd   d}|  | j}| | j}dd |D  t t|ks#J t fdd|D s0J d S )Niy)c                 S   s   h | ]}t |qS r   tupler9  rowr   r   r   	<setcomp>(  rO  z(_assert_same_contents.<locals>.<setcomp>c                 3   s    | ]	}t | v V  qd S r   r  r  rowsr   r   	<genexpr>*  s    z(_assert_same_contents.<locals>.<genexpr>)fillnadrop_duplicatesr   r   r   )
join_chunkr5   NA_SENTINELjvaluessvaluesr   r  r   r  "  s   r  c                 C   s,   |D ]}||v r	q| |    sJ qd S r   )r   r   )r  source_columnsr   rZ   r   r   r   r~  -  s
   r~  c           	      C   sZ   | j j|j |d}| |}||}| j|j}| D ]\}}|||< q|j|dS )Nr:   r   )r+   rj   r   rb   appenditems)	rX   rY   r;   
join_indexa_reb_reresult_columnsr   r  r   r   r   r   4  s   


r   c                  C   sx   t dditjdgddd} t dditjd	gd
dd}| j|dd}t dgdgdtjdgddd}t|| d S )Nr  r   )r!   r\   r'   r   r   r3   r+   r|   r   )r\   r_   )rY   rZ   rI   r:   )r  r|   )r\   r!   r'   r_   )rY   rX   r   rZ   r*   r   r   from_tuplesrj   r1   rl   )r9   rC   r   rt   r   r   r   .test_join_inner_multiindex_deterministic_orderA  s   r  )	input_coloutput_colsrY   rX   a_xa_yc                 C   sb   t dddgi}t | ddgi}|j|dddd}t |d	 g d
|d g di}t|| d S )NrX   r!   r_   r'   crossry  rz  )r;   r   r   r   )r!   r!   r_   r_   )r_   r'   r_   r'   r   )r  r  r9   rC   r   rt   r   r   r   test_join_crossR  s
    r  c                 C   s|   t dditjdgddd}t dditjd	gd
dd}|j|| d}t dgdgdtjdgddgdd}t|| d S )NrZ   r_   )r!   r\   r   r   r  r   r'   )r\   )rY   r:   )rZ   r   )r\   r!   rY   rX   r*   r  )r   r9   rC   r   rt   r   r   r   test_join_multiindex_one_level^  s   r  zcategories, valuesYX)r  r  r  r\   r!   )r\   r!   r!         @      ?)r  r  r  z
2020-12-31z
2019-12-31c                 C   s   t ddgt| | dddgdddg}t g dt|| dg d	dddg}|j|d
dd}t ddgt| | dddgddgdddg}t|| d S )Nr,   rh  r!   r\   )r   r   r(   r   r   )r,   r,   r   )r_   r'   r   _leftr.  r   r_   r'   )r   r   
value_leftvalue_rightr   r   r   rj   r1   rl   )ri  r   r9   rC   r   rt   r   r   r   1test_join_multiindex_not_alphabetical_categoricall  s6   





r  zleft_empty, how, exp)
)Fr9   r9   )FrC   empty)FrI   r  )FrG   r9   )Fr  r  )Tr9   r  )TrC   rC   )TrI   r  )TrG   rC   )Tr  r  c                 C   s   t ddgddgdddd}t dgd	gd
ddd}| r&|d}n|d}|j||d}|dkrLt ddgddgtjtjgd}|d}n+|dkrbt tjgdgd	gd}|d}n|dkrwt ddgdd}|dkrw|d}t|| d S )Nr\   r!   r_   r'   )r,   r   r   r$  r,   r   )r,   r0   r   r:   r9   )r,   r   r0   rC   )r   r,   r0   r  r   r0   r   r  )	r   r   headrj   r   r  rename_axisr1   rl   )
left_emptyr;   expr9   rC   r   rt   r   r   r   test_join_empty  s"    
 
r  zhow, valuesrI   r[   rG   rC   r   r\   r!   c                 C   s   t tg dtg dg ddddg}t tg dtg dg ddddg}t t|t|||dddg}|j|| d}t|| d S )	Nr[   r]   rX   rY   r  r   )rX   rY   rZ   r   r:   r  )r;   r   r   r)   rt   r   r   r   r   3test_join_multiindex_categorical_output_index_dtype  s6   






	r  )r
   r   )r9   ry  rz  )r9   )numpyr   rn   pandasr   r   r   r   r   r   r   r   r	   pandas._testing_testingr1   r   r   r=   r{  r  r~  r   r  rv  rw  r  r  r  r  r  r   r   r   r   <module>   s`    (

     
R'

	





	