
    bMh                         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                            d	          d
             Zd Zd ZdS )    N)PerformanceWarning)Index
MultiIndexc                    |                      ddg          }t          j        ddg          }|                      |          }| g d         }t          j        ||           t          j        ||           |                      dg          }| g d         }t          j        ||           |                      d          }| g d         }t          j        ||           t          j        dg          }t          j        t          d	
          5  |                      dg           d d d            n# 1 swxY w Y   t          j        t          d	
          5  |                      |           d d d            n# 1 swxY w Y   t          j        t          d
          5  |                      ddg           d d d            n# 1 swxY w Y   t          j        ddg          }t          j        t          d	
          5  |                      |           d d d            n# 1 swxY w Y   |                      |d          }| g d         }t          j        ||           |                      |d          }| g d         }t          j        ||           |                      ddgd          }| g d         }t          j        ||           |                      ddg          }| g d         }t          j        ||           g d}t          j        t          d
          5  |                      |           d d d            n# 1 swxY w Y   |                      |d          }| g d         }t          j        ||           d S )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         d/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/indexes/multi/test_drop.py	test_dropr$      s   hh788G"NN#CDDExxH<<< H'8,,,(H---hhwG???#H'8,,,hhuooG<<< H'8,,,"N#344E	x'<	=	=	= # #.!"""# # # # # # # # # # # # # # #	x'<	=	=	=                	xz	2	2	2 ! !%   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! (..)IJJK	x'<	=	=	=                 hhuXh..G%%%&H'8,,,hh{8h44G???#H'8,,,hhu~hh77G<<< H'8,,, hh~.//G999~H'8,,, 100K	xz	2	2	2                hh{8h44G999~H'8,,,,,sZ   D33D7:D7E;;E?E?!GG	G	H##H'*H''M		MMc           	         | |                      d                   }|                    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	          }|                    d          }|j        d
k    sJ |                    d          }|                    d          }|	                    |          sJ d S )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   s1   E""#Eooa  G<8####eAhhuQxx%a//BH---..H---..H---..

 &%%  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                             dd	g          }| d d                             d                              d
          }|                    |          sJ | d d                             g           }| d d         }|                    |          sJ d}t          j        t          |          5  | d d                             g d           d d d            n# 1 swxY w Y   t          j        t          d          5  | d d                             d	dg           d d d            d S # 1 swxY w Y   d S )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=   ^   sh   eAhhuQxx%a//BH---..H---..H---..

 &%%  E BQBi!!7E"233GRaRy""1%%//22H>>(#####BQBi!!"%%GRaRyH>>(#####	*  
z	-	-	- 5 5bqb	3334445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 
x'?	@	@	@ - -bqb	UFO,,,- - - - - - - - - - - - - - - - - -s$   & FFF8 G%%G),G)c                  @   g d} t          j        | ddg          }|                                sJ t          j        g dg dg dg          }|                    d	ddgd
          }|                                }|j        }|                                rJ t          j	        ||           t          j
        t                    5  t          j	        |                    d	          |                    d	                     d d d            d S # 1 swxY w Y   d S )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    544F)&c
CCCL%%''''' 
$$$,>,>,>@R@R@R+S
 
 
B 
cC:c	B	BB			Bz--///// ,(8999		#$6	7	7 R R
l//446F6K6KC6P6PQQQR R R R R R R R R R R R R R R R R Rs   
<DDDc                     t          j        d| fgddg          }d}t          j        t          |          5  |                    t          j        d          d           d d d            d S # 1 swxY w Y   d S )	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`      s    		&-!8 9&&AQ	R	R	RB
MC	xs	+	+	+ 4 4
V$$F3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4s   *A00A47A4z(ignore::pandas.errors.PerformanceWarningc                      t          j        g d          } |                     d          }t          j        dg          }t          j        ||           d S )N)r   r   r   r   rb   rb   rc   )r   r   r   r   r   )r_   resultr!   s      r#   'test_drop_with_non_monotonic_duplicatesre      sU     
	 8 8 8	9	9BWWV__F%vh//H&(+++++r8   c                     t          j        g d          } d}t          j        t          |          5  |                     dd           d d d            n# 1 swxY w Y   t          j        t          |          5  |                     ddgd           d d d            n# 1 swxY w Y   d}t          j        t          |          5  |                     t          j        gd           d d d            n# 1 swxY w Y   t          j        t          |          5  |                     t          j        dd	d
gd           d d d            n# 1 swxY w Y   t          j        t          j        dfdg          } d}t          j        t          |          5  |                     t          j        ddgd           d d d            d S # 1 swxY w Y   d S )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 8 8	9	9B
,C	xs	+	+	+  
              	xs	+	+	+ ! !
Aa   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
.C	xs	+	+	+ # #
"""# # # # # # # # # # # # # # #	xs	+	+	+ , ,
Aq!+++, , , , , , , , , , , , , , , 
	"&!f 5	6	6B
.C	xs	+	+	+ + +
C ***+ + + + + + + + + + + + + + + + + +sY   AAA>B$$B(+B(#C;;C?C?!&EEE%GGGc                      t          j        dgd          } |                     g           }t          dgd          }t	          j        ||           d S )N)r   )rE   rG   r   rE   )r2   )r   r   r1   r   r   r   )r   rd   r!   s      r#   #test_droplevel_multiindex_one_levelrj      sW    "D688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      s        , , , , , ,                 7- 7- 7-t$ $ $,- - -<R R R.4 4 4 FGG, , HG,+ + +*, , , , ,r8   