
    bMhC>                     6   d dl Zd dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
mZmZ d dlmZ d dlmZ d Zd Zd Zd	 Zd
 Zd Zd Zej                            dg d          d             Zej                            dd d g          d             Zd Zej                            dd dfd dfg          d             Zej                            dg d          d             Zej                              e            oed          d             Z!d Z"dS )     N)using_string_dtype)HAS_PYARROW)	DataFrameIndexSeriesconcatmerge)	get_arrayc                    t          ddgdz  it                    }t          ddgdz  it                    }|                                }t          ||gd          }| rgt	          j        t          |d          t          |d                    sJ t	          j        t          |d          t          |d                    sJ nft	          j        t          |d          t          |d                    rJ t	          j        t          |d          t          |d                    rJ d|j        d<   | rft	          j        t          |d          t          |d                    rJ t	          j        t          |d          t          |d                    sJ d|j        d	<   | r3t	          j        t          |d          t          |d                    rJ t          j	        ||           d S )
Nba   dtype   axisdr   r   r   r   )
r   objectcopyr   npshares_memoryr
   iloctmassert_frame_equal)using_copy_on_writedfdf2df_origresults        e/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/copy_view/test_functions.pytest_concat_framesr$      s   	C##6	2	2	2B
S3%!)$F
3
3
3CggiiGRIA&&&F Q	&# 6 6	"c8J8JKKKKK	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ib#<N<NOOOOO#Ifc$:$:Ic3<O<OPPPPPFK M#Ifc$:$:Ib#<N<NOOOOO	&# 6 6	#s8K8KLLLLLFK Q#Ifc$:$:Ic3<O<OPPPPP"g&&&&&    c                    t          ddgdz  it                    }t          ddgdz  it                    }t          ||gd          }| rgt          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ |                                }d|j        d<   | rft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    sJ d|j        d<   | r3t          j        t          |d          t          |d                    rJ t          j	        ||           d S )	Nr   r   r   r   r   r   r   r   )
r   r   r   r   r   r
   r   r   r   r   )r   r   r    r"   expecteds        r#   !test_concat_frames_updating_inputr(   +   s   	C##6	2	2	2B
S3%!)$F
3
3
3CRIA&&&F Q	&# 6 6	"c8J8JKKKKK	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ib#<N<NOOOOO#Ifc$:$:Ic3<O<OPPPPP{{}}HBGDM M#Ifc$:$:Ib#<N<NOOOOO	&# 6 6	#s8K8KLLLLLCHTN Q#Ifc$:$:Ic3<O<OPPPPP&(+++++r%   c                    t          ddgd          }t          ddgd          }|                                }|                                }t          ||gd          }| rUt          j        t          |d          |j                  sJ t          j        t          |d          |j                  sJ nTt          j        t          |d          |j                  rJ t          j        t          |d          |j                  rJ d	|j        d
<   | rTt          j        t          |d          |j                  rJ t          j        t          |d          |j                  sJ d|j        d<   | r*t          j        t          |d          |j                  rJ t          j	        ||           t          j	        ||           d S )Nr      r   namer      r   r   d   r     r   )
r   r   r   r   r   r
   valuesr   r   assert_series_equal)r   serser2ser_orig	ser2_origr"   s         r#   test_concat_seriesr6   C   s   
!Qc
"
"
"C1a&s###DxxzzH		IS$Ka(((F I	&# 6 6
CCCCC	&# 6 6DDDDDD#Ifc$:$:CJGGGGG#Ifc$:$:DKHHHHHFK E#Ifc$:$:CJGGGGG	&# 6 6DDDDDFK I#Ifc$:$:DKHHHHH3)))4+++++r%   c                     t          g dg dd          }t          dg di          }t          dg di          }t          t          ||gd          |gd          }|                                }| rt          j        t          |d	          t          |d	                    sJ t          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nt          j        t          |d	          t          |d	                    rJ t          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d
|j        d<   | r3t          j        t          |d	          t          |d	                    rJ t          j        ||           d S )Nr   r*   r   )g?g?g333333?r   r   cr-         r   r   r   r   r.   r   )	r   r   r   r   r   r
   r   r   r   )r   df1r    df3r"   r'   s         r#   test_concat_frames_chainedr@   ]   s   
)))///::
;
;C
S)))$
%
%C
S)))$
%
%CVS#JQ///5A>>>F{{}}H Q	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPPCHTN Q#Ifc$:$:Ic3<O<OPPPPP&(+++++r%   c                    t          g dd          }t          g dd          }t          g dd          }t          t          ||gd          |gd          }|                                }| rt          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nt          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d	|j        d
<   | r3t          j        t          |d          t          |d                    rJ t          j        ||           d S )Nr8   r   r+   r;   r:   r   r   r   r.   r   )	r   r   r   r   r   r
   r   r   r   )r   ser1r3   ser3r"   r'   s         r#   test_concat_series_chainedrD   t   s   )))#&&&D)))#&&&D)))#&&&DVT4Lq11148qAAAF{{}}H R	&# 6 6	$8L8LMMMMM	&# 6 6	$8L8LMMMMM	&# 6 6	$8L8LMMMMMM#Ifc$:$:IdC<P<PQQQQQ#Ifc$:$:IdC<P<PQQQQQ#Ifc$:$:IdC<P<PQQQQQDIaL R#Ifc$:$:IdC<P<PQQQQQ&(+++++r%   c                    t          ddgd          }t          ddgd          }t          ddgddgd          }t          ||gd	          }| rgt          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d
|j        d<   | rft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    sJ t          j        ||           d|j        d<   | r3t          j        t          |d          t          |d                    rJ t          j        ||           d S )Nr   r*   r   r+   r   r-   r   r9   r   r.   r   r/   )	r   r   r   r   r   r
   r   r   r   )r   r2   r3   r'   r"   s        r#   !test_concat_series_updating_inputrF      s   
!Qc
"
"
"C1a&s###D1vQF3344HS$Ka(((F R	&# 6 6	#s8K8KLLLLL	&# 6 6	$8L8LMMMMMM#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:IdC<P<PQQQQQCHQK N#Ifc$:$:Ic3<O<OPPPPP	&# 6 6	$8L8LMMMMM&(+++DIaL R#Ifc$:$:IdC<P<PQQQQQ&(+++++r%   c                 2   t          g ddd          }t          g dd          }t          ||gd          }|                                }| rt	          j        t          |d          t          |d                    sJ t	          j        t          |d	          t          |d	                    sJ t	          j        t          |d          t          |d                    sJ nt	          j        t          |d          t          |d                    rJ t	          j        t          |d	          t          |d	                    rJ t	          j        t          |d          t          |d                    rJ d
|j        d<   | r3t	          j        t          |d          t          |d                    rJ d
|j        d<   | r3t	          j        t          |d          t          |d                    rJ t          j	        ||           d S )Nr8   r   )r   r:   r;   r   r+   r   r   r:   r.   r   r   )
r   r   r   r   r   r   r
   r   r   r   )r   r   r2   r"   r'   s        r#   test_concat_mixed_series_framerH      s	   	++	,	,B

%
%
%CRIA&&&F{{}}H Q	&# 6 6	"c8J8JKKKKK	&# 6 6	"c8J8JKKKKK	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ib#<N<NOOOOO#Ifc$:$:Ib#<N<NOOOOO#Ifc$:$:Ic3<O<OPPPPPCHQK Q#Ifc$:$:Ic3<O<OPPPPPBGDM P#Ifc$:$:Ib#<N<NOOOOO&(+++++r%   r   )TNFc                 "   t          dddgi          }t          dddgi          }t          ||gd|          }| s|du rht          j        t	          |d          t	          |d                    sJ t          j        t	          |d          t	          |d                    sJ d S t          j        t	          |d          t	          |d                    rJ t          j        t	          |d          t	          |d                    rJ d S )	Nr   r   r*   r   g      ?g      @)r   r   F)r   r   r   r   r
   r   r   r   r    r"   s        r#   test_concat_copy_keywordrK      s   	C!Q=	!	!B
S3*%
&
&CRIAD111F Qdemm	"c 2 2Ifc4J4JKKKKK	#s 3 3Yvs5K5KLLLLLLL#Ib#$6$6	&#8N8NOOOOO#Ic3$7$7639O9OPPPPPPPr%   funcc                      | j         |fi |S Nr	   r>   r    kwargss      r#   <lambda>rR      s    939S#;#;F#;#; r%   c                     t          | |fi |S rN   rO   rP   s      r#   rR   rR      s    5c#<#<V#<#< r%   c                 :   t          t          g dt                    g dd          }t          t          g dt                    g dd          }|                                }|                                } |||d          }| rt	          j        t          |d	          t          |d	                    sJ t	          j        t          |d
          t          |d
                    sJ t	          j        t          |d          t          |d                    sJ t	          j        t          |d          t          |d                    rJ nft	          j        t          |d	          t          |d	                    rJ t	          j        t          |d
          t          |d
                    rJ d|j        d<   | rft	          j        t          |d	          t          |d	                    rJ t	          j        t          |d
          t          |d
                    sJ d|j        d<   | r3t	          j        t          |d
          t          |d
                    rJ t          j	        ||           t          j	        ||           d S )Nr   r   r:   r   r8   keyr   r;   rW   r   rW   onr   r   r   r   r   r*   )
r   r   r   r   r   r   r
   r   r   r   )r   rL   r>   r    df1_origdf2_origr"   s          r#   test_merge_on_keyr^      s    F???&AAA			RR
S
SC
F???&AAA			RR
S
SCxxzzHxxzzHT#su%%%F Q	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLL	&% 8 8)C:O:OPPPPP#Ife$<$<iU>S>STTTTTT#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPPFK M#Ifc$:$:Ic3<O<OPPPPP	&# 6 6	#s8K8KLLLLLFK Q#Ifc$:$:Ic3<O<OPPPPP#x(((#x(((((r%   c                    t          dg di          }t          dg di          }|                                }|                                }t          ||dd          }| rgt          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d|j        d<   | rft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    sJ d|j        d	<   | r3t          j        t          |d          t          |d                    rJ t          j        ||           t          j        ||           d S )
Nr   r8   r   r;   T)
left_indexright_indexr   r   r   )	r   r   r	   r   r   r
   r   r   r   )r   r>   r    r\   r]   r"   s         r#   test_merge_on_indexrb      s   
S)))$
%
%C
S)))$
%
%CxxzzHxxzzH3$???F Q	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPPFK M#Ifc$:$:Ic3<O<OPPPPP	&# 6 6	#s8K8KLLLLLFK Q#Ifc$:$:Ic3<O<OPPPPP#x(((#x(((((r%   z	func, howc                 "    t          || fddi|S NrZ   rW   rO   rP   s      r#   rR   rR         E#s$G$Gu$G$G$G r%   rightc                 "    t          | |fddi|S rd   rO   rP   s      r#   rR   rR     re   r%   leftc                    t          t          g dt                    g dd          }t          t          ddgt                    ddgd	          }|                                }|                                } ||||
          }| rt	          j        t          |d          t          |d                    sJ t	          j        t          |d          t          |d                    rJ |j                            d          sJ |j                            d          sJ t	          j        t          |d          t          |d                    |dk    u sJ t	          j        t          |d          t          |d                    rJ nft	          j        t          |d          t          |d                    rJ t	          j        t          |d          t          |d                    rJ |dk    rd|j	        d<   n
d|j	        d<   | r3t	          j        t          |d          t          |d                    rJ t          j        ||           t          j        ||           d S )NrU   r   r8   rV   r   r   r-   r<   rX   )howr   r   rW   rh   r   r[   )r   r   r   r   r   r   r
   _mgr_has_no_referencer   r   r   )r   rL   rj   r>   r    r\   r]   r"   s           r#   test_merge_on_key_enlarging_onerm     st    F???&AAA			RR
S
SC
FC:V<<<Aq6JJ
K
KCxxzzHxxzzHT#s$$$F Q	&# 6 6	#s8K8KLLLLL#Ifc$:$:Ic3<O<OPPPPPx))!,,,,,x))!,,,,,	&% 8 8)C:O:OPP6M
 
 
 
 #Ife$<$<iU>S>STTTTTT#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPP
f}}DD Q#Ifc$:$:Ic3<O<OPPPPP#x(((#x(((((r%   c                 ,   t          dddgi          }t          dddgi          }|                    ||dd          }| s|d	u rht          j        t	          |d          t	          |d                    sJ t          j        t	          |d          t	          |d                    sJ d S t          j        t	          |d          t	          |d                    rJ t          j        t	          |d          t	          |d                    rJ d S )
Nr   r   r*   r   r   g      @T)r   r`   ra   F)r   r	   r   r   r
   rJ   s        r#   test_merge_copy_keywordro   1  s   	C!Q=	!	!B
S1c(O
$
$CXXc4XHHF Qdemm	"c 2 2Ifc4J4JKKKKK	#s 3 3Yvs5K5KLLLLLLL#Ib#$6$6	&#8N8NOOOOO#Ic3$7$7639O9OPPPPPPPr%   zZTODO(infer_string); result.index infers str dtype while both df1 and df2 index are object.)reasonc                    t          g ddt                    }t          dg di|                    d                    }t          d	g d
i|                    d                    }|                                }|                                }|                    |d          }| rt          j        t          |d          t          |d                    sJ t          j        t          |d	          t          |d	                    sJ t          j        t          |j                  t          |j                            sJ t          j        t          |j                  t          |j                            rJ nft          j        t          |d          t          |d                    rJ t          j        t          |d	          t          |d	                    rJ d|j	        d<   | rft          j        t          |d          t          |d                    rJ t          j        t          |d	          t          |d	                    sJ d|j	        d<   | r3t          j        t          |d	          t          |d	                    rJ t          j        ||           t          j        ||           d S )NrU   rW   r,   r   r   r8   Tdeepindexr   r;   rY   r   r   r   )r   r   r   r   joinr   r   r
   rv   r   r   r   )r   df_indexr>   r    r\   r]   r"   s          r#   test_join_on_keyry   @  s    ___5???H
S)))$HMMtM,D,D
E
E
EC
S)))$HMMtM,D,D
E
E
ECxxzzHxxzzHXXceX$$F Q	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLL	&, 7 7399M9MNNNNN#Ifl$;$;Ysy=Q=QRRRRRR#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPPFK M#Ifc$:$:Ic3<O<OPPPPP	&# 6 6	#s8K8KLLLLLFK Q#Ifc$:$:Ic3<O<OPPPPP#x(((#x(((((r%   c                 	   t          g ddt                    }t          dg di|                    d                    }t          d	g d
i|                    d                    t          dg di|                    d                    g}|                                }d |D             }|                    |          }| rct          j        t          |d          t          |d                    sJ t          j        t          |d	          t          |d         d	                    sJ t          j        t          |d          t          |d         d                    sJ t          j        t          |j                  t          |j                            sJ t          j        t          |j                  t          |d         j                            rJ t          j        t          |j                  t          |d         j                            rJ nt          j        t          |d          t          |d                    rJ t          j        t          |d	          t          |d         d	                    rJ t          j        t          |d          t          |d         d                    rJ d|j	        d<   | rt          j        t          |d          t          |d                    rJ t          j        t          |d	          t          |d         d	                    sJ t          j        t          |d          t          |d         d                    sJ d|j	        d<   | rrt          j        t          |d	          t          |d         d	                    rJ t          j        t          |d          t          |d         d                    sJ d|j	        d<   | r9t          j        t          |d          t          |d         d                    rJ t          j        ||           t          ||          D ]\  }}t          j        ||           d S )NrU   rW   rr   r   r8   Trs   ru   r   r;   r:   )      	   c                 6    g | ]}|                                 S  )r   ).0r   s     r#   
<listcomp>z8test_join_multiple_dataframes_on_key.<locals>.<listcomp>p  s     2222RWWYY222r%   r   r   r   r   r[   )r   r   r   r   rw   r   r   r
   rv   r   r   r   zip)	r   rx   r>   dfs_listr\   dfs_list_origr"   r   r!   s	            r#   $test_join_multiple_dataframes_on_keyr   f  sW   ___5???H
S)))$HMMtM,D,D
E
E
EC3			"(--T-*B*BCCC3			"(--T-*B*BCCCH
 xxzzH22222MXXhF Y	&# 6 6	#s8K8KLLLLL	&# 6 6	(1+s8S8STTTTT	&# 6 6	(1+s8S8STTTTT	&, 7 7399M9MNNNNN#fl##Yx{/@%A%A
 
 	
 	
 	
 #fl##Yx{/@%A%A
 
 	
 	
 	
 	
 #Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:IhqkSV<W<WXXXXX#Ifc$:$:IhqkSV<W<WXXXXXFK U#Ifc$:$:Ic3<O<OPPPPP	&# 6 6	(1+s8S8STTTTT	&# 6 6	(1+s8S8STTTTTFK U#Ifc$:$:IhqkSV<W<WXXXXX	&# 6 6	(1+s8S8STTTTTFK Y#Ifc$:$:IhqkSV<W<WXXXXX#x(((8]33 + +G
b'****+ +r%   )#numpyr   pytestpandas._configr   pandas.compatr   pandasr   r   r   r   r	   pandas._testing_testingr   pandas.tests.copy_view.utilr
   r$   r(   r6   r@   rD   rF   rH   markparametrizerK   r^   rb   rm   ro   xfailry   r   r   r%   r#   <module>r      s        - - - - - - % % % % % %                    1 1 1 1 1 1' ' '0, , ,0, , ,4, , ,., , ,., , ,2, , ,2 !4!4!455Q Q 65Q 
;;<< ) ) ):) ) )6 	G	GQ	G	GP ) ) )> !4!4!455Q Q 65Q ([$   
) ) 
)B/+ /+ /+ /+ /+r%   