
    yhhv=                        d dl Zd dl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                            dedg          d             Zd ZdS )    N)	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        \/var/www/histauto/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_seriesr4   ?   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>   Y   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 )Nr6   r   r)   r9   r8   r   r   r   r,   r   )	r   r   r   r   r   r   r   r   r   )r   ser1r1   ser3r    r%   s         r!   test_concat_series_chainedrB   p   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
   r7   r   r,   r   r-   )	r   r   r   r   r   r   r   r   r   )r   r0   r1   r%   r    s        r!   !test_concat_series_updating_inputrD      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 )Nr6   r   )r   r8   r9   r   r)   r   r   r8   r,   r   r   )
r   r   r   r   r   r   r   r   r   r   )r   r   r0   r    r%   s        r!   test_concat_mixed_series_framerF      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_keywordrI      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>rP      s    939S#;#;F#;#; r#   c                     t          | |fi |S rL   rM   rN   s      r!   rP   rP      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
   r8   r   r6   keyr   r9   rU   r
   rU   onr   r
   r   r   r   r(   )
r   r   r   r   r   r   r   r   r   r   )r   rJ   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   r6   r
   r9   T)
left_indexright_indexr   r   r   )	r   r   r   r   r   r   r   r   r   )r   r<   r   rZ   r[   r    s         r!   test_merge_on_indexr`      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 NrX   rU   rM   rN   s      r!   rP   rP   
      E#s$G$Gu$G$G$G r#   rightc                 "    t          | |fddi|S rb   rM   rN   s      r!   rP   rP     rc   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 )NrS   r   r6   rT   r   r
   r+   r:   rV   )howr   r   rU   rf   r   rY   )r   r   r   r   r   r   r   _mgr_has_no_referencer   r   r   )r   rJ   rh   r<   r   rZ   r[   r    s           r!   test_merge_on_key_enlarging_onerk     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^   r_   F)r   r   r   r   r   rH   s        r!   test_merge_copy_keywordrm   -  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#   r   strc                    t          g dd|           }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 )NrS   rU   r*   r   r   r6   Tdeepindexr
   r9   rW   r   r   r   )r   r   r   joinr   r   r   r   rt   r   r   )r   r   df_indexr<   r   rZ   r[   r    s           r!   test_join_on_keyrw   <  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 )NrS   rU   rp   r   r6   Trq   rs   r
   r9   r8   )      	   c                 6    g | ]}|                                 S  )r   ).0r   s     r!   
<listcomp>z8test_join_multiple_dataframes_on_key.<locals>.<listcomp>h  s     2222RWWYY222r#   r   r   r   r   rY   )r   r   r   r   ru   r   r   r   rt   r   r   r   zip)	r   rv   r<   dfs_listrZ   dfs_list_origr    r   r   s	            r!   $test_join_multiple_dataframes_on_keyr   ^  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pandasr   r   r   r   r   pandas._testing_testingr   pandas.tests.copy_view.utilr   r"   r&   r4   r>   rB   rD   rF   markparametrizerI   r\   r`   rk   rm   r   rw   r   r}   r#   r!   <module>r      sL                           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 65/22) ) 32)B/+ /+ /+ /+ /+r#   