
    MhV                     P   S SK r S SKrS SKrS SKrS SKJrJrJrJ	r	  S SK
Jr  S SKJr  \R                  " SS/SS/\" SS9S / SQ\R                   " / SQ5      \" \" \" S	5      / SQ5      5      \	" / S
Q5      \	" / S
Q5      \	" / SQ5      //
S9S 5       r\R                  " SS/S9S 5       r\R                  S 5       r\R                  S 5       r\R                  S 5       r\R                  S 5       rS)S jr\R6                  R9                  S/ SQ5      S 5       r\R6                  R9                  SSS/5      S 5       r\R6                  R9                  SSS/5      \R6                  R9                  S\R>                  \R@                  /5      S 5       5       r!\R6                  R9                  S/ SQ5      S 5       r"\R6                  R9                  SSS/5      S 5       r#\R6                  R9                  SSS/5      \R6                  R9                  S\R>                  \R@                  /5      S  5       5       r$\R6                  R9                  S!/ S"Q5      S# 5       r%\R6                  R9                  S/ SQ5      S$ 5       r&\R6                  R9                  SSS/5      S% 5       r'\R6                  R9                  SSS/5      \R6                  R9                  S\R>                  \R@                  /5      S& 5       5       r(\R6                  R9                  S/ SQ5      S' 5       r)S( r*g)*    N)Categorical	DataFrameGrouperSeries)get_groupby_method_argsab)keyc                     U S-  $ )N    xs    R/var/www/html/env/lib/python3.13/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                     U R                   $ Nparamrequests    r   byr       s     ==r   TFc                     U R                   $ r   r   r   s    r   groupby_seriesr"   '   s    ==r   c                  R    [        / SQ/ SQ[        S5      [        S5      S.5      n U $ )Nr   r   r   	xyzwtyuior   r	   cd)r   rangelistdfs    r   df_with_string_colr,   ,   s-    	,,qk"		

B Ir   c                  t    [        / SQ/ SQ[        S5      [        R                  " SSSSSSS	5      S
.5      n U $ )Nr   r   r   i  r   
         i`= r%   )r   r(   datetimer*   s    r   df_with_datetime_colr2   9   s?    	,,q""4Ar2r6B		

B Ir   c            	      d    [        / SQ/ SQ[        S5      [        R                  " SS9S.5      n U $ )Nr   r   r   r   )daysr%   )r   r(   r1   	timedeltar*   s    r   df_with_timedelta_colr6   F   s3    	,,q##+		

B Ir   c                  Z    [        / SQ/ SQ[        S5      [        / SQ/ SQSS9S.5      n U $ )Nr   r   r   	r   r   r   r   r	   r	   r	   r	   r&   r%   T
categoriesordered)r   r(   r   r*   s    r   df_with_cat_colr<   S   s6    	,,q=/			

B Ir   c                    US:X  a  S O[         n[        R                  " XvS9   U cC  US:X  a  [        X45      " U6   OUS:X  a  UR                  " U/UQ76   OsUR
                  " U/UQ76   O_[        R                  " XS9   US:X  a  [        X45      " U6   O-US:X  a  UR                  " U/UQ76   OUR
                  " U/UQ76   S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)N matchmethodagg)FutureWarningtmassert_produces_warninggetattrrB   	transformpytestraises)klassmsghowgbgroupby_funcargswarn_msg
warn_klasss           r   _call_and_checkrR   d   s    !R]J		#	#J	?=h)40|+d+\1D1u0(?B-t4E\FF</$/LL55 1 
@	? 10 
@	?s%   AC#>ACC#
C 	C##
C1rL   )rA   rB   rG   c           	      8   Un[        X55      nUR                  US9nU(       a  US   nUS:X  a  [        US5      (       a   eg 0 SS_SS_SS_S[        S4_S	S_S
S_S[        [        4S4_S[        [        4S4_S[        [        4S4_S[        [        4S4_S[        S4_SS_SS_SS_SS_SS_SS_0 SS_S[        [
        R                  " S5      4_S[        [
        R                  " S5      4_S S_S!S_S"S_S#[        S4_S$[        [
        R                  " S%5      4_S&[        S'4_S(S_S)[        S*4_S+S_S,S_S-[        S*4_S.[        S*4_S/S_S0[        [
        R                  " S15      4_EU   u  pUS:X  a  U(       a  S2OS3n
U
 S43nOS5n[        XXX6U5        g )6Nr    r'   corrwithallNr>   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idxmaxidxminlastmaxmean-agg function failed [how->mean,dtype->object]medianz/agg function failed [how->median,dtype->object]minngroupnunique
pct_changeprodz-agg function failed [how->prod,dtype->object]quantilez,cannot be performed against 'object' dtypes!ranksemz!could not convert string to floatshiftsizeskewstdsumvarz%agg function failed [how->var,dtype->r   r   GroupBy.fillna is deprecatedr>   )	r   groupbyhasattr	TypeErrorNotImplementedErrorreescape
ValueErrorrR   )rL   r    r"   rN   r,   r+   rO   rM   rJ   rK   kindrP   s               r   test_groupby_raises_stringr   x   s    
B"<4D	r	BW:%r:....;z;z; 	; 	Y 34	;
 	; 	J; 	 ),V
; 	 ),V
; 	 ),W
;& 	 ),V
';. 	67/;0 	1;2 	*3;4 	5;6 	*7;8 	*9;: 	
;;< 	z=;> 	IIEF
?;F 	IIGH
G;N 	zO;P 	*Q;R 	:S;T 	y"<=U;V 	IIEF
W;^ 	Y NO_;` 	
a;b 	
?@c;d 	e;f 	
g;h 	@Ai;j 	
?@k;l 	zm;n 	II=>
o;v w;JEz x)x{V78EXFr   rB   rG   c                     UnUR                  US9nU(       a  US   nS n[        R                  " [        SS9   [	        XP5      " U5        S S S 5        g ! , (       d  f       g = f)NrT   r'   c                     [        S5      eNTest error messager}   r   s    r   func,test_groupby_raises_string_udf.<locals>.func       ,--r   r   r?   r{   rH   rI   r}   rF   )rL   r    r"   r,   r+   rM   r   s          r   test_groupby_raises_string_udfr      sR    	B	r	BW. 
y(<	= 
>	=	=   A
A#groupby_func_npc           
          UnUR                  US9nU(       a  US   n[        R                  S[        R                  [        [
        R                  " S5      40U   u  pxU(       a  Sn	OSn	[        XxXUSU	S9  g )	NrT   r'   rW   rj   using SeriesGroupBy.[sum|mean]!using DataFrameGroupBy.[sum|mean]r   rP   )r{   nprx   ri   r}   r   r   rR   )
rL   r    r"   r   r,   r+   rM   rJ   rK   rP   s
             r   test_groupby_raises_string_npr      s~     
B	r	BW 	

IIEF
 JE 36E"xPr   c           
      L   Un[        X55      nUR                  US9nU(       a  US   nUS:X  a  [        US5      (       a   eg 0 SS_SS_SS_S[        S4_S	S_S
S_SS_SS_S[        S4_S[        S4_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_S[        S4_S [        S!4_S"S_S#S_S$S_S%S_S&S_S'[        S(R	                  S)S*/5      4_S+S_S,[        S-4_S.[        S/4_EU   u  pUS0;   a  S1U S23n
OUS:X  a  U(       a  S3OS4nU S53n
OS6n
[        XXX6U
S79  g )8NrT   r'   rU   rV   rW   rX   rY   z+cannot perform __mul__ with this index typerZ   r[   r\   r]   r^   z3datetime64 type does not support cumprod operationsr_   z2datetime64 type does not support cumsum operationsr`   rb   rc   rd   re   rf   rg   rh   ri   rk   rl   rm   rn   ro   z/cannot perform __truediv__ with this index typerp   z%datetime64 type does not support prodrq   rr   rs   rt   ru   rv   |z1dtype datetime64\[ns\] does not support reductionz0datetime64 type does not support skew operationsrw   rx   /datetime64 type does not support sum operationsry   z/datetime64 type does not support var operations)rX   rV   'z&' with datetime64 dtypes is deprecatedr   r   rz   r>   r   )r   r{   r|   r}   joinrR   )rL   r    r"   rN   r2   r+   rO   rM   rJ   rK   rP   r   s               r   test_groupby_raises_datetimer      s    
B"<4D	r	BW:%r:....+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+: 	;+< 	
=+> 	HHHF
?+P 	zQ+R 		LMS+T 		LMU+V W+JEZ ~%|n$JK		!)x{V78EhOr   c                     UnUR                  US9nU(       a  US   nS n[        R                  " [        SS9   [	        XP5      " U5        S S S 5        g ! , (       d  f       g = f)NrT   r'   c                     [        S5      er   r   r   s    r   r   .test_groupby_raises_datetime_udf.<locals>.funcD  r   r   r   r?   r   )rL   r    r"   r2   r+   rM   r   s          r    test_groupby_raises_datetime_udfr   <  sR    	B	r	BW. 
y(<	= 
>	=	=r   c           
          UnUR                  US9nU(       a  US   n[        R                  [        S4[        R                  S0U   u  pxU(       a  Sn	OSn	[        XxXUSU	S9  g )	NrT   r'   r   rW   r   r   r   r   r{   r   rx   r}   ri   rR   )
rL   r    r"   r   r2   r+   rM   rJ   rK   rP   s
             r   test_groupby_raises_datetime_npr   K  sq     
B	r	BW 	MN
 JE
 36E"xPr   r   )rp   r^   rv   ry   c                 N    UnUR                  SS9n[        [        SSUU / 5        g )Nr   rT   z/timedelta64 type does not support .* operationsrA   )r{   rR   r}   )r   r6   r+   rM   s       r   test_groupby_raises_timedeltar   c  s1    	B	s	B9

r   c           	         Un[        X65      nUR                  US9nU(       a  US   nUS:X  a  [        US5      (       a   eg 0 SS_SS_SS_S[        S4_S	S_S
S_S[        [        4S4_S[        [        4S4_S[        [        4S4_S[        [        4S4_S[        S4_SS_SU(       d  [        S4OS_SS_SS_SS_SS_0 SS_S[        SR                  SS /5      4_S![        SR                  S"S#/5      4_S$S_S%S_S&S_S'[        S(4_S)[        S*4_S+[        S,4_S-S_S.[        SR                  S/S0/5      4_S1S_S2S_S3[        SR                  S4S5/5      4_S6[        SR                  S7S8/5      4_S9[        S:4_S;[        SR                  S<S=/5      4_EU   u  pUS:X  a  U(       a  S>OS?nU S@3nOSAn[        XXX7U5        g )BNrT   r'   rU   rV   rW   rX   rY   =unsupported operand type\(s\) for \*: 'Categorical' and 'int'rZ   r[   r\   zz(category type does not support cummax operations|category dtype not supported|cummax is not supported for category dtype)r]   zz(category type does not support cummin operations|category dtype not supported|cummin is not supported for category dtype)r^   z|(category type does not support cumprod operations|category dtype not supported|cumprod is not supported for category dtype)r_   zz(category type does not support cumsum operations|category dtype not supported|cumsum is not supported for category dtype)r`   zDunsupported operand type\(s\) for -: 'Categorical' and 'Categorical'rb   rc   SCannot setitem on a Categorical with a new category \(0\), set the categories firstrd   re   rf   rg   rh   ri   r   z2'Categorical' .* does not support reduction 'mean'2category dtype does not support aggregation 'mean'rk   z4'Categorical' .* does not support reduction 'median'4category dtype does not support aggregation 'median'rl   rm   rn   ro   zDunsupported operand type\(s\) for /: 'Categorical' and 'Categorical'rp   .category type does not support prod operationsrq   zNo matching signature foundrr   rs   1'Categorical' .* does not support reduction 'sem'1category dtype does not support aggregation 'sem'rt   ru   rv   0dtype category does not support reduction 'skew'.category type does not support skew operationsrw   1'Categorical' .* does not support reduction 'std'1category dtype does not support aggregation 'std'rx   -category type does not support sum operationsry   1'Categorical' .* does not support reduction 'var'1category dtype does not support aggregation 'var'r   r   rz   r>   )r   r{   r|   r}   r~   r   rR   )rL   r    r"   rN   using_copy_on_writer<   r+   rO   rM   rJ   rK   r   rP   s                r   test_groupby_raises_categoryr   r  s   
 
B"<4D	r	BW:%r:....vzvzv 	v 	L
	v 	v 	Jv 	 ),:
v  	 ),:
!v, 	 ),;
-v8 	 ),:
9vD 	S
EvL 	MvN 	
 #	 '
 [v\ 	]v^ 	*_v` 	*avb 	
cvd 	zevf 	HHHH
gvx 	HHJJ
yvJ 	zKvL 	*MvN 	:OvP 	S
QvX 	LMYvZ 	Y =>[v\ 	
]v^ 	HHGG
_vp 	qvr 	
svt 	HHFD
uvF 	HHGG
GvX 		JKYvZ 	HHGG
[vl mvJEp x)x{V78EXFr   c                     UnUR                  US9nU(       a  US   nS n[        R                  " [        SS9   [	        XP5      " U5        S S S 5        g ! , (       d  f       g = f)NrT   r'   c                     [        S5      er   r   r   s    r   r   .test_groupby_raises_category_udf.<locals>.func  r   r   r   r?   r   )rL   r    r"   r<   r+   rM   r   s          r    test_groupby_raises_category_udfr     sT     
B	r	BW. 
y(<	= 
>	=	=r   c           
          UnUR                  US9nU(       a  US   n[        R                  [        S4[        R                  [        S40U   u  pxU(       a  Sn	OSn	[        XxXUSU	S9  g )	NrT   r'   r   r   r   r   r   r   r   )
rL   r    r"   r   r<   r+   rM   rJ   rK   rP   s
             r   test_groupby_raises_category_npr     sz     
B	r	BW 	KL
@
 JE 36E"xPr   c           	         Un[        / SQ/ SQSS9US'   [        X75      nUR                  XS9n	U(       a  U	S   n	US:X  a  [        U	S5      (       a   eg U(       + =(       a*    [	        S	 U	R
                  R                  5        5       5      n
U(       dF  U S
:w  a@  [        U[        5      (       a+  [        US   [        5      (       a  USS/:X  a  U
(       a   eSn
U S
:X  a  Sn
0 SS_SS_SS_S[        S4_SS_SS_S[        [        4S4_S[        [        4S4_S[        [        4S4_S[        [        4S4_S[        S4_SS_S U(       d  [        S!4OS_S"S_S#U
(       a  [        S$4OS_S%U
(       a  [        S$4OS_S&S_0 S'S_S([        S)4_S*[        S+4_S,S_S-S_S.S_S/[        S4_S0[        S14_S2[        S34_S4S_S5[        S6R                  S7S8/5      4_S9S_S:S_S;[        S6R                  S<S=/5      4_S>[        S6R                  S?S@/5      4_SA[        SB4_SC[        S6R                  SDSE/5      4_EU   u  pUS :X  a  U(       a  SFOSGnU SH3nOS3n[        XX	X8U5        g )INr8   r%   Tr9   r   )r    observedr'   rU   c              3   8   #    U  H  oR                   v   M     g 7fr   )empty).0groups     r   	<genexpr>;test_groupby_raises_category_on_category.<locals>.<genexpr>H  s     'TASASs   rG   r   r	   FrV   rW   rX   rY   r   rZ   r[   r\   zz(cummax is not supported for category dtype|category dtype not supported|category type does not support cummax operations)r]   zz(cummin is not supported for category dtype|category dtype not supported|category type does not support cummin operations)r^   z|(cumprod is not supported for category dtype|category dtype not supported|category type does not support cumprod operations)r_   zz(cumsum is not supported for category dtype|category dtype not supported|category type does not support cumsum operations)r`   ra   rb   rc   r   rd   re   z(empty group due to unobserved categoriesrf   rg   rh   ri   r   rk   r   rl   rm   rn   ro   rp   r   rq   r>   rr   rs   r   r   r   rt   ru   rv   r   r   rw   r   r   rx   r   ry   r   r   r   r   rz   )r   r   r{   r|   rX   groupsvalues
isinstancer)   strr}   r~   r   r   rR   )rL   r    r"   rN   r   r   r<   r+   rO   rM   empty_groupsrJ   rK   r   rP   s                  r   (test_groupby_raises_category_on_categoryr   -  s)    
B5'BsG
 #<4D	r	-BW:%r:....<TC'TAQAQAS'T$TL;r4  r!uc""3*
kdzdzd 	d 	L
	d 	d 	Jd 	 ),@
d  	 ),@
!d, 	 ),A
-d8 	 ),@
9dD 	67EdF 	GdH 	
 #	 '
 UdV 	WdX 	 IJ]d^ 	 IJcdd 	
edf 	zgdh 	PQidj 	9TUkdl 	zmdn 	*odp 	:qdr 	y"<=sdt 	LMudv 	YOwdx 	
ydz 	HHGG
{dL 	MdN 	
OdP 	HHDF
Qdb 	HHGG
cdt 		JKudv 	HHGG
wdH IdJEL x)x{V78EXFr   c                  "   [        S/S/S/S.5      n Sn[        R                  " [        US9   U R	                  SSS9nS S S 5        [
        R                  " [        S	S9   WS
     S S S 5        g ! , (       d  f       N6= f! , (       d  f       g = f)Nr   r   r   )r   r	   r&   z+DataFrame.groupby with axis=1 is deprecatedr?   r   )axisz'Cannot subset columns when using axis=1r	   )r   rD   rE   rC   r{   rH   rI   r   )r+   rK   rM   s      r   %test_subsetting_columns_axis_1_raisesr     st    	!A3aS1	2B
7C		#	#M	=ZZ!Z$ 
>	z)R	S
3 
T	S 
>	=	S	Ss   A/ B /
A= 
B)r>   )+r1   r   numpyr   rH   pandasr   r   r   r   pandas._testing_testingrD   pandas.tests.groupbyr   fixturearraydictzipr(   r    r"   r,   r2   r6   r<   rR   markparametrizer   r   rx   ri   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s{  
  	     8 		c
C#
,-Sq678*+	+	,f5P.QR e}% & 	 	 	 	 	 	   6(  >?PG @PGf  45 6  45*RVVRWW,=>Q ? 6Q2  >?BP @BPJ  45 6  45*RVVRWW,=>Q ? 6Q, !CD E  >?LG @LG^  45 6  45*RVVRWW,=>Q ? 6Q2  >?TG @TGnr   