
    dAO                        d dl Z d dlZd dlZd dlmZmZmZmZ d dl	m
Z
  ej        ddgddg ed          d g d ej        g d           e e ed	          g d                     eg d
           eg d
           eg d          gg
          d             Z ej        ddg          d             Zej                            dg d          d             Zej                            dddg          d             Zej                            dddg          ej                            dej        ej        g          d                         Zej                            dg d          d             Zej                            dddg          d             Zej                            dddg          ej                            dej        ej        g          d                         Zej                            dg d          d             Zej                            dddg          d             Zej                            dddg          ej                            dej        ej        g          d                         Zej                            dg d          d             Zd  Z dS )!    N)Categorical	DataFrameGrouperSeries)get_groupby_method_argsab)keyc                     | dz  S )N    xs    \/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/pandas/tests/groupby/test_raises.py<lambda>r      s
    !a%     )	r   r   r      r   r   r      r   	   	r   r   r   r   r   r   r   r   r   	r   r      r   r   r   r   r   r   )paramsc                     | j         S Nparamrequests    r   byr       s     =r   TFc                     | j         S r   r   r   s    r   groupby_seriesr"   %   s
    =r   how)methodagg	transformc                 h   t          g dg dt          d          t          d          d          }t          ||          }|                    |          }|r"|d         }|dk    rt          |d          rJ d S i d	d
dd
dd
dt          dfdd
dd
dt          t          fdfdt          t          fdfdt          t          fdfdt          t          fdfdt          dfdd
dd
dd
dt          dfdt          d fd!d
i d"d
d#t          d$fd%t          d&fd'd
d(d
d)d
d*t          dfd+t          d,fd-t          d.fd/d
d0t          d&fd1d
d2d
d3t          d&fd4t          d&fd5d
d6t          d&f|         \  }}|A| d7k    r t          ||          |  d S | d8k    r |j
        |g|R   d S  |j        |g|R   d S t          j        ||9          5  | d7k    r t          ||          |  n#| d8k    r |j
        |g|R   n |j        |g|R   d d d            d S # 1 swxY w Y   d S ):Nr   r   r   	xyzwtyuior   r	   cdr    r+   corrwithallN anybfillzCould not convertcountcumcountcummaxzH(function|cummax) is not (implemented|supported) for (this|object) dtypecumminzH(function|cummin) is not (implemented|supported) for (this|object) dtypecumprodzI(function|cumprod) is not (implemented|supported) for (this|object) dtypecumsumzH(function|cumsum) is not (implemented|supported) for (this|object) dtypediffunsupported operand typeffillfillnafirstidxmaxz#'argmax' not allowed for this dtypeidxminz#'argmin' not allowed for this dtypelastmaxmean.Could not convert xy?z?w?t?y?u?i?o? to numericmedianz!could not convert string to floatminngroupnunique
pct_changeprodz0can't multiply sequence by non-int of type 'str'quantilez,cannot be performed against 'object' dtypes!ranksemshiftsizeskewstdsumvarr$   r%   match)r   rangelistr   groupbyhasattr	TypeErrorNotImplementedError
ValueErrorgetattrr%   r&   pytestraises	r#   r    r"   groupby_funcdfargsgbklassmsgs	            r   test_groupby_raises_stringrf   *   sH   	,,,,,,qk""		
 	

 
B #<44D	r		B W:%%r:.....F/z/z/ 	/ 	Y 34	/
 	/ 	J/ 	 ),V
/ 	 ),V
/ 	 ),W
/& 	 ),V
'/. 	67//0 	1/2 	*3/4 	5/6 	9CD7/8 	9CD9/: 	
;/ /< 	z=/> 	LM?/@ 	9ABA/B 	zC/D 	*E/F 	:G/H 	y"<=I/J 	NOK/L 	Y NOM/N 	
O/P 	
?@Q/R 	S/T 	
U/V 	?@W/X 	
?@Y/Z 	z[/\ 		>?]/ /^ _/JE3b }(??%GB%%t,,,,E\\BF<'$''''''BL-------]5,,, 	2 	2h)L))4000|+d+++++\1D1111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   >H''H+.H+r%   r&   c                 J   t          g dg dt          d          t          d          d          }|                    |          }|r|d         }d }t	          j        t          d	
          5   t          ||           |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   r(   r)   r,   r+   c                      t          d          NTest error messagerY   r   s    r   funcz,test_groupby_raises_string_udf.<locals>.func       ,---r   rj   rS   )r   rU   rV   rW   r]   r^   rY   r\   r#   r    r"   ra   rc   rl   s         r   test_groupby_raises_string_udfro      s   	,,,,,,qk""		
 	

 
B 
r		B W. . . 
y(<	=	=	=  C                 s   1BBBgroupby_func_npc                    t          g dg dt          d          t          d          d          }|                    |          }|r|d         }t          j        dt          j        t          d	fi|         \  }}| t          ||           |           d S t          j
        ||
          5   t          ||           |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   r(   r)   r,   r+   r/   rC   rS   )r   rU   rV   rW   nprQ   rB   rY   r\   r]   r^   r#   r    r"   rp   ra   rc   rd   re   s           r   test_groupby_raises_string_nprt      sN    
,,,,,,qk""		
 	

 
B 
r		B W 	

)MN JE3
 }C)))))]5,,, 	. 	.GB_---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   0CCCc                    t          g dg dt          d          t          j        ddddddd	          d
          }t          ||          }|                    |          }|r"|d         }|dk    rt          |d          rJ d S i dddddddt          dfdddddddddt          dfdt          dfddddddddddd dd!di d"dd#dd$dd%dd&dd'dd(t          d)fd*t          d+fd,dd-dd.dd/dd0dd1t          d2fd3dd4t          d5fd6d|         \  }}|A| d7k    r t          ||          |  d S | d8k    r |j        |g|R   d S  |j	        |g|R   d S t          j        ||9          5  | d7k    r t          ||          |  n#| d8k    r |j        |g|R   n |j	        |g|R   d d d            d S # 1 swxY w Y   d S ):Nr   r   r     r   
         `= r)   r,   r+   r-   r.   r/   r1   r2   z+cannot perform __mul__ with this index typer3   r4   r5   r6   r7   z3datetime64 type does not support cumprod operationsr8   z2datetime64 type does not support cumsum operationsr9   r;   r<   r=   r>   r?   r@   rA   rB   rD   rE   rF   rG   rH   z/cannot perform __truediv__ with this index typerI   z%datetime64 type does not support prodrJ   rK   rL   rM   rN   rO   z1dtype datetime64\[ns\] does not support reductionrP   rQ   /datetime64 type does not support sum operationsrR   r$   r%   rS   )r   rU   datetimer   rW   rX   rY   r\   r%   r&   r]   r^   r_   s	            r   test_groupby_raises_datetimer}      s   	,,,,,,q"4Ar2r6BB		
 	

 
B #<44D	r		B W:%%r:.....F#z#z# 	# 	Y MN	#
 	# 	J# 	*# 	*# 	ITU# 	9RS# 	
# 	# 	*# 	# 	*#  	*!#" 	
## #$ 	z%#& 	
'#( 	*)#* 	z+#, 	*-#. 	:/#0 	y"ST1#2 	CD3#4 	J5#6 	
7#8 	z9#: 	;#< 	
=#> 	PQ?#@ 	zA#B 		LMC#D 	zE# #F G#JE3J }(??%GB%%t,,,,E\\BF<'$''''''BL-------]5,,, 	2 	2h)L))4000|+d+++++\1D1111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   >GGGc                 `   t          g dg dt          d          t          j        ddddddd	          d
          }|                    |          }|r|d         }d }t	          j        t          d          5   t          ||           |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   rv   r   rw   rx   ry   rz   r)   r,   r+   c                      t          d          ri   rk   r   s    r   rl   z.test_groupby_raises_datetime_udf.<locals>.func  rm   r   rj   rS   )r   rU   r|   rW   r]   r^   rY   r\   rn   s         r    test_groupby_raises_datetime_udfr      s   	,,,,,,q"4Ar2r6BB		
 	

 
B 
r		B W. . . 
y(<	=	=	=  C                 s   <B##B'*B'c                    t          g dg dt          d          t          j        ddddddd	          d
          }|                    |          }|r|d         }t          j        t          dft          j        di|         \  }}| t          ||           |           d S t          j
        ||          5   t          ||           |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   rv   r   rw   rx   ry   rz   r)   r,   r+   r{   r/   rS   )r   rU   r|   rW   rr   rQ   rY   rB   r\   r]   r^   rs   s           r   test_groupby_raises_datetime_npr     s]    
,,,,,,q"4Ar2r6BB		
 	

 
B 
r		B W 	MN
 JE3
 }C)))))]5,,, 	. 	.GB_---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   ;C""C&)C&c           
      ~   t          g dg dt          d          t          g dg dd          d          }t          ||          }|                    |          }|r"|d	         }|d
k    rt          |d
          rJ d S i ddddddd
t          dfdddddt          t          fdfdt          t          fdfdt          t          fdfdt          t          fdfdt          dfddd|s	t          dfndddd dd!dd"di d#dd$t          d%fd&t          d'fd(dd)dd*dd+t          d,fd-t          d.fd/t          d0fd1dd2t          d3fd4dd5dd6t          d7fd8t          d3fd9t          d:fd;t          d<f|         \  }}	|A| d=k    r t          ||          |  d S | d>k    r |j
        |g|R   d S  |j        |g|R   d S t          j        ||	?          5  | d=k    r t          ||          |  n#| d>k    r |j
        |g|R   n |j        |g|R   d d d            d S # 1 swxY w Y   d S )@Nr   r   r   	r   r   r   r   r	   r	   r	   r	   r*   r)   T
categoriesorderedr,   r+   r-   r.   r/   r1   r2   =unsupported operand type\(s\) for \*: 'Categorical' and 'int'r3   r4   r5   zz(category type does not support cummax operations|category dtype not supported|cummax is not supported for category dtype)r6   zz(category type does not support cummin operations|category dtype not supported|cummin is not supported for category dtype)r7   z|(category type does not support cumprod operations|category dtype not supported|cumprod is not supported for category dtype)r8   zz(category type does not support cumsum operations|category dtype not supported|cumsum is not supported for category dtype)r9   zDunsupported operand type\(s\) for -: 'Categorical' and 'Categorical'r;   r<   SCannot setitem on a Categorical with a new category \(0\), set the categories firstr=   r>   r?   r@   rA   rB   C'Categorical' with dtype category does not support reduction 'mean'rD   E'Categorical' with dtype category does not support reduction 'median'rE   rF   rG   rH   zDunsupported operand type\(s\) for /: 'Categorical' and 'Categorical'rI   .category type does not support prod operationsrJ   zNo matching signature foundrK   rL   #Cannot cast object dtype to float64rM   rN   rO   C'Categorical' with dtype category does not support reduction 'skew'rP   rQ   -category type does not support sum operationsrR   B'Categorical' with dtype category does not support reduction 'var'r$   r%   rS   )r   rU   r   r   rW   rX   rY   rZ   r[   r\   r%   r&   r]   r^   )
r#   r    r"   r`   using_copy_on_writera   rb   rc   rd   re   s
             r   test_groupby_raises_categoryr   1  s   
 
,,,,,,q===///  			
 		

 
B #<44D	r		B W:%%r:.....FRzRzR 	R 	L
	R 	R 	JR 	 ),<
R  	 ),:
!R, 	 ),;
-R8 	 ),:
9RD 	S
ERL 	MRN 	
 #)
 
 [R\ 	]R^ 	*_R` 	*aRb 	
cR Rd 	zeRf 	Q
gRn 	S
oRv 	zwRx 	*yRz 	:{R| 	S
}RD 	LMERF 	Y =>GRH 	
IRJ 	
ABKRL 	MRN 	
ORP 	Q
QRX 	
ABYRZ 		JK[R\ 	P
]R Rd eRJE3h }(??%GB%%t,,,,E\\BF<'$''''''BL-------]5,,, 	2 	2h)L))4000|+d+++++\1D1111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   '>H22H69H6c           
      X   t          g dg dt          d          t          g dg dd          d          }|                    |          }|r|d	         }d
 }t	          j        t          d          5   t          ||           |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r)   Tr   r,   r+   c                      t          d          ri   rk   r   s    r   rl   z.test_groupby_raises_category_udf.<locals>.func  rm   r   rj   rS   )r   rU   r   rW   r]   r^   rY   r\   rn   s         r    test_groupby_raises_category_udfr     s*    
,,,,,,q===///  			
 		

 
B 
r		B W. . . 
y(<	=	=	=  C                 s   8BB#&B#c           
         t          g dg dt          d          t          g dg dd          d          }|                    |          }|r|d	         }t          j        t          d
ft          j        t          dfi|         \  }}| t          ||           |           d S t          j
        ||          5   t          ||           |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r)   Tr   r,   r+   r   r   rS   )r   rU   r   rW   rr   rQ   rY   rB   r\   r]   r^   rs   s           r   test_groupby_raises_category_npr     ss    
,,,,,,q===///  			
 		

 
B 
r		B W 	KL
Q
 JE3 }C)))))]5,,, 	. 	.GB_---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   >C%%C),C)c           
      0   t          t          g dg dd          g dt          d          t          g dg dd          d          }t          ||          }|                    ||          }|r"|d	         }|d
k    rt          |d
          rJ d S t          d |j                                        D                       }	i ddddddd
t          dfdddddt          t          fdfdt          t          fdfdt          t          fdfdt          t          fdfdt          dfddd|s	t          dfndd dd!|	r	t          d"fndd#|	r	t          d$fndd%di d&dd't          d(fd)t          d*fd+dd,dd-dd.t          dfd/t          d0fd1t          d2fd3dd4t          d5fd6dd7dd8t          d9fd:t          d5fd;t          d<fd=t          d>f|         \  }
}|
A| d?k    r t          ||          |  d S | d@k    r |j        |g|R   d S  |j        |g|R   d S t          j        |
|A          5  | d?k    r t          ||          |  n#| d@k    r |j        |g|R   n |j        |g|R   d d d            d S # 1 swxY w Y   d S )BNr   r)   Tr   r   r   )	r   r   r   r   r	   r	   r*   r*   r*   )r    observedr+   r-   c              3   $   K   | ]}|j         V  d S r   )empty).0groups     r   	<genexpr>z;test_groupby_raises_category_on_category.<locals>.<genexpr>  s$      CCuu{CCCCCCr   r.   r/   r1   r2   r   r3   r4   r5   zz(cummax is not supported for category dtype|category dtype not supported|category type does not support cummax operations)r6   zz(cummin is not supported for category dtype|category dtype not supported|category type does not support cummin operations)r7   z|(cumprod is not supported for category dtype|category dtype not supported|category type does not support cumprod operations)r8   zz(cumsum is not supported for category dtype|category dtype not supported|category type does not support cumsum operations)r9   r:   r;   r<   r   r=   r>   z*attempt to get argmax of an empty sequencer?   z*attempt to get argmin of an empty sequencer@   rA   rB   r   rD   r   rE   rF   rG   rH   rI   r   rJ   r0   rK   rL   r   rM   rN   rO   r   rP   rQ   r   rR   r   r$   r%   rS   )r   r   rU   r   rW   rX   r1   groupsvaluesrY   rZ   r[   r\   r%   r&   r]   r^   )r#   r    r"   r`   r   r   ra   rb   rc   empty_groupsrd   re   s               r   (test_groupby_raises_category_on_categoryr     sD   
 
===///  
 -,,q===///  	
 	

 
B  #<44D	rH	-	-B W:%%r:.....FCC	0@0@0B0BCCCCCLPzPzP 	P 	L
	P 	P 	JP 	 ),B
P  	 ),@
!P, 	 ),A
-P8 	 ),B
9PD 	67EPF 	GPH 	
 #)
 
 UPV 	WPX 	:KLL]P^ 	:KLLcPd 	
eP Pf 	zgPh 	Q
iPp 	S
qPx 	zyPz 	*{P| 	:}P~ 	y"<=P@ 	LMAPB 	YOCPD 	
EPF 	
ABGPH 	IPJ 	
KPL 	Q
MPT 	
ABUPV 		JKWPX 	P
YP P` aPJE3d }(??%GB%%t,,,,E\\BF<'$''''''BL-------]5,,, 	2 	2h)L))4000|+d+++++\1D1111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s    >JJJc                      t          dgdgdgd          } |                     dd          }t          j        t          d          5  |d	          d d d            d S # 1 swxY w Y   d S )
Nr   r   r   )r   r	   r*   r   )axisz'Cannot subset columns when using axis=1rS   r	   )r   rW   r]   r^   r[   )ra   rc   s     r   %test_subsetting_columns_axis_1_raisesr   t  s    	!A3aS11	2	2B	Ca	 	 B	z)R	S	S	S  
3                 s   		AA#&A#)!r|   numpyrr   r]   pandasr   r   r   r   pandas.tests.groupbyr   fixturearraydictziprU   r    r"   markparametrizerf   ro   rQ   rB   rt   r}   r   r   r   r   r   r   r   r   r   r   <module>r      s,  
                  9 8 8 8 8 8 		c
C###,,,--SSq6667788***++	+++	,	,ff5P5P5P.Q.QR     e}%%%  &%  > > >??R2 R2 @?R2j  455  65*  455*RVRW,=>>. . ?> 65.6  > > >??F2 F2 @?F2R  455  65,  455*RVRW,=>>. . ?> 65.6  > > >??|2 |2 @?|2~  455  654  455*RVRW,=>>. . ?> 65.D  > > >??@2 @2 @?@2F    r   