
    bMhx"                        d dl Z d dlZd dlZd dlZd dlmZ d Z	ej
                            d ed          dfg df ed          dfg          d             Zej
                            dd	d d
 ej        d           ej        d          g          d             Zd Zd Zd Zej
                            dddgddggddgdd d gg dg ddg dfddgddggddgd ej        d d gd          g dg dd ej        g dd          fddgddggddgdej                            d d gddggddg           g dg ddej                            g dg d!gddg           fddgddggddgdej                            d d gddggddg           g dg ddej                            g dg d!gddg           fg          d"             Zd# Zd$ Zej
                            d% ed           ej        d ddej        ej        ddej        g ed&          e'          dd	d(d)dej        d*d+ej        gd, ed&          f ed-           ej        d ddej        ej        ddej        g ed&          e'          dg d.g d.g d.dg d*d+gd*d+gej        gd, ed&          fg          d/             Zd0 ZdS )1    Nc                     t          j        t          j        g dt          j        g dgt          d                    dd          } t          j        t          d          5  | 	                    t          d	          g           d d d            n# 1 swxY w Y   t          j        t          d
          5  | 	                    t          d	                     d d d            n# 1 swxY w Y   t          d	          | _
        t          j        t          t          j        d                    5  | 	                    d           d d d            d S # 1 swxY w Y   d S )Nr               abcdindexr   ABz/column must be a scalar, tuple, or list thereofmatchAAzcolumn must be uniquez:DataFrame columns must be unique. Duplicate columns: ['A']r   )pd	DataFrameSeriesnpnanlistpytestraises
ValueErrorexplodecolumnsreescape)dfs    g/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/frame/methods/test_explode.py
test_errorr"   
   s   	iBFB7tF||LLLSTUU
 
B 
K
 
 
 ! ! 	

DJJ<   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
 
z)@	A	A	A  


4::               dBJ	iTUU
 
 
   	

3	                 s6   $$BBB:#C))C-0C-5EEEzinput_subset, error_messageACz)columns must have matching element countszcolumn must be nonemptyc           	         t          j        g dt          j        g dgdg ddg g dgdt	          d          	          }t          j        t          |
          5  |                    |            d d d            d S # 1 swxY w Y   d S )Nr   r   r   abcfoo)defr   r   Cr
   r   r   )	r   r   r   r   r   r   r   r   r   )input_subseterror_messager    s      r!   test_error_multi_columnsr1      s    & 
))RVR0!//5"ooo>	
 	

 6ll
 
 
B 
z	7	7	7 ! !


<   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s   A>>BBscalarr&   g      ?z1 daysz
2019-12-31c                    t          j        | t          j        g dt          j        g dgt          d                    ddi          }|                    |           }t          j        | t          j        dddt          j        t          j        d	d
gt          d          t                    ddi          }t          j	        ||           d S )Nr   r   r
   r   r   r   r   r   r   r	   aaabcddr   dtype)
r   r   r   r   r   r   r   objecttmassert_frame_equal)r2   r    resultexpecteds       r!   
test_basicr<   =   s    
 
	IIIrvr6:$v,,OOOQTVWX
 
B ZZF|BIAq"&"&!Q/tIf   		
 H &(+++++    c                     t          j        t          j        g dt          j        g dgt
                    ddt           j                            g d                    } |                     d          }t          j        t          j	        d	dd
t          j        t          j        ddgt           j                            g d          t
                    dd          }t          j        ||           d S )Nr   r   r6   r   r   )r&   r   r&   r   r'   r   r'   r   r   r   r   r   r   r	   )r@   r@   r@   rA   rB   rC   rC   r5   )r   r   r   arrayr   r7   
MultiIndexfrom_tuplesr   r   r8   r9   r    r:   r;   s      r!   test_multi_index_rowsrH   Q   s    	h			262v6fEEEANNm''(P(P(PQQ
 
 
B
 ZZ__F|Aq"&"&!Q/m//  
 
    !	
 	
 H( &(+++++r=   c                     t          j        t          j        g dt          j        g dgt
                    dd          } |                     d          }t          j        t          j        dddt          j        t          j        d	d
gt          j        g d          t
                    dd          }t          j
        ||           d S )Nr   r   r?   r   )r   r   )r   r   rJ   r   r   r   r	   )r   r   r   r   r   r   r   r5   )r   r   r   rD   r   r7   r   r   Indexr8   r9   rG   s      r!   test_multi_index_columnsrL   o   s    	8YYYF;6JJJVWXX
 
B ZZ!!F|iAq"&"&!Q/h44455  
 	
 	
	 	H &(+++++r=   c                     t          j        dt          d          dgdt          d          dggt          d                                        d	          } |                     d
          }t          j        g dt          j        g dt                    g ddt          d                                        d	          }t          j
        ||           t          j        g dg dgg d          } |                     | j        j                            d                                        d          }t          j        g dg dg dg dgg dg d          }t          j
        ||           d S )N      
      r      ABC)r   r.   r   )rN   rN   rN   rN   rN   rQ   rQ   rQ   )r   r   r   r   r	   r   r   r   r?   )rP   rP   rP   rP   rP   rR   rR   rR   r-   )
2014-01-01AlicezA B)
2014-01-02BobzC D)dtnametext )rZ   rZ   )rT   rU   r   )rT   rU   r   )rV   rW   r.   )rV   rW   D)r   r   r   r   )r   r   )r   r   ranger   	set_indexr   r   rD   r7   r8   r9   assignrZ   strsplitrG   s      r!   test_usecaserb      s    

eAhh	b%((B/0$u++
 
 
inn  ZZ__F|111222&AAA111	
 	

 U   inn  &(+++ 
	'	'	')E)E)EF&&&
 
 
B YYBGK--c22Y33;;FCCF|((((((&&&&&&		
 '&&ll	 	 	H &(+++++r=   z6input_dict, input_index, expected_dict, expected_indexr   r   r   r	   r)   bar)col1col2)r   r   r   r	   )r)   r)   rc   rc   )r   r   r   r   my_index)rY   my_first_indexmy_second_index)names)r   r   r   r   c                     t          j        | |t                    }|                    d          }t          j        ||t                    }t	          j        ||           d S )Nr5   rd   )r   r   r7   r   r8   r9   )
input_dictinput_indexexpected_dictexpected_indexr    r:   r;   s          r!   test_duplicate_indexro      s[    L 
j6	B	B	BBZZF|MvNNNH&(+++++r=   c                  6   t          j        t          ddd          t          d          t          d          gd          } |                     dd	          }t          j        g d
t          d          dg d          }t          j        ||           d S )Nr   rR   rP   abcd)idvaluesrt   T)ignore_index)r   r   rP   rP   r
   )r   r   r   r   r   )r   r   r]   r   r   r8   r9   rG   s      r!   test_ignore_indexrv      s    	U1b"--$t**d4jj9QRR	S	SBZZtZ44F|~~f66lll  H &(+++++r=   c                      t          j        ddhgdgddg          } |                     d                              d          }t          j        ddgddgdddg          }t	          j        ||           d S )	Nxyr   )r&   r'   r   r&   )column)by)r   r   r   sort_valuesr8   r9   rG   s      r!   test_explode_setsr}      s    	c3ZLs33A3	?	?	?BZZsZ##//3/77F|3*Aq6::1a&IIIH&(+++++r=   z+input_subset, expected_dict, expected_indexaaabcdder5   r'   r(   r*   r+   r-   r   r%   c           	      .   t          j        g dt          j        g dt          j        gdg ddg ddgt          j        gdt	          d	          
          }|                    |           }t          j        ||          }t          j        ||           d S )Nr   r   r   r%   r)   r*   r+   r-   abcder   )r   r   r   r   r   r   r8   r9   )r/   rm   rn   r    r:   r;   s         r!   test_multi_columnsr      s    T 
))RVR8!//5"sCj"&A	
 	

 7mm
 
 
B ZZ%%F|M>::H&(+++++r=   c                     t          j        ddgdgg ddggg dddgt          j        g ddggd          } |                     d	d
g          }t          j        t          j        dddt          j        ddgt                    g dt          j        ddt          j        t          j        ddgt                    dg d          }t          j        ||           d S )Nr   r   rO   r   r   )	            r	   r-   r   r.   r?   )r   r   r   r   r   r   )r   r   r   r   r   r   r   )	r   r   r   r   r   rD   r7   r8   r9   rG   s      r!   test_multi_columns_nan_emptyr     s    	a&1#rAq6*a&"&"q!f-	
 	

 
B ZZc
##F|1aBFAq1@@@###1aA6fEEE	
 	

 !    H &(+++++r=   )r   numpyr   r   pandasr   pandas._testing_testingr8   r"   markparametrizer   r1   	Timedelta	Timestampr<   rH   rL   rb   rK   rE   from_arraysro   rv   r}   r   r   r7   r   r    r=   r!   <module>r      s   				                 ( ! DJJ7	

 %	

 DJJ7	
 "! !# "! !S,",x((,",|*D*DE , ,	 , , , ,<, , ,&#, #, #,L < !fq!f%u~>>F!\\+G+G+GHHLL		
 !fq!f%u~>>BHaV*---!\\+G+G+GHHBH\\\
333		
 !fq!f%u~>>M%%Q!Q )9;L(M &   "\\+G+G+GHHM%%|||,'):; &  
	
 !fq!f%u~>>M%%1v1v&6z4>P%QQ!\\+G+G+GHHM%%|||,Z4F &  		
1 # #H, ,I# #H,, , ,, , , 1 DJJRY1bfbfaBF;$z**   
 3UBFCbfE  D	
 DIIRY1bfbfaBF;$z**   
 #OO#OO#OO#J#JF	 $ D)	
$' 'P, ,Q' 'P,, , , , ,r=   