o
    dAO                     @   s  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dd g d	eg d	eeed
g d	eg deg deg dgg
ddd Zejddgddd Zejdg ddd Zejdddgdd Zejdddgejdejejgdd Zejdg ddd  Zejdddgd!d" Zejdddgejdejejgd#d$ Zejdg dd%d& Zejdddgd'd( Zejdddgejdejejgd)d* Zejdg dd+d, Zd-d. Z dS )/    N)Categorical	DataFrameGrouperSeries)get_groupby_method_argsab)keyc                 C   s   | d S )N    xr   r   e/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/pandas/tests/groupby/test_raises.py<lambda>   s    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   )paramsc                 C      | j S Nparamrequestr   r   r   by   s   r   TFc                 C   r   r   r   r   r   r   r   groupby_series%   s   r   how)methodagg	transformc           	      C   s  t g dg dtdtdd}t||}|j|d}|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| \}}|d u r| d7krt	|||  d S | d8kr|j
|g|R   d S |j|g|R   d S tj||d9> | d7krt	|||  n | d8kr|j
|g|R   n|j|g|R   W d    d S W d    d S W d    d S 1 s;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msgr   r   r   test_groupby_raises_string*   s   
 !"#$%&'()*+,-./1

$ra   r!   r"   c                 C   s   t g dg dtdtdd}|j|d}|r|d }dd	 }tjtd
d t|| | W d    d S 1 s;w   Y  d S )Nr   r   r   r#   r$   r'   r&   c                 S      t dNTest error messagerT   r   r   r   r   func      z,test_groupby_raises_string_udf.<locals>.funcrd   rN   )r   rP   rQ   rR   rX   rY   rT   rW   r   r   r   r\   r^   rf   r   r   r   test_groupby_raises_string_udf   s   "ri   groupby_func_npc                 C   s   t g dg dtdtdd}|j|d}|r|d }tjdtjtd	fi| \}}|d u r8t|| | d S t	j
||d
 t|| | W d    d S 1 sRw   Y  d S )Nr   r   r   r#   r$   r'   r&   r*   r>   rN   )r   rP   rQ   rR   nprL   r=   rT   rW   rX   rY   r   r   r   rj   r\   r^   r_   r`   r   r   r   test_groupby_raises_string_np   s(   
"rm   c           	      C   sV  t g dg dtdtddddddd	d
}t||}|j|d}|r6|d }|dkr6t|dr4J 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| \}}|d u r| d7krt|||  d S | d8kr|j|g|R   d S |j	|g|R   d S t
j||d9< | d7krt|||  n| d8kr|j|g|R   n|j	|g|R   W d    d S W d    d S W d    d S 1 s$w   Y  d S ):Nr   r   r     r   
         `= r$   r'   r&   r(   r)   r*   r,   r-   z+cannot perform __mul__ with this index typer.   r/   r0   r1   r2   z3datetime64 type does not support cumprod operationsr3   z2datetime64 type does not support cumsum operationsr4   r6   r7   r8   r9   r:   r;   r<   r=   r?   r@   rA   rB   rC   z/cannot perform __truediv__ with this index typerD   z%datetime64 type does not support prodrE   rF   rG   rH   rI   rJ   z1dtype datetime64\[ns\] does not support reductionrK   rL   /datetime64 type does not support sum operationsrM   r    r!   rN   )r   rP   datetimer   rR   rS   rT   rW   r!   r"   rX   rY   rZ   r   r   r   test_groupby_raises_datetime   s   
	
 !"#%$ru   c                 C   s   t g dg dtdtddddddd	d
}|j|d}|r$|d }dd }tjtdd t|| | W d    d S 1 sBw   Y  d S )Nr   r   r   rn   r   ro   rp   rq   rr   r$   r'   r&   c                 S   rb   rc   re   r   r   r   r   rf     rg   z.test_groupby_raises_datetime_udf.<locals>.funcrd   rN   )r   rP   rt   rR   rX   rY   rT   rW   rh   r   r   r    test_groupby_raises_datetime_udf   s   	"rv   c                 C   s   t g dg dtdtddddddd	d
}|j|d}|r$|d }tjtdftjdi| \}}|d u r?t|| | d S t	j
||d t|| | W d    d S 1 sYw   Y  d S )Nr   r   r   rn   r   ro   rp   rq   rr   r$   r'   r&   rs   r*   rN   )r   rP   rt   rR   rk   rL   rT   r=   rW   rX   rY   rl   r   r   r   test_groupby_raises_datetime_np  s(   
"rw   c           
   	   C   s  t g dg dtdtg dg dddd}t||}|j|d}|r6|d	 }|d
kr6t|d
r4J 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|svt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| \}}	|d u r| d=krt	|||  d S | d>kr|j
|g|R   d S |j|g|R   d S tj||	d?> | d=krt	|||  n | d>kr!|j
|g|R   n|j|g|R   W d    d S W d    d S W d    d S 1 sFw   Y  d S )@Nr   r   r   	r   r   r   r   r   r   r   r   r%   r$   T
categoriesorderedr'   r&   r(   r)   r*   r,   r-   =unsupported operand type\(s\) for \*: 'Categorical' and 'int'r.   r/   r0   zz(category type does not support cummax operations|category dtype not supported|cummax is not supported for category dtype)r1   zz(category type does not support cummin operations|category dtype not supported|cummin is not supported for category dtype)r2   z|(category type does not support cumprod operations|category dtype not supported|cumprod is not supported for category dtype)r3   zz(category type does not support cumsum operations|category dtype not supported|cumsum is not supported for category dtype)r4   zDunsupported operand type\(s\) for -: 'Categorical' and 'Categorical'r6   r7   SCannot setitem on a Categorical with a new category \(0\), set the categories firstr8   r9   r:   r;   r<   r=   C'Categorical' with dtype category does not support reduction 'mean'r?   E'Categorical' with dtype category does not support reduction 'median'r@   rA   rB   rC   zDunsupported operand type\(s\) for /: 'Categorical' and 'Categorical'rD   .category type does not support prod operationsrE   zNo matching signature foundrF   rG   #Cannot cast object dtype to float64rH   rI   rJ   C'Categorical' with dtype category does not support reduction 'skew'rK   rL   -category type does not support sum operationsrM   B'Categorical' with dtype category does not support reduction 'var'r    r!   rN   )r   rP   r   r   rR   rS   rT   rU   rV   rW   r!   r"   rX   rY   )
r   r   r   r[   using_copy_on_writer\   r]   r^   r_   r`   r   r   r   test_groupby_raises_category1  s"  
	
"&'./01237;<=>BCDEFGHLMNRT

$r   c              	   C   s   t g dg dtdtg dg dddd}|j|d}|r$|d	 }d
d }tjtdd t|| | W d    d S 1 sBw   Y  d S )Nr   r   r   rx   r$   Try   r'   r&   c                 S   rb   rc   re   r   r   r   r   rf     rg   z.test_groupby_raises_category_udf.<locals>.funcrd   rN   )r   rP   r   rR   rX   rY   rT   rW   rh   r   r   r    test_groupby_raises_category_udf  s$   "r   c              	   C   s   t g dg dtdtg dg dddd}|j|d}|r$|d	 }tjtd
ftjtdfi| \}}|d u rAt|| | d S t	j
||d t|| | W d    d S 1 s[w   Y  d S )Nr   r   r   rx   r$   Try   r'   r&   r   r~   rN   )r   rP   r   rR   rk   rL   rT   r=   rW   rX   rY   rl   r   r   r   test_groupby_raises_category_np  s6   
"r   c              	   C   s  t tg dg dddg dtdtg dg dddd}t||}|j||d}|r>|d	 }|d
kr>t|d
r<J d S td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|st	d fndd!dd"|	rtd#fndd$|	rt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d0t	d1fd2t	d3fd4dd5td6fd7dd8dd9t	d:fd;td6fd<t	d=fd>t	d?f| \}
}|
d u r | d@krt|||  d S | dAkr|j|g|R   d S |j|g|R   d S tj|
|dB> | d@kr5t|||  n | dAkrD|j|g|R   n|j|g|R   W d    d S W d    d S W d    d S 1 siw   Y  d S )CNrx   r$   Try   r   r   )	r   r   r   r   r   r   r%   r%   r%   )r   observedr&   r(   c                 s   s    | ]}|j V  qd S r   )empty).0groupr   r   r   	<genexpr>  s    z;test_groupby_raises_category_on_category.<locals>.<genexpr>r)   r*   r,   r-   r|   r.   r/   r0   zz(cummax is not supported for category dtype|category dtype not supported|category type does not support cummax operations)r1   zz(cummin is not supported for category dtype|category dtype not supported|category type does not support cummin operations)r2   z|(cumprod is not supported for category dtype|category dtype not supported|category type does not support cumprod operations)r3   zz(cumsum is not supported for category dtype|category dtype not supported|category type does not support cumsum operations)r4   r5   r6   r7   r}   r8   r9   z*attempt to get argmax of an empty sequencer:   z*attempt to get argmin of an empty sequencer;   r<   r=   r~   r?   r   r@   rA   rB   rC   rD   r   rE   r+   rF   rG   r   rH   rI   rJ   r   rK   rL   r   rM   r   r    r!   rN   )r   r   rP   r   rR   rS   r,   groupsvaluesrT   rU   rV   rW   r!   r"   rX   rY   )r   r   r   r[   r   r   r\   r]   r^   empty_groupsr_   r`   r   r   r   (test_groupby_raises_category_on_category  s,  
	
"#$+,
/
2348<=>?@ABCDEFJKLP
R



$r   c                  C   s`   t dgdgdgd} | jddd}tjtdd |d	  W d    d S 1 s)w   Y  d S )
Nr   r
   r   )r   r   r%   r   )axisz'Cannot subset columns when using axis=1rN   r   )r   rR   rX   rY   rV   )r\   r^   r   r   r   %test_subsetting_columns_axis_1_raisest  s
   
"r   )!rt   numpyrk   rX   pandasr   r   r   r   pandas.tests.groupbyr   fixturearraydictziprP   r   r   markparametrizera   ri   rL   r=   rm   ru   rv   rw   r   r   r   r   r   r   r   r   r   <module>   s\   



U

I


"
 