
    Pi;                        d dl Z d dlZd dlmZ d dlmZ d dlZd dlmZm	Z	m
Z
mZmZ d dlmZ d dlmZ  G d d          Zej                            dg d	          ej                            d
ddej        g          ej                            ddgddgg          d                                     Zej                            deeeeg          d             ZdS )    N)lib)Pandas4Warning)	DataFrameIndexSeries	Timestamp
date_range)get_groupby_method_argsc                      e Zd Zej        d             Zej                            dddg          d             Zej                            dddg          d             Z	ej                            dd	d
g          d             Z
ej                            dddg          d             Zej                            dddg          d             Zej                            dddg          d             Zd ZdS )TestNumericOnlyc                 b   t          g dg dg dt          g dd          t          g dt                    t          t          d                                        d          g d	t          d
d          t          d
dd          t          j        ddd          d
g d          }|S )N)   r      )r   r      )g      @g      @      @)abcstrdtypeabccategory)      	   20130101r   )periods
US/Eastern)r   tzz1 ss)r   freq)
groupintfloatstringobjectcategory_stringcategory_intdatetime
datetimetz	timedelta)columns)r   r   r'   listastyper	   pdtimedelta_range)selfdfs     z/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/tests/groupby/test_numeric_only.pyr3   zTestNumericOnly.df   s     " yy( >>> ???#)$u++#6#6#=#=j#I#I )		&z1===(Q<PPP/qsKKK   
 
 
4 	    methodmeanmedianc                 <   t          g d          }|                    d          }t          ddgddgt          j        d          t          j        d          gd	d
gt          d          t          d          gt          dd          t          dd          gdt          ddgd          g d          } t          ||          d          }t          j        |	                    |          |           |j
        }|                     ||||           d S )Nr$   r%   r)   r#   g      @r   g      @r   z1.5s3sg      ?r   z2013-01-01 12:00:00z2013-01-03 00:00:00r   )r    )r)   r%   r,   r$   r*   r+   r   r   )name)indexr-   Tnumeric_only)r   groupbyr   r0   	Timedeltar   getattrtmassert_frame_equalreindex_liker-   _check)r2   r3   r6   expected_columns_numericgbexpectedresultexpected_columnss           r4   test_averageszTestNumericOnly.test_averages7   sL    $))I)I)I#J#J ZZ  !$as l622BL4F4FGQx344344
 3EEE3EEE  AW---  !
 
 
. %V$$$777
f11(;;XFFF#+B 02JKKKKKr5   minmaxc                 \    t          g d          }|}|                     ||||           d S )N)r$   r%   r&   r)   r*   r+   r,   r   rF   r2   r3   r6   rK   rG   s        r4   test_extremazTestNumericOnly.test_extrema[   sK    
 !  

 

 $4 B 02JKKKKKr5   firstlastc                 \    t          g d          }|}|                     ||||           d S )N)	r$   r%   r&   r'   r(   r)   r*   r+   r,   rP   rQ   s        r4   test_first_lastzTestNumericOnly.test_first_lasto   sI     
 
 

 
 $4 B 02JKKKKKr5   sumcumsumc                     t          g d          }t          g d          }|dk    rt          g d          }|                     ||||           d S )Nr:   )r$   r%   r&   r)   r,   rX   )r$   r%   r)   r,   rP   )r2   r3   r6   rG   rK   s        r4   test_sum_cumsumzTestNumericOnly.test_sum_cumsum   sr    #()I)I)I#J#J  CCC
 
 X$%R%R%RSSB 02JKKKKKr5   prodcumprodc                 \    t          g d          }|}|                     ||||           d S )Nr:   rP   rQ   s        r4   test_prod_cumprodz!TestNumericOnly.test_prod_cumprod   s=     !A!A!ABB#3 B 02JKKKKKr5   cummincummaxc                 \    t          g d          }|}|                     ||||           d S )N)r$   r%   r)   r*   r+   r,   rP   rQ   s        r4   test_cummin_cummaxz"TestNumericOnly.test_cummin_cummax   sE     !SSS
 

 $4 B 02JKKKKKr5   c                    |                     d          }|                    d          rt          t          fnt          }|dv rd                    dd| dt          j        d| d	          d
d| dg          }t          j        ||          5   t          ||                       d d d            n# 1 swxY w Y   n|dv rd                    dt          j        d| d	          t          j        d| d          d| dg          }t          j        ||          5   t          ||                       d d d            n# 1 swxY w Y   n2 t          ||                      }t          j        |j        |           |dvrd                    ddd
d| dt          j        d| d	          t          j        d| d          d| dg          }t          j        ||          5   t          ||          d           d d d            d S # 1 swxY w Y   d S  t          ||          d          }t          j        |j        |           d S )Nr#   cum)rM   rN   r_   r`   rX   r\   |zCategorical is not orderedzCannot perform z with non-ordered Categoricalagg function failed [how->,dtype->object]*function is not implemented for this dtypez(dtype 'str' does not support operation ''match)rW   r7   r8   r[   z-category type does not support sum operationsz,dtype->string]rS   rT   zcategory type does not supportFr>   )r@   
startswithNotImplementedError	TypeErrorjoinreescapepytestraisesrB   rC   assert_index_equalr-   )	r2   r3   r6   rK   rG   rH   	exceptionmsgrJ   s	            r4   rF   zTestNumericOnly._check   s   ZZ  
 170A0A%0H0HW ),,i 	 LLL((0KfKKKIR6RRRSS@HvHHH	 	C y444 & &#F##%%%& & & & & & & & & & & & & & &888((CIR6RRRSSIR6RRRSSHvHHH	 C y444 & &#F##%%%& & & & & & & & & & & & & & & )WR((**F!&.2JKKK***((04@KfKKKIR6RRRSSIR6RRRSSHvHHH
 
C y444 8 8#F##77778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 )WR((e<<<F!&.2BCCCCCs6   B77B;>B;&EEE3HH"HN)__name__
__module____qualname__rs   fixturer3   markparametrizerL   rR   rV   rZ   r^   rb   rF    r5   r4   r   r      s        ^  ^> [X'9::!L !L ;:!LF [Xu~66L L 76L& [X'899L L :9L$ [Xx'899	L 	L :9	L [X	':;;L L <;L [X(';<<	L 	L =<	L6D 6D 6D 6D 6Dr5   r   zkernel, has_arg))allF)anyF)bfillF)corrT)corrwithT)covT)r`   T)r_   T)r\   T)rX   T)diffF)ffillF)rS   T)idxmaxT)idxminT)rT   T)rN   T)r7   T)r8   T)rM   T)nthF)nuniqueF)
pct_changeF)r[   T)quantileT)semT)skewT)kurtT)stdT)rW   T)varTr?   TFkeysa1a2c                    t          ddgddgddgdt          gz  d          }t          | |          }|t          j        u ri nd|i}|                    |          }t          ||           }|r[|du rW| dk    r
t          }	d	}
nd }	d
}
t          j	        |	|
          5   ||i |}d d d            n# 1 swxY w Y   d|j
        vsJ d S | dv s| dv r#|t          j        u r ||i |}d|j
        v sJ d S |r|dusJ |                     d          rt          nt          }d                    dddddt          j        d|  d          g          }
| dk    rd}
n| dk    rd}
n| dk    rd}
t#          j        ||
          5  | dk    r
t          }	d	}
nd }	d
}
t          j	        |	|
          5   ||i | d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S |sL|t          j        ur>t#          j        t          d          5   ||i | d d d            d S # 1 swxY w Y   d S | dv sJ |t          j        u sJ t#          j        t          d          5   ||i | d d d            d S # 1 swxY w Y   d S ) Nr   r         )r   r   a3r   r?   Tr   z'DataFrameGroupBy.corrwith is deprecated rj   r   rl   )r   r   r   r   r   r   rd   re   znot allowed for this dtypez+cannot be performed against 'object' dtypesz!must be a string or a real numberzunsupported operand typerh   rf   rg   r   4dtype 'object' does not support operation 'quantile'r   z8'<' not supported between instances of 'type' and 'type'r   z8'>' not supported between instances of 'type' and 'type'1got an unexpected keyword argument 'numeric_only')r   r   )r   r'   r
   r   
no_defaultr@   rB   r   rC   assert_produces_warningr-   rm   rn   ro   rp   rq   rr   rs   rt   )kernelhas_argr?   r   r3   argskwargsrH   r6   warnrw   rJ   rv   s                r4   test_numeric_onlyr      s   T 
1a&Aq!f1x<PP	Q	QB"62..D3>11RR7UF	D		BR  F A$<4''Z!D;CCDC'C888 	- 	-VT,V,,F	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-&.(((((( 	### HHH.. (((fn$$$$$$	 +$4''''
 ,2+<+<U+C+CR''	hh,=3*<	NvNNNOO	
 	
 ZHCCxLCCxLC]9C000 	( 	(##%?+D<<< ( (''''( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(  
$S^;;]P
 
 
 	$ 	$ FD#F###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$
 /////s~----]9,GHHH 	$ 	$FD#F###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$sl   	B22B69B6+G,	G5GG	GG		GG G	H''H+.H+%	I;;I?I?r   c                    g d}t          g d|           }|                    |          }|dk    rt          ||          rJ d S t          ||          }t          g d          }|                    |          }t          ||          }	t	          ||          }
d}d}||v rM| t
          u rD|dk    rd}nd	}t          j        t          |
          5   ||
  d d d            n# 1 swxY w Y   nF| t
          u r= ||
 } |	|
 }||v r|	                    t
                    }t          j        ||           d}||vr@d}t          j        t          |
          5   ||
ddi d d d            d S # 1 swxY w Y   d S | t
          u rUd                    g d          }t          j        t          |
          5   ||
ddi d d d            d S # 1 swxY w Y   d S | t          k    rF|dk    r@d}t          j        t          |
          5   ||
ddi d d d            d S # 1 swxY w Y   d S  ||
ddi} ||
ddi}t          j        ||           d S )N)r   r   r   )r   r   r   r   r   )r   r   r`   r_   r\   rX   r   )rS   rT   r   r   r   shiftrW   r   r   r   r7   r8   rM   rN   r[   r   r   r   r   z!is not supported for object dtyperj   )rS   rT   rN   r7   r8   rM   r[   r   r   r   r   r   rW   r   r`   r_   r\   rX   r   r?   Tre   )z@SeriesGroupBy.sem called with numeric_only=True and dtype objectz=Series.skew does not allow numeric_only=True with non-numericz7cum(sum|prod|min|max) is not supported for object dtypezCCannot use numeric_only=True with SeriesGroupBy\..* and non-numericz#Cannot use quantile with bool dtypeF)r   r@   hasattrrB   r
   r'   rs   rt   ro   r/   rC   assert_series_equalrp   bool)r   groupby_funcrequestgrouperserrH   r6   expected_serexpected_gbexpected_methodr   fails_on_numeric_object
obj_resultrw   rJ   rI   has_numeric_onlys                    r4   "test_deprecate_numeric_only_seriesr   O  s    iiG
%
(
(
(C	W		Bz!!2|,,,,,R&&F)))$$L&&w//Kk<88O"<55DJ, ...5F??:%%HCC5C]9C000 	 	FDMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 		&"?D):%%v..H
vx000( +++A]9C000 	- 	-FD,t,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-	&hh  
 
 ]9C000 	- 	-FD,t,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-	$<:553]9C000 	. 	.FD-u---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 1D11644e44
vx00000sH   C&&C*-C*	E11E58E59	GGG
	H  H$'H$)rq   rs   pandas._libsr   pandas.errorsr   pandasr0   r   r   r   r   r	   pandas._testing_testingrC   pandas.tests.groupbyr
   r   r|   r}   r   r   r   r$   r%   r'   r   r~   r5   r4   <module>r      s   				        ( ( ( ( ( (                        8 8 8 8 8 8CD CD CD CD CD CD CD CDL      # #H $s~)FGG4&4,!788L$ L$ 98 HGI# #LL$^ 4eV"<==m1 m1 >=m1 m1 m1r5   