
    Owg                     P    d dl Zd dlZd dlZd dlmZmZmZ d dlm	Z
  G d d      Zy)    N)	DataFrame
MultiIndexSeriesc                   @   e Zd Zd Zej
                  j                  dg  ee       e	j                  g       g      d        Zd Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zej
                  j                  d edg did       eg dd      g      d        Zd Zd Zy)TestDataFrameIsInc                    t        g dg dg ddg d      }g d}|j                  |      }t        |j                  D cg c]   }|j                  |   j                  |      " c}      }t	        j
                  ||       y c c}w )N            abfnr   r   cr   valsidsids2foobarbazquxindexr   r   r   )r   isinr   loctmassert_frame_equal)selfdfotherresultsexpecteds         [/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/frame/methods/test_isin.py	test_isinzTestDataFrameIsIn.test_isin   ss    $+,
 /
  RXXFbffQinnU3FG
fh/ Gs   %Bempty)dtypec                     t        g dg dd      }t        d|j                  |j                        }|j                  |      }t	        j
                  ||       y )Nr    r   er   ABF)r   r   columnsr!   r#   r$   )r%   r-   r&   r*   r(   s        r+   test_isin_emptyz!TestDataFrameIsIn.test_isin_empty   sF     _?CDUBHHbjj9
fh/    c                    t        g dg dd      }ddgi}t        d|j                  |j                        }d|j                  d<   |j	                  |      }t        j                  ||       t        g dg dd      }ddg|_        t        d|j                  |j                        }d|j                  d<   |j	                  |      }t        j                  ||       y )	Nr    r0   r2   r3   r   FT)r   r3   )r   r   r5   r"   r!   r#   r$   )r%   r&   dr*   r(   s        r+   test_isin_dictz TestDataFrameIsIn.test_isin_dict'   s    _?CD3%LUBHHbjj9#V
fh/ _?CD3Z
UBHHbjj9#V
fh/r7   c                 >   t        g dg dg ddg d      }d}t        j                  t        |      5  |j	                  d	       d d d        t        j                  t        |      5  |j	                  d
       d d d        y # 1 sw Y   ?xY w# 1 sw Y   y xY w)Nr	   r   r   r   r   r   zfonly list-like or dict-like objects are allowed to be passed to DataFrame.isin\(\), you passed a 'str'matchr   aaa)r   pytestraises	TypeErrorr!   )r%   r&   msgs      r+   test_isin_with_string_scalarz.TestDataFrameIsIn.test_isin_with_string_scalar9   s    $+,
 /
F 	 ]]9C0 	GGCL	 ]]9C0 	GGEN	 		 		 	s   B,BBBc                    t        g ddt        j                  ddgd      }t        g ddt        j                  ddgd      }t        d|j                  |j                        }|j                  |      }d|j                  d	d
gdf<   d|j                  ddgdf<   t        j                  ||       ddg|_        |j                  |      }d|d<   t        j                  ||       y )Nr	   r   r   r2   )r   r      r      FTr
   r   r3   r   r4   C)	r   npnanr   r5   r!   r"   r#   r$   )r%   df1df2r*   r(   s        r+   test_isin_dfzTestDataFrameIsIn.test_isin_dfM   s    l!RVVQ1BCDm1bffa2CDEUCIIs{{;#$(aVS[!$(aVS[!
fh/ Cj#
fh/r7   c                     t        g dg dd      }t        t        |d   |d               |d<   |d   j                  dg      }t	        j
                  |t        g dd	             y )
Nr
   r   r   )r   r   r   r2   r3   r4   rG   )r
   r   )TFF)name)r   listzipr!   r#   assert_series_equalr   )r%   r&   r(   s      r+   test_isin_tuplesz"TestDataFrameIsIn.test_isin_tuples\   sZ    Y_=>s2c7BsG,-3Cxj)
vv.B'MNr7   c                    t        g ddt        j                  ddgd      }t        ddgddgdt        j                  gddggddg	      }d
}t        j                  t
        |      5  |j                  |       d d d        t        ddgddgdt        j                  gddggddgg d      }t        j                  t
        |      5  |j                  |       d d d        ddg|_        t        j                  t
        |      5  |j                  |       d d d        y # 1 sw Y   xY w# 1 sw Y   TxY w# 1 sw Y   y xY w)Nr	   r   r   r2   r   rE   rF   r4   r5   z+cannot compute isin with a duplicate axis\.r<   r3   )r   r   r
   r
   r5   r   )r   rH   rI   r?   r@   
ValueErrorr!   r5   )r%   rJ   rK   rB   s       r+   test_isin_df_dupe_valuesz*TestDataFrameIsIn.test_isin_df_dupe_valuesc   s$   l!RVVQ1BCD!Q"a1bff+1v>c
S<]]:S1 	HHSM	 Vb!Wq"&&kAq62#J

 ]]:S1 	HHSM	 Cj]]:S1 	HHSM	 		 		 	
	 	s$   )D#
D/D;#D,/D8;Ec                 &   t        g dg dd      }t        ddgddgddggddg      }|j                  |      }t        d|j                  |j                  	      }d
|j                  d<   d
|j
                  d<   t        j                  ||       y )N)r
   r   r
   r   )r
   r
   r   r   r2   r
   r   r3   rU   Fr   r5   T)r
   r
   )r   r!   r   r5   r"   ilocr#   r$   )r%   r'   r&   r(   r*   s        r+   test_isin_dupe_selfz%TestDataFrameIsIn.test_isin_dupe_selfy   s    <@AAAA/#sDU"((BJJGQ"d
fh/r7   c                 @   t        g ddt        j                  ddgdg d      }t        g dg d      }t        d|j                  |j
                  	      }d
|j                  d<   d
|j                  d<   |j                  |      }t        j                  ||       y )Nr	   r   r   r2   )r   r   r   r9   r   )r
   r      r   FrZ   T)r   r3   r9   )
r   rH   rI   r   r   r5   r"   r!   r#   r$   )r%   r&   r)   r*   r(   s        r+   test_isin_against_seriesz*TestDataFrameIsIn.test_isin_against_series   s    aA%67?S
 =(<=U"((BJJG!%X S
fh/r7   c                 0   t        j                  g d      }t        t        j                  d      t        j
                  d      d|      }t        g dg dd      }t        d|j                  |j                        }|j                  |      }t        j                  ||       ||_        |j                  j                  t              }|d d d	f    |d d d	f<   t        |d
dg|      }|j                  |      }t        j                  ||       y )N))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
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   rE   r2   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
   FrZ   r
   r3   r4   rV   )r   from_tuplesr   rH   oneszerosr   r5   r!   r#   r$   valuesastypebool)r%   idxrJ   rK   r*   r(   s         r+   test_isin_multiIndexz&TestDataFrameIsIn.test_isin_multiIndex   s    $$
  bggbk=SI99
 U#))S[[I#
fh/	::$$T*"1a4.AXSzE#
fh/r7   c                 :   t        dt        j                  ddg      i      }t        dt        j                  dd      t        j                  dd      gi      }t        dg i      }t               }t        dddgi      }|j	                  |      }t        j                  ||       |j	                  |      }t        j                  ||       |j	                  |      }t        j                  ||       |j	                  |      }t        j                  ||       y )Ndatez
2014-01-01z
2014-01-02r
   r)   r   F)r   pdto_datetime	Timedeltar!   r#   r$   )r%   df1_tsdf1_tdrK   df3r*   r(   s          r+   test_isin_empty_datetimelikez.TestDataFrameIsIn.test_isin_empty_datetimelike   s    FBNNL,3O$PQRFR\\!S%92<<3;O$PQR%kfuen56S!
fh/S!
fh/S!
fh/S!
fh/r7   rd   r   rN   categoryc                     t        g dg dd      }t        g dg dd      }|j                  |      }t        j                  ||       y )NrN   )r   rF      r   r   TTT)FFFr   r!   r#   r$   )r%   rd   r&   r*   r(   s        r+   test_isin_category_framez*TestDataFrameIsIn.test_isin_category_frame   sA     YY78#5<QRS
fh/r7   c                     t        j                  g d      }|j                  d       t        g d      }|j	                  |      }t        g d      }t        j                  ||       y )NrN   F)writerv   )rH   arraysetflagsr   r!   r#   r$   )r%   arrr&   r(   r*   s        r+   test_isin_read_onlyz%TestDataFrameIsIn.test_isin_read_only   sP    hhy!5!y!/0
fh/r7   c                     d}t        |gdgd      }|j                  |g      }t        dgdgd      }t        j                  ||       y )Nl   +YNJ9 g      ?ru   TFrw   )r%   valr&   r(   r*   s        r+   test_isin_not_lossyz%TestDataFrameIsIn.test_isin_not_lossy   sL    !cU#/0#D689
fh/r7   N)__name__
__module____qualname__r,   r?   markparametrizer   objectrH   r{   r6   r:   rC   rL   rS   rX   r\   r_   rh   rq   r   rx   r~   r    r7   r+   r   r      s    0  [[Wr6+?"&NO0 P00$(0O,0	0#0J0& [[sI&j99J/	
0000r7   r   )numpyrH   r?   pandasrk   r   r   r   pandas._testing_testingr#   r   r   r7   r+   <module>r      s)       
 V0 V0r7   