
    4iwZ                     n   S SK r S SKrS SKrS SKrS SKJ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SS9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 S*S jr\R8                  R;                  S/ SQ5      S 5       r\R8                  R;                  SSS/5      S 5       r\R8                  R;                  SSS/5      \R8                  R;                  S\R@                  \RB                  /5      S 5       5       r"\R8                  R;                  S/ SQ5      S 5       r#\R8                  R;                  SSS/5      S  5       r$\R8                  R;                  SSS/5      \R8                  R;                  S\R@                  \RB                  /5      S! 5       5       r%\R8                  R;                  S"/ S#Q5      S$ 5       r&\R8                  R;                  S/ SQ5      S% 5       r'\R8                  R;                  SSS/5      S& 5       r(\R8                  R;                  SSS/5      \R8                  R;                  S\R@                  \RB                  /5      S' 5       5       r)\R8                  RU                  S(5      \R8                  R;                  S/ SQ5      S) 5       5       r+g)+    N)Pandas4Warning)Categorical	DataFrameGrouperSeries)get_groupby_method_argsab)keyc                     U S-  $ )N    xs    b/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/pandas/tests/groupby/test_raises.py<lambda>r      s    !a%    )	r   r   r      r   r   r      r   	   T)strict	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   Fc                     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_colr4   ;   s?    	,,q""4Ar2r6B		

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:   H   s6    	,,q=/			

B Ir   c                    [         R                  " XgSS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)NF)matchcheck_stacklevelmethodaggr<   )tmassert_produces_warninggetattrr?   	transformpytestraises)klassmsghowgbgroupby_funcargswarn_categorywarn_msgs           r   _call_and_checkrO   Y   s     
	#	#
 =h)40|+d+\1D1u0(?B-t4E\FF</$/LL55 1
 
 10
 
s%   AC1AC4C
C	C
C$rI   )r>   r?   rD   c           
      R   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S_SS_SS_SS_SS_0 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)4_S/S_S0[        [
        R                  " S15      4_EU   u  pU(       a  US2;   a  S3U S43n
US5;   a  [        n	OmUS":X  a   US   R                  R                  S6:X  a  S7n
OGUS:X  a   US   R                  R                  S6:X  a  S8n
O!US9;   a  U
R                  S:S;5      n
OUS:X  a  S<n
US:X  a	  [        nS=nOS nS>n[        XXX7X5        g )?N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firstidxmaxidxminlastmaxmeanz-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]quantilez4dtype 'object' does not support operation 'quantile'ranksemz!could not convert string to floatshiftsizeskewkurtstdsumvarz%agg function failed [how->var,dtype->)rl   rf   rg   r]   r\   rt   ro   rv   rr   rs   rm   z(dtype 'str' does not support operation '')ro   rt   rr   rs   pyarrowzBoperation 'truediv' not supported for dtype 'str' with dtype 'str'z>operation 'sub' not supported for dtype 'str' with dtype 'str')r[   rZ   objectstrz1Cannot perform reduction 'mean' with string dtype'DataFrameGroupBy.corrwith is deprecatedrU   )r   groupbyhasattr	TypeErrorNotImplementedErrorreescape
ValueErrordtypestoragereplacer   rO   )rI   r"   r$   rK   r.   using_infer_stringr-   rL   rJ   rG   rH   rM   rN   s                r   test_groupby_raises_stringr   p   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
=;D 	IIGH
E;L 	zM;N 	*O;P 	:Q;R 	y"<=S;T 	IIEF
U;\ 	Y VW];^ 	
_;` 	
?@a;b 	c;d 	
e;f 	@Ag;h 	@Ai;j 	
?@k;l 	zm;n 	II=>
o;v w;JEz  
 
 =\N!LC==!\)bgmm.C.Cy.P WCV#3(=(=(J SC11++h.CZ'ECz!&<E]Ur   r?   rD   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)NrQ   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|   rE   rF   r~   rC   )rI   r"   r$   r.   r-   rJ   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                  [        S40U   u  pU(       a)  U[        R                  L a  [        nSUR
                   S3n	[        XXUS5        g )NrQ   r)   rT   zXCould not convert string .* to numeric|Cannot perform reduction 'mean' with string dtypezCannot perform reduction 'z' with string dtyper   )r|   npru   rf   r~   __name__rO   )
rI   r"   r$   r   r.   r   r-   rJ   rG   rH   s
             r   test_groupby_raises_string_npr      s     
B	r	BW 	

@
 JE bgg%E*?+C+C*DDWXE"=r   c           
      p   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4_S[        S4_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 4_S![        S"4_S#S	_S$S	_S%S	_S&S	_S'S	_S([        S)R	                  S*S+/5      4_S,[        S)R	                  S*S-/5      4_S.S	_S/[        S04_S1[        S24_EU   u  pUS:X  a	  [
        n
S3nOS n
S4n[        XXX6X5        g )5NrQ   r)   rR   rS   z3'all' with datetime64 dtypes is no longer supportedrV   z3'any' with datetime64 dtypes is no longer supportedrW   rT   z+cannot perform __mul__ with this index typerX   rY   rZ   r[   r\   z4datetime64 type does not support operation 'cumprod'r]   z3datetime64 type does not support operation 'cumsum'r^   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   z/cannot perform __truediv__ with this index typerl   z1datetime64 type does not support operation 'prod'rm   rn   ro   rp   rq   rr   |z1dtype datetime64\[ns\] does not support operationz1datetime64 type does not support operation 'skew'rs   z1datetime64 type does not support operation 'kurt'rt   ru   z/datetime64 type does not support operation 'sumrv   z0datetime64 type does not support operation 'var'r{   rU   )r   r|   r}   r~   joinr   rO   )rI   r"   r$   rK   r4   r-   rL   rJ   rG   rH   rM   rN   s               r   test_groupby_raises_datetimer     s    
B"<4D	r	BW:%r:....3	PQ3	PQ3 	3 	Y MN	3
 	3 	J3 	*3 	*3 	IUV3 	9ST3 	
3 	3 	3 	*3 	*3  	
!3" 	z#3$ 	
%3& 	*'3( 	z)3* 	*+3, 	:-3. 	y"ST/30 	OP132 	J334 	
536 	z738 	93: 	
;3< 	HHHG
=3N 	HHHG
O3` 	za3b 		LMc3d 		MNe3f g3JEj z!&<E]Ur   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)NrQ   r)   c                     [        S5      er   r   r   s    r   r   .test_groupby_raises_datetime_udf.<locals>.funck  r   r   r   r@   r   )rI   r"   r$   r4   r-   rJ   r   s          r    test_groupby_raises_datetime_udfr   c  sR    	B	r	BW. 
y(<	= 
>	=	=r   c                     UnUR                  US9nU(       a  US   n[        R                  [        [        R
                  " S5      4[        R                  S0U   u  px[        XxXUS5        g )NrQ   r)   z/datetime64[us] does not support operation 'sum'rT   r   )r|   r   ru   r~   r   r   rf   rO   )	rI   r"   r$   r   r4   r-   rJ   rG   rH   s	            r   test_groupby_raises_datetime_npr   r  sq     
B	r	BW 	IIGH
 	 JE E"=r   r   )rl   r\   rr   rs   rv   c           	          [        / SQ/ SQ[        S5      [        R                  " SS9S.5      nUR	                  SS9n[        [        S	S
UU / 5        g )Nr   r   r   r   )daysr'   r	   rQ   z/timedelta64 type does not support .* operationsr>   )r   r*   r3   	timedeltar|   rO   r~   )r   r-   rJ   s      r   test_groupby_raises_timedeltar     sX    	,,q##+		

B 
s	B9

r   c           
         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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-S./5      4_S/S_S0S_S1[        SR                  S2S3/5      4_S4[        SR                  S5S6/5      4_S7[        SR                  S8S9/5      4_S:[        S;4_S<[        SR                  S=S>/5      4_EU   u  pUS:X  a	  [        n
S?nOS n
S@n[        XXX6X5        g )ANrQ   r)   rR   rS   rT   rV   rW   =unsupported operand type\(s\) for \*: 'Categorical' and 'int'rX   rY   rZ   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'r`   ra   rb   rc   rd   re   rf   r   z2'Categorical' .* does not support operation 'mean'2category dtype does not support aggregation 'mean'rg   z4'Categorical' .* does not support operation 'median'4category dtype does not support aggregation 'median'rh   ri   rj   rk   zDunsupported operand type\(s\) for /: 'Categorical' and 'Categorical'rl   .category type does not support prod operationsrm   No matching signature foundrn   ro   1'Categorical' .* does not support operation 'sem'1category dtype does not support aggregation 'sem'rp   rq   rr   0dtype category does not support operation 'skew'.category type does not support skew operationsrs   0dtype category does not support operation 'kurt'.category type does not support kurt operationsrt   1'Categorical' .* does not support operation 'std'1category dtype does not support aggregation 'std'ru   -category type does not support sum operationsrv   1'Categorical' .* does not support operation 'var'1category dtype does not support aggregation 'var'r{   rU   )r   r|   r}   r~   r   r   r   rO   )rI   r"   r$   rK   r:   r-   rL   rJ   rG   rH   rM   rN   s               r   test_groupby_raises_categoryr     s   
 
B"<4D	r	BW:%r:....xzxzx 	x 	L
	x 	x 	Jx 	 ),:
x  	 ),:
!x, 	 ),;
-x8 	 ),:
9xD 	S
ExL 	MxN 	OxP 	*QxR 	*SxT 	
UxV 	zWxX 	HHHH
Yxj 	HHJJ
kx| 	z}x~ 	*x@ 	:AxB 	S
CxJ 	LMKxL 	Y =>MxN 	
OxP 	HHGG
Qxb 	cxd 	
exf 	HHFD
gxx 	HHFD
yxJ 	HHGG
Kx\ 		JK]x^ 	HHGG
_xp qxJEt z!&<E]Ur   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)NrQ   r)   c                     [        S5      er   r   r   s    r   r   .test_groupby_raises_category_udf.<locals>.func:  r   r   r   r@   r   )rI   r"   r$   r:   r-   rJ   r   s          r    test_groupby_raises_category_udfr   1  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  px[        XxXUS5        g )NrQ   r)   z/dtype category does not support operation 'sum'z0dtype category does not support operation 'mean'r   )r|   r   ru   r~   rf   rO   )	rI   r"   r$   r   r:   r-   rJ   rG   rH   s	            r   test_groupby_raises_category_npr   A  sk     
B	r	BW 	MN
>
 JE E"=r   z$ignore:In a future version, the keysc           
      .   Un[        / SQ/ SQSS9US'   [        X65      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 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S_SU	(       a  [        S 4OS_S!U	(       a  [        S 4OS_S"S_S#S_0 S$[        S%4_S&[        S'4_S(S_S)S_S*S_S+[        S4_S,[        S-4_S.[        S/4_S0S_S1[        S2R                  S3S4/5      4_S5S_S6S_S7[        S2R                  S8S9/5      4_S:[        S2R                  S;S</5      4_S=[        S2R                  S>S?/5      4_S@[        SA4_SB[        S2R                  SCSD/5      4_EU   u  pUS:X  a	  [        nSEnOS nSFn[        XXX7X5        g )GNr6   r'   Tr7   r	   )r"   observedr)   rR   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>r  s     'TASASs   rD   FrS   rT   rV   rW   r   rX   rY   rZ   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^   r_   r`   ra   rb   z(empty group due to unobserved categoriesrc   rd   re   rf   r   rg   r   rh   ri   rj   rk   rl   r   rm   r   rn   ro   r   r   r   rp   rq   rr   r   r   rs   r   r   rt   r   r   ru   r   rv   r   r   r{   rU   )r   r   r|   r}   rV   groupsvaluesr~   r   r   r   r   rO   )rI   r"   r$   rK   r   r:   r-   rL   rJ   empty_groupsrG   rH   rM   rN   s                 r   (test_groupby_raises_category_on_categoryr   W  s    
B5'BsG
 #<4D	r	-BW:%r:....<TC'TAQAQAS'T$TL
kfzfzf 	f 	L
	f 	f 	Jf 	 ),@
f  	 ),@
!f, 	 ),A
-f8 	 ),@
9fD 	67EfF 	GfH 	IfJ 	 IJOfP 	 IJUfV 	
WfX 	zYfZ 	PQ[f\ 	9TU]f^ 	z_f` 	*afb 	:cfd 	y"<=eff 	LMgfh 	Y =>ifj 	
kfl 	HHGG
mf~ 	f@ 	
AfB 	HHDF
CfT 	HHDF
Uff 	HHGG
gfx 		JKyfz 	HHGG
{fL MfJEP z!&<E]Ur   rT   ),r3   r   numpyr   rE   pandas.errorsr   pandasr   r   r   r   pandas._testing_testingrA   pandas.tests.groupbyr   fixturearraydictzipr*   r"   r$   r.   r4   r:   rO   markparametrizer   r   ru   rf   r   r   r   r   r   r   r   r   filterwarningsr   r   r   r   <module>r      s}  
  	   (   8 		c
C#
,-Sq6tDE*+	+	,f5P.QR e}% & 	 	 	 	  " KM6.  >?qV @qVh  45 6  45*RVVRWW,=>> ? 6>@  >?IV @IVX  45 6  45*RVVRWW,=>> ? 6>( !KL M*  >?OV @OVd  45 6  45*RVVRWW,=>> ? 6>( BC >?LV @ DLVr   