
    g                         d dl Zd dlZd dlmZ d dlZd dlmZmZ d dl	m
Z d Zd Zd Zd Zd Zej"                  j%                  d	      d
        Zd Zd Zy)    N)PerformanceWarning)Index
MultiIndexc                 x   | j                  ddg      }t        j                  ddg      }| j                  |      }| g d   }t        j                  ||       t        j                  ||       | j                  dg      }| g d   }t        j                  ||       | j                  d      }| g d   }t        j                  ||       t        j                  dg      }t        j                  t        d	
      5  | j                  dg       d d d        t        j                  t        d	
      5  | j                  |       d d d        t        j                  t        d
      5  | j                  ddg       d d d        t        j                  ddg      }t        j                  t        d	
      5  | j                  |       d d d        | j                  |d      }| g d   }t        j                  ||       | j                  |d      }| g d   }t        j                  ||       | j                  ddgd      }| g d   }t        j                  ||       | j                  ddg      }| g d   }t        j                  ||       g d}t        j                  t        d
      5  | j                  |       d d d        | j                  |d      }| g d   }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ]xY w# 1 sw Y   nxY w)N)footwoquxone)r            bar)r      r      r   r   )r   r   r   r   )r   r   z^\('bar', 'two'\)$matchz^'two'$r   ignore)errors)r   r   r   r   r   r   )r   r   r   r   r   )r   r   r   )r   r	   r   )dropr   from_tuplestmassert_index_equalpytestraisesKeyError)idxdroppedindexdropped2expectedmixed_indexs         Y/var/www/openai/venv/lib/python3.12/site-packages/pandas/tests/indexes/multi/test_drop.py	test_dropr$      s   hh78G""NN#CDExxH< H'8,(H-hhwG?#H'8,hhuoG< H'8,""N#34E	x'<	=.!" 
>	x'<	= 
>	xz	2%  
3 ((..)IJK	x'<	= 
> hhuXh.G%&H'8,hh{8h4G?#H'8,hhu~hh7G< H'8, hh~./G9~H'8, 1K	xz	2 
3hh{8h4G9~H'8,I 
>	=	=	=	2	2
 
>	=. 
3	2s<   =K<3L	(L6L#1L0<L	LL #L-0L9c           	      4   | | j                  d         }|j                  d      }|j                  dk(  sJ t        t	        t        d            t	        t        d            t	        t        d            gt        j                  g d      t        j                  g d      t        j                  g d      gg d	      }|j                  d      }|j                  d
k(  sJ |j                  d      }|j                  d      }|j                  |      sJ y )Nr   r   secondr   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   threelevelscodesnames)r   r+   r   r   )
get_loc	droplevelnamer   r   rangenparrayr/   equals)r   r   r   r!   s       r#   test_droplevel_with_namesr7   H   s    E"#Eooa G<<8###eAhuQx%a/BHH-.HH-.HH-.

 &E ooa G==,,,,ooe$Gq!H>>(###    c            	      &   t        t        t        d            t        t        d            t        t        d            gt        j                  g d      t        j                  g d      t        j                  g d      gg d      } | d d j                  dd	g      }| d d j                  d      j                  d
      }|j                  |      sJ | d d j                  g       }| d d }|j                  |      sJ d}t        j                  t        |      5  | d d j                  g d       d d d        t        j                  t        d      5  | d d j                  d	dg       d d d        y # 1 sw Y   DxY w# 1 sw Y   y xY w)Nr   r'   r(   r)   r*   r,   r   r+   r   r   zSCannot remove 3 levels from an index with 3 levels: at least one level must be leftr   z'Level four not found'four)r   r   r3   r4   r5   r1   r6   r   r   
ValueErrorr   )r   r   r!   msgs       r#   test_droplevel_listr=   ^   s[   eAhuQx%a/BHH-.HH-.HH-.

 &E BQi!!7E"23GRay""1%//2H>>(###BQi!!"%GRayH>>(###	*  
z	-bq	34 
. 
x'?	@bq	UFO, 
A	@ 
.	- 
A	@s   !E;F;FFc                     g d} t        j                  | ddg      }|j                         sJ t        j                  g dg dg dg      }|j                  d	ddgd
      }|j                         }|j                  }|j                         rJ t        j                  ||       t        j                  t              5  t        j                  |j                  d	      |j                  d	             d d d        y # 1 sw Y   y xY w)N))a )b1c1)b2c2bcr/   )r?   rE   rF   d)r   rA   rB   r   )r   rC   rD   r   )columnsdatar?   rH   )r   rI   values)r   r   _is_lexsortedpd	DataFramepivot_tablereset_indexrI   r   r   assert_produces_warningr   r   )tupleslexsorted_midfnot_lexsorted_mis       r#   test_drop_not_lexsortedrV   |   s     5F))&c
CL%%''' 
$,>@R+S
B 
cC:c	BB		Bzz--/// ,(89		#	#$6	7
l//46F6K6KC6PQ 
8	7	7s   5D  D	c                     t        j                  d| fgddg      }d}t        j                  t        |      5  |j                  t        j                  d      d       d d d        y # 1 sw Y   y xY w)	Nblahr2   daterG   z@labels \[Timestamp\('2001-01-01 00:00:00'\)\] not found in levelr   2001level)r   r   r   r   r   r   rM   	Timestamp)nulls_fixturemir<   s      r#   test_drop_with_nan_in_indexr`      sY    			&-!8 9&&AQ	RB
MC	xs	+
V$F3 
,	+	+s   'A**A3z(ignore::pandas.errors.PerformanceWarningc                      t        j                  g d      } | j                  d      }t        j                  dg      }t        j                  ||       y )N)r   r   r   r   rb   rb   rc   )r   r   r   r   r   )r_   resultr!   s      r#   'test_drop_with_non_monotonic_duplicatesre      sD     
		 8	9BWWV_F%%vh/H&(+r8   c                     t        j                  g d      } d}t        j                  t        |      5  | j                  dd       d d d        t        j                  t        |      5  | j                  ddgd       d d d        d}t        j                  t        |      5  | j                  t        j                  gd       d d d        t        j                  t        |      5  | j                  t        j                  dd	d
gd       d d d        t        j                  t        j                  dfdg      } d}t        j                  t        |      5  | j                  t        j                  ddgd       d d d        y # 1 sw Y   FxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)N)rb   )r   r   )r   r   zlabels \[4\] not found in levelr   r   r   r[   r   z!labels \[nan\] not found in levelr   r   rb   z!labels \['a'\] not found in levelr?   )r   r   r   r   r   r   r4   nan)r_   r<   s     r#   1test_single_level_drop_partially_missing_elementsrh      s@    
		 8	9B
,C	xs	+
 
,	xs	+
Aa  
,
.C	xs	+
" 
,	xs	+
Aq!+ 
, 
		"&&!f 5	6B
.C	xs	+
C * 
,	+ 
,	+	+	+ 
,	+	+	+
 
,	+s;   F,F'#F'-&F3%F?FF$'F03F<?Gc                      t        j                  dgd      } | j                  g       }t        dgd      }t	        j
                  ||       y )N)r   )rE   rG   r   rE   )r2   )r   r   r1   r   r   r   )r   rd   r!   s      r#   #test_droplevel_multiindex_one_levelrj      sB    ""D68E__R FaSs#H&(+r8   )numpyr4   r   pandas.errorsr   pandasrM   r   r   pandas._testing_testingr   r$   r7   r=   rV   r`   markfilterwarningsre   rh   rj    r8   r#   <module>rs      se      ,  7-t$,-<R.4 FG, H,+*,r8   